diff --git a/README.docify.md b/README.docify.md index 8905eaa..fa873e5 100644 --- a/README.docify.md +++ b/README.docify.md @@ -34,6 +34,10 @@ plus a `u64` (cached hash code), it would be silly to use `Interned` with int directly, however it makes sense to do so for the purposes of memoizing an expensive computation via `Memoized`. +An interned string type, `InStr`, is also provided as a convenient wrapper around +`Interned<&'static str>`. It has a number of extra impls and should be your go-to type if you +want to work with interned strings. + ### Interned Example diff --git a/README.md b/README.md index f14766f..80680e9 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,10 @@ plus a `u64` (cached hash code), it would be silly to use `Interned` with int directly, however it makes sense to do so for the purposes of memoizing an expensive computation via `Memoized`. +An interned string type, `InStr`, is also provided as a convenient wrapper around +`Interned<&'static str>`. It has a number of extra impls and should be your go-to type if you +want to work with interned strings. + ### Interned Example ```rust #[test] @@ -49,6 +53,10 @@ fn test_interned_showcase() { assert_ne!(d, "fdsa".into()); assert_eq!(Interned::from("asdf"), d); let e = Interned::from([1, 2, 3, 4, 5].as_slice()); + let f = InStr::from("abc"); + let g: InStr = "abc".into(); + assert_eq!(f, g); + assert_eq!(f.as_ptr(), g.as_ptr()); assert_eq!(e, [1, 2, 3, 4, 5].as_slice().into()); assert_ne!(e, [4, 1, 7].as_slice().into()); assert_eq!(format!("{b:?}"), "Interned { value: 1289 }"); diff --git a/src/lib.rs b/src/lib.rs index c58d41a..43213c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -30,6 +30,10 @@ //! integer types directly, however it makes sense to do so for the purposes of memoizing an //! expensive computation via [`Memoized`]. //! +//! An interned string type, [`InStr`], is also provided as a convenient wrapper around +//! [`Interned<&'static str>`]. It has a number of extra impls and should be your go-to type if +//! you want to work with interned strings. +//! //! ### Interned Example #![doc = docify::embed_run!("tests/tests.rs", test_interned_showcase)] //! diff --git a/tests/tests.rs b/tests/tests.rs index 945b626..f9752b8 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -180,6 +180,10 @@ fn test_interned_showcase() { assert_ne!(d, "fdsa".into()); assert_eq!(Interned::from("asdf"), d); let e = Interned::from([1, 2, 3, 4, 5].as_slice()); + let f = InStr::from("abc"); + let g: InStr = "abc".into(); + assert_eq!(f, g); + assert_eq!(f.as_ptr(), g.as_ptr()); assert_eq!(e, [1, 2, 3, 4, 5].as_slice().into()); assert_ne!(e, [4, 1, 7].as_slice().into()); assert_eq!(format!("{b:?}"), "Interned { value: 1289 }");