From 8a12d911a78d37189e83a6b31303962bab64a219 Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 11:37:33 +0000 Subject: [PATCH 1/6] Initial commit with task details Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: https://github.com/linksplatform/data-rs/issues/16 --- .gitkeep | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitkeep diff --git a/.gitkeep b/.gitkeep new file mode 100644 index 0000000..2386fcb --- /dev/null +++ b/.gitkeep @@ -0,0 +1 @@ +# .gitkeep file auto-generated at 2026-04-14T11:37:33.446Z for PR creation at branch issue-16-3373fe2814a2 for issue https://github.com/linksplatform/data-rs/issues/16 \ No newline at end of file From 70375679c274602081c095e38461f97effe14bb0 Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 11:42:24 +0000 Subject: [PATCH 2/6] feat!: replace funty with platform-num LinkReference Replace `funty::Unsigned` and `FuntyPart` in the `LinkType` trait with `LinkReference` from `platform-num`, eliminating the `funty` dependency. - `LinkType` now extends `LinkReference + WrappingAdd` - All `T::funty(n)` calls replaced with `T::from_byte(n)` - Re-export `LinkReference` from crate root for downstream use - Added `num-traits` dependency for `WrappingAdd` bound This unifies the trait hierarchy with `platform-trees` so downstream crates like `doublets-rs` can use a single `T: LinkReference` bound. Closes #16 Co-Authored-By: Claude Opus 4.6 --- Cargo.lock | 35 ++++++-- Cargo.toml | 3 +- ...0260414_replace_funty_with_platform_num.md | 14 +++ src/constants.rs | 24 ++--- src/hybrid.rs | 10 +-- src/lib.rs | 1 + src/link_type.rs | 89 +------------------ 7 files changed, 65 insertions(+), 111 deletions(-) create mode 100644 changelog.d/20260414_replace_funty_with_platform_num.md diff --git a/Cargo.lock b/Cargo.lock index e7ccac5..6dd3c7b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,6 +17,12 @@ version = "1.0.102" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + [[package]] name = "beef" version = "0.5.2" @@ -67,12 +73,6 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "getrandom" version = "0.4.2" @@ -156,17 +156,36 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + [[package]] name = "platform-data" -version = "0.1.0-beta.3" +version = "1.0.0" dependencies = [ "beef", - "funty", + "num-traits", + "platform-num", "quickcheck", "quickcheck_macros", "thiserror", ] +[[package]] +name = "platform-num" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e56c23d5941ec71f27ae66257c92adf2450f2c94c47b5a37529453dcb3b26be" +dependencies = [ + "num-traits", +] + [[package]] name = "prettyplease" version = "0.2.37" diff --git a/Cargo.toml b/Cargo.toml index c4bc808..a8adf3d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,8 @@ categories = ["data-structures"] [dependencies] beef = "0.5.2" -funty = "2.0.0" +num-traits = "0.2" +platform-num = "0.7.0" thiserror = "2.0.18" [dev-dependencies] diff --git a/changelog.d/20260414_replace_funty_with_platform_num.md b/changelog.d/20260414_replace_funty_with_platform_num.md new file mode 100644 index 0000000..04363ce --- /dev/null +++ b/changelog.d/20260414_replace_funty_with_platform_num.md @@ -0,0 +1,14 @@ +--- +bump: major +--- + +### Changed +- Replaced `funty` dependency with `platform-num` (`LinkReference` trait) +- `LinkType` now extends `LinkReference` from `platform-num` instead of `funty::Unsigned` +- Replaced `FuntyPart::funty(n)` calls with `LinkReference::from_byte(n)` +- Added `num-traits` dependency for `WrappingAdd` support + +### Removed +- Removed `funty` dependency +- Removed `FuntyPart` trait (replaced by `LinkReference::from_byte`) +- Removed all explicit `TryFrom`/`TryInto` bounds from `LinkType` (now provided by `LinkReference`) diff --git a/src/constants.rs b/src/constants.rs index 1c0679a..037c399 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -20,7 +20,7 @@ pub struct LinksConstants { impl LinksConstants { fn default_target_part() -> T { - T::funty(2) + T::from_byte(2) } pub fn full_new( @@ -29,17 +29,17 @@ impl LinksConstants { external: Option>, ) -> Self { Self { - index_part: T::funty(0), - source_part: T::funty(1), + index_part: T::from_byte(0), + source_part: T::from_byte(1), target_part, - null: T::funty(0), + null: T::from_byte(0), r#continue: *internal.end(), - r#break: *internal.end() - T::funty(1), - skip: *internal.end() - T::funty(2), - any: *internal.end() - T::funty(3), - itself: *internal.end() - T::funty(4), - error: *internal.end() - T::funty(5), - internal_range: *internal.start()..=*internal.end() - T::funty(6), + r#break: *internal.end() - T::from_byte(1), + skip: *internal.end() - T::from_byte(2), + any: *internal.end() - T::from_byte(3), + itself: *internal.end() - T::from_byte(4), + error: *internal.end() - T::from_byte(5), + internal_range: *internal.start()..=*internal.end() - T::from_byte(6), external_range: external, } } @@ -79,9 +79,9 @@ impl LinksConstants { fn default_internal(external: bool) -> RangeInclusive { if external { - T::funty(1)..=Hybrid::half() + T::from_byte(1)..=Hybrid::half() } else { - T::funty(1)..=T::MAX + T::from_byte(1)..=T::MAX } } diff --git a/src/hybrid.rs b/src/hybrid.rs index 8c45d05..c771833 100644 --- a/src/hybrid.rs +++ b/src/hybrid.rs @@ -12,7 +12,7 @@ impl Hybrid { #[must_use] pub fn half() -> T { - T::MAX / T::funty(2) + T::MAX / T::from_byte(2) } pub fn external(value: T) -> Self { @@ -26,11 +26,11 @@ impl Hybrid { } fn extend_value(value: T) -> T { - (T::MAX - value).wrapping_add(T::funty(1)) + (T::MAX - value).wrapping_add(&T::from_byte(1)) } pub fn is_zero(&self) -> bool { - self.value == T::funty(0) + self.value == T::from_byte(0) } pub fn is_internal(&self) -> bool { @@ -38,11 +38,11 @@ impl Hybrid { } pub fn is_external(&self) -> bool { - !self.is_internal() || self.value == T::funty(0) + !self.is_internal() || self.value == T::from_byte(0) } pub fn abs(&self) -> T { - self.value.wrapping_add(T::funty(1)).wrapping_add(T::MAX) + self.value.wrapping_add(&T::from_byte(1)).wrapping_add(&T::MAX) } pub const fn as_inner(&self) -> T { diff --git a/src/lib.rs b/src/lib.rs index fe865e7..21be38f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,7 @@ pub use converters::{AddrToRaw, RawToAddr}; pub use flow::Flow; pub use hybrid::Hybrid; pub use link_type::LinkType; +pub use platform_num::LinkReference; pub use links::{Error, Links, ReadHandler, WriteHandler}; pub use point::{Point, PointIter}; pub use query::{Query, ToQuery}; diff --git a/src/link_type.rs b/src/link_type.rs index 84e1d26..1811b03 100644 --- a/src/link_type.rs +++ b/src/link_type.rs @@ -1,87 +1,6 @@ -use funty::Unsigned; -use std::{ - convert::{TryFrom, TryInto}, - fmt::Debug, -}; +use num_traits::WrappingAdd; +use platform_num::LinkReference; -/// Trait for creating small numeric values from u8. -/// -/// This trait provides a convenient way to create numeric types from small u8 values, -/// which is commonly needed when working with link constants and indices. -pub trait FuntyPart: Sized + TryFrom { - /// Create a value from a u8. Panics if the conversion fails. - fn funty(n: u8) -> Self; -} +pub trait LinkType: LinkReference + WrappingAdd {} -impl> FuntyPart for All -where - >::Error: Debug, -{ - fn funty(n: u8) -> Self { - All::try_from(n).expect("conversion from u8 should succeed for all unsigned types") - } -} - -/// Trait bound for numeric types that can be used as link identifiers. -/// -/// This trait combines several requirements: -/// - Must be an unsigned integer type (via `Unsigned`) -/// - Must support creation from small values (via `FuntyPart`) -/// - Must support conversions to/from various integer types -pub trait LinkType: - Unsigned - + FuntyPart - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto -{ -} - -impl LinkType for All where - All: TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryFrom - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto - + TryInto -{ -} +impl LinkType for T {} From 261dfaeda5d104fdb2673b329320f608120d533a Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 11:46:16 +0000 Subject: [PATCH 3/6] style: fix formatting in hybrid.rs and lib.rs Co-Authored-By: Claude Opus 4.6 --- src/hybrid.rs | 4 +++- src/lib.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/hybrid.rs b/src/hybrid.rs index c771833..a6c1af3 100644 --- a/src/hybrid.rs +++ b/src/hybrid.rs @@ -42,7 +42,9 @@ impl Hybrid { } pub fn abs(&self) -> T { - self.value.wrapping_add(&T::from_byte(1)).wrapping_add(&T::MAX) + self.value + .wrapping_add(&T::from_byte(1)) + .wrapping_add(&T::MAX) } pub const fn as_inner(&self) -> T { diff --git a/src/lib.rs b/src/lib.rs index 21be38f..2bd9128 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,7 @@ pub use converters::{AddrToRaw, RawToAddr}; pub use flow::Flow; pub use hybrid::Hybrid; pub use link_type::LinkType; -pub use platform_num::LinkReference; pub use links::{Error, Links, ReadHandler, WriteHandler}; +pub use platform_num::LinkReference; pub use point::{Point, PointIter}; pub use query::{Query, ToQuery}; From 7006035ee287e9a7e3a74c26efb4e4f8d0dc9e4b Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 11:52:37 +0000 Subject: [PATCH 4/6] Revert "Initial commit with task details" This reverts commit 8a12d911a78d37189e83a6b31303962bab64a219. --- .gitkeep | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .gitkeep diff --git a/.gitkeep b/.gitkeep deleted file mode 100644 index 2386fcb..0000000 --- a/.gitkeep +++ /dev/null @@ -1 +0,0 @@ -# .gitkeep file auto-generated at 2026-04-14T11:37:33.446Z for PR creation at branch issue-16-3373fe2814a2 for issue https://github.com/linksplatform/data-rs/issues/16 \ No newline at end of file From c78bff6732929f85bc5a53a149bc8d39bde01938 Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 12:08:22 +0000 Subject: [PATCH 5/6] feat!: remove LinkType trait, replace with LinkReference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit LinkType was a thin wrapper around LinkReference + WrappingAdd. Remove it entirely per review feedback — downstream crates like doublets-rs should use LinkReference directly. WrappingAdd is still needed from num-traits where wrapping arithmetic is used (hybrid.rs, constants.rs, converters.rs, links.rs) until platform-num adds it to LinkReference. Co-Authored-By: Claude Opus 4.6 --- README.md | 9 +++++---- .../20260414_replace_funty_with_platform_num.md | 6 +++--- src/constants.rs | 10 ++++++---- src/converters.rs | 8 +++++--- src/hybrid.rs | 5 +++-- src/lib.rs | 2 -- src/link_type.rs | 6 ------ src/links.rs | 8 +++++--- 8 files changed, 27 insertions(+), 27 deletions(-) delete mode 100644 src/link_type.rs diff --git a/README.md b/README.md index 8a9beca..a523b76 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This crate provides core data types and traits for the [Links Platform](https:// The `platform-data` crate provides: -- **`LinkType`** — A trait defining the numeric types that can be used as link identifiers +- **`LinkReference`** — A trait (from `platform-num`) defining the numeric types that can be used as link identifiers - **`Links`** — The core trait for CRUD operations on doublet links storage - **`Flow`** — Control flow type for iteration operations (Continue/Break) - **`Query`** — A wrapper for link queries using copy-on-write semantics @@ -115,7 +115,7 @@ assert!(external.is_external()); ### Implementing the Links trait ```rust -use platform_data::{Links, LinkType, LinksConstants, Flow, Error, ReadHandler, WriteHandler}; +use platform_data::{Links, LinkReference, LinksConstants, Flow, Error, ReadHandler, WriteHandler}; // The Links trait provides CRUD operations for doublet links: // - constants_links() - get storage configuration @@ -132,7 +132,7 @@ use platform_data::{Links, LinkType, LinksConstants, Flow, Error, ReadHandler, W | Type | Description | |------|-------------| -| `LinkType` | Trait bound for numeric types usable as link identifiers (unsigned integers) | +| `LinkReference` | Trait bound (from `platform-num`) for numeric types usable as link identifiers (unsigned integers) | | `Links` | Main trait defining CRUD operations for links storage | | `Flow` | Control flow enum: `Continue` or `Break` for iteration control | | `Query<'a, T>` | Copy-on-write query wrapper for efficient link queries | @@ -162,7 +162,8 @@ This crate requires **Rust 1.85 or later** (stable toolchain, edition 2024). ## Dependencies - [beef](https://crates.io/crates/beef) — Faster and more compact Cow implementation -- [funty](https://crates.io/crates/funty) — Fundamental type unification +- [platform-num](https://crates.io/crates/platform-num) — Numeric traits for the Links Platform +- [num-traits](https://crates.io/crates/num-traits) — Numeric traits (`WrappingAdd`) - [thiserror](https://crates.io/crates/thiserror) — Derive macro for error types ## Documentation diff --git a/changelog.d/20260414_replace_funty_with_platform_num.md b/changelog.d/20260414_replace_funty_with_platform_num.md index 04363ce..160bf01 100644 --- a/changelog.d/20260414_replace_funty_with_platform_num.md +++ b/changelog.d/20260414_replace_funty_with_platform_num.md @@ -4,11 +4,11 @@ bump: major ### Changed - Replaced `funty` dependency with `platform-num` (`LinkReference` trait) -- `LinkType` now extends `LinkReference` from `platform-num` instead of `funty::Unsigned` +- Replaced all `LinkType` bounds with `LinkReference` from `platform-num` - Replaced `FuntyPart::funty(n)` calls with `LinkReference::from_byte(n)` -- Added `num-traits` dependency for `WrappingAdd` support ### Removed - Removed `funty` dependency +- Removed `LinkType` trait entirely (replaced by `LinkReference`) - Removed `FuntyPart` trait (replaced by `LinkReference::from_byte`) -- Removed all explicit `TryFrom`/`TryInto` bounds from `LinkType` (now provided by `LinkReference`) +- Removed `link_type.rs` module diff --git a/src/constants.rs b/src/constants.rs index 037c399..ec63bb8 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,9 +1,11 @@ use std::ops::RangeInclusive; -use crate::{Hybrid, LinkType}; +use crate::Hybrid; +use num_traits::WrappingAdd; +use platform_num::LinkReference; #[derive(Clone, Eq, PartialEq, Debug)] -pub struct LinksConstants { +pub struct LinksConstants { pub index_part: T, pub source_part: T, pub target_part: T, @@ -18,7 +20,7 @@ pub struct LinksConstants { pub external_range: Option>, } -impl LinksConstants { +impl LinksConstants { fn default_target_part() -> T { T::from_byte(2) } @@ -108,7 +110,7 @@ impl LinksConstants { } } -impl Default for LinksConstants { +impl Default for LinksConstants { fn default() -> Self { Self::new() } diff --git a/src/converters.rs b/src/converters.rs index 5e3b966..fb724e1 100644 --- a/src/converters.rs +++ b/src/converters.rs @@ -1,10 +1,12 @@ -use crate::{Hybrid, LinkType}; +use crate::Hybrid; +use num_traits::WrappingAdd; +use platform_num::LinkReference; #[derive(Default)] pub struct AddrToRaw; impl AddrToRaw { - pub fn convert(&self, source: T) -> T { + pub fn convert(&self, source: T) -> T { Hybrid::external(source).as_inner() } } @@ -13,7 +15,7 @@ impl AddrToRaw { pub struct RawToAddr; impl RawToAddr { - pub fn convert(&self, source: T) -> T { + pub fn convert(&self, source: T) -> T { Hybrid::external(source).abs() } } diff --git a/src/hybrid.rs b/src/hybrid.rs index a6c1af3..a7af2b9 100644 --- a/src/hybrid.rs +++ b/src/hybrid.rs @@ -1,11 +1,12 @@ -use crate::LinkType; +use num_traits::WrappingAdd; +use platform_num::LinkReference; #[derive(Debug, Clone, Copy, Hash, PartialOrd, PartialEq, Ord, Eq)] pub struct Hybrid { value: T, } -impl Hybrid { +impl Hybrid { pub const fn new(value: T) -> Self { Self::internal(value) } diff --git a/src/lib.rs b/src/lib.rs index 2bd9128..43d006f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,7 +2,6 @@ mod constants; mod converters; mod flow; mod hybrid; -mod link_type; mod links; mod point; mod query; @@ -11,7 +10,6 @@ pub use constants::LinksConstants; pub use converters::{AddrToRaw, RawToAddr}; pub use flow::Flow; pub use hybrid::Hybrid; -pub use link_type::LinkType; pub use links::{Error, Links, ReadHandler, WriteHandler}; pub use platform_num::LinkReference; pub use point::{Point, PointIter}; diff --git a/src/link_type.rs b/src/link_type.rs deleted file mode 100644 index 1811b03..0000000 --- a/src/link_type.rs +++ /dev/null @@ -1,6 +0,0 @@ -use num_traits::WrappingAdd; -use platform_num::LinkReference; - -pub trait LinkType: LinkReference + WrappingAdd {} - -impl LinkType for T {} diff --git a/src/links.rs b/src/links.rs index 7ccc94f..f8900b6 100644 --- a/src/links.rs +++ b/src/links.rs @@ -1,8 +1,10 @@ -use crate::{Flow, LinkType, LinksConstants}; +use crate::{Flow, LinksConstants}; +use num_traits::WrappingAdd; +use platform_num::LinkReference; use std::{borrow::Cow, error, io}; #[derive(thiserror::Error, Debug)] -pub enum Error<'a, T: LinkType> { +pub enum Error<'a, T: LinkReference + WrappingAdd> { #[error("link {0} does not exist.")] NotExists(T), @@ -26,7 +28,7 @@ pub type ReadHandler<'a, T> = &'a mut dyn FnMut(&[T]) -> Flow; pub type WriteHandler<'a, T> = &'a mut dyn FnMut(&[T], &[T]) -> Flow; -pub trait Links { +pub trait Links { fn constants_links(&self) -> LinksConstants; fn count_links(&self, query: &[T]) -> T; From c71ed2b513779caa553606b086bd2f4fc47f145f Mon Sep 17 00:00:00 2001 From: konard Date: Tue, 14 Apr 2026 13:03:21 +0000 Subject: [PATCH 6/6] feat!: upgrade platform-num to 0.8.0, drop num-traits dependency LinkReference in platform-num 0.8.0 includes WrappingArithmetic as a supertrait, so explicit + WrappingAdd bounds and the num-traits dependency are no longer needed. Co-Authored-By: Claude Opus 4.6 --- Cargo.lock | 5 ++--- Cargo.toml | 3 +-- README.md | 3 +-- changelog.d/20260414_replace_funty_with_platform_num.md | 4 +++- src/constants.rs | 7 +++---- src/converters.rs | 5 ++--- src/hybrid.rs | 3 +-- src/links.rs | 5 ++--- 8 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6dd3c7b..051aea6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -170,7 +170,6 @@ name = "platform-data" version = "1.0.0" dependencies = [ "beef", - "num-traits", "platform-num", "quickcheck", "quickcheck_macros", @@ -179,9 +178,9 @@ dependencies = [ [[package]] name = "platform-num" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e56c23d5941ec71f27ae66257c92adf2450f2c94c47b5a37529453dcb3b26be" +checksum = "2c4ca8e18138b1c90ad802aff931f946a0e6bd760c35af30f1ff2489489ab54a" dependencies = [ "num-traits", ] diff --git a/Cargo.toml b/Cargo.toml index a8adf3d..09149ae 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,8 +14,7 @@ categories = ["data-structures"] [dependencies] beef = "0.5.2" -num-traits = "0.2" -platform-num = "0.7.0" +platform-num = "0.8.0" thiserror = "2.0.18" [dev-dependencies] diff --git a/README.md b/README.md index a523b76..a2f8c1b 100644 --- a/README.md +++ b/README.md @@ -162,8 +162,7 @@ This crate requires **Rust 1.85 or later** (stable toolchain, edition 2024). ## Dependencies - [beef](https://crates.io/crates/beef) — Faster and more compact Cow implementation -- [platform-num](https://crates.io/crates/platform-num) — Numeric traits for the Links Platform -- [num-traits](https://crates.io/crates/num-traits) — Numeric traits (`WrappingAdd`) +- [platform-num](https://crates.io/crates/platform-num) — Numeric traits for the Links Platform (`LinkReference`, `WrappingAdd`, etc.) - [thiserror](https://crates.io/crates/thiserror) — Derive macro for error types ## Documentation diff --git a/changelog.d/20260414_replace_funty_with_platform_num.md b/changelog.d/20260414_replace_funty_with_platform_num.md index 160bf01..f08fa5b 100644 --- a/changelog.d/20260414_replace_funty_with_platform_num.md +++ b/changelog.d/20260414_replace_funty_with_platform_num.md @@ -3,12 +3,14 @@ bump: major --- ### Changed -- Replaced `funty` dependency with `platform-num` (`LinkReference` trait) +- Replaced `funty` dependency with `platform-num` 0.8.0 (`LinkReference` trait) - Replaced all `LinkType` bounds with `LinkReference` from `platform-num` - Replaced `FuntyPart::funty(n)` calls with `LinkReference::from_byte(n)` +- Simplified all generic bounds from `T: LinkReference + WrappingAdd` to `T: LinkReference` (`WrappingArithmetic` is now a supertrait of `LinkReference` in `platform-num` 0.8.0) ### Removed - Removed `funty` dependency +- Removed `num-traits` dependency (re-exported by `platform-num`) - Removed `LinkType` trait entirely (replaced by `LinkReference`) - Removed `FuntyPart` trait (replaced by `LinkReference::from_byte`) - Removed `link_type.rs` module diff --git a/src/constants.rs b/src/constants.rs index ec63bb8..35b21bd 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,11 +1,10 @@ use std::ops::RangeInclusive; use crate::Hybrid; -use num_traits::WrappingAdd; use platform_num::LinkReference; #[derive(Clone, Eq, PartialEq, Debug)] -pub struct LinksConstants { +pub struct LinksConstants { pub index_part: T, pub source_part: T, pub target_part: T, @@ -20,7 +19,7 @@ pub struct LinksConstants { pub external_range: Option>, } -impl LinksConstants { +impl LinksConstants { fn default_target_part() -> T { T::from_byte(2) } @@ -110,7 +109,7 @@ impl LinksConstants { } } -impl Default for LinksConstants { +impl Default for LinksConstants { fn default() -> Self { Self::new() } diff --git a/src/converters.rs b/src/converters.rs index fb724e1..36cd89f 100644 --- a/src/converters.rs +++ b/src/converters.rs @@ -1,12 +1,11 @@ use crate::Hybrid; -use num_traits::WrappingAdd; use platform_num::LinkReference; #[derive(Default)] pub struct AddrToRaw; impl AddrToRaw { - pub fn convert(&self, source: T) -> T { + pub fn convert(&self, source: T) -> T { Hybrid::external(source).as_inner() } } @@ -15,7 +14,7 @@ impl AddrToRaw { pub struct RawToAddr; impl RawToAddr { - pub fn convert(&self, source: T) -> T { + pub fn convert(&self, source: T) -> T { Hybrid::external(source).abs() } } diff --git a/src/hybrid.rs b/src/hybrid.rs index a7af2b9..7766cb7 100644 --- a/src/hybrid.rs +++ b/src/hybrid.rs @@ -1,4 +1,3 @@ -use num_traits::WrappingAdd; use platform_num::LinkReference; #[derive(Debug, Clone, Copy, Hash, PartialOrd, PartialEq, Ord, Eq)] @@ -6,7 +5,7 @@ pub struct Hybrid { value: T, } -impl Hybrid { +impl Hybrid { pub const fn new(value: T) -> Self { Self::internal(value) } diff --git a/src/links.rs b/src/links.rs index f8900b6..5334990 100644 --- a/src/links.rs +++ b/src/links.rs @@ -1,10 +1,9 @@ use crate::{Flow, LinksConstants}; -use num_traits::WrappingAdd; use platform_num::LinkReference; use std::{borrow::Cow, error, io}; #[derive(thiserror::Error, Debug)] -pub enum Error<'a, T: LinkReference + WrappingAdd> { +pub enum Error<'a, T: LinkReference> { #[error("link {0} does not exist.")] NotExists(T), @@ -28,7 +27,7 @@ pub type ReadHandler<'a, T> = &'a mut dyn FnMut(&[T]) -> Flow; pub type WriteHandler<'a, T> = &'a mut dyn FnMut(&[T], &[T]) -> Flow; -pub trait Links { +pub trait Links { fn constants_links(&self) -> LinksConstants; fn count_links(&self, query: &[T]) -> T;