diff --git a/compact_str/src/features/bytes.rs b/compact_str/src/features/bytes.rs index 1affbb72..6849bd4e 100644 --- a/compact_str/src/features/bytes.rs +++ b/compact_str/src/features/bytes.rs @@ -32,7 +32,7 @@ impl CompactString { /// // `bytes::Buf` is implemented for `std::io::Cursor<&[u8]>` /// let mut invalid = io::Cursor::new(&[0, 159]); /// - /// // The provided buffer is invalid, so trying to create a `ComapctStr` will fail + /// // The provided buffer is invalid, so trying to create a `CompactString` will fail /// assert!(CompactString::from_utf8_buf(&mut invalid).is_err()); /// ``` pub fn from_utf8_buf(buf: &mut B) -> Result { @@ -45,7 +45,7 @@ impl CompactString { /// # Safety /// This function is unsafe because it does not check that the provided bytes are valid UTF-8. /// If this constraint is violated, it may cause memory safety issues with futures uses of the - /// `ComapctStr`, as the rest of the library assumes that `CompactString`s are valid UTF-8 + /// `CompactString`, as the rest of the library assumes that `CompactString`s are valid UTF-8 /// /// # Examples /// ``` diff --git a/compact_str/src/features/serde.rs b/compact_str/src/features/serde.rs index a963fafa..29a1a019 100644 --- a/compact_str/src/features/serde.rs +++ b/compact_str/src/features/serde.rs @@ -9,7 +9,7 @@ use serde::de::{ use crate::CompactString; -fn compact_str<'de: 'a, 'a, D: Deserializer<'de>>( +fn compact_string<'de: 'a, 'a, D: Deserializer<'de>>( deserializer: D, ) -> Result { struct CompactStringVisitor; @@ -69,6 +69,6 @@ impl serde::Serialize for CompactString { impl<'de> serde::Deserialize<'de> for CompactString { fn deserialize>(deserializer: D) -> Result { - compact_str(deserializer) + compact_string(deserializer) } } diff --git a/compact_str/src/lib.rs b/compact_str/src/lib.rs index 174216b0..78c5ed83 100644 --- a/compact_str/src/lib.rs +++ b/compact_str/src/lib.rs @@ -349,7 +349,6 @@ impl CompactString { /// assert!(compact.is_heap_allocated()); /// assert!(compact.capacity() >= 200); /// ``` - #[inline] pub fn reserve(&mut self, additional: usize) { self.repr.reserve(additional) @@ -429,7 +428,7 @@ impl CompactString { } /// Removes the last character from the [`CompactString`] and returns it. - /// Returns `None` if this `ComapctStr` is empty. + /// Returns `None` if this [`CompactString`] is empty. /// /// # Examples /// ``` diff --git a/compact_str/src/traits.rs b/compact_str/src/traits.rs index 175e7b57..7dc5dd9a 100644 --- a/compact_str/src/traits.rs +++ b/compact_str/src/traits.rs @@ -19,11 +19,11 @@ use crate::CompactString; /// A trait for converting a value to a `CompactString`. /// /// This trait is automatically implemented for any type which implements the -/// [`fmt::Display`] trait. As such, `ToCompactString` shouldn't be implemented directly: -/// [`fmt::Display`] should be implemented instead, and you get the `ToCompactString` +/// [`fmt::Display`] trait. As such, [`ToCompactString`] shouldn't be implemented directly: +/// [`fmt::Display`] should be implemented instead, and you get the [`ToCompactString`] /// implementation for free. pub trait ToCompactString { - /// Converts the given value to a `CompactString`. + /// Converts the given value to a [`CompactString`]. /// /// # Examples /// @@ -43,9 +43,10 @@ pub trait ToCompactString { /// # Safety /// -/// * CompactString does not contain any lifetime -/// * CompactString is 'static -/// * CompactString is a container to `u8`, which is `LifetimeFree`. +/// * [`CompactString`] does not contain any lifetime +/// * [`CompactString`] is 'static +/// * [`CompactString`] is a container to `u8`, which is `LifetimeFree`. +/// unsafe impl LifetimeFree for CompactString {} unsafe impl LifetimeFree for Repr {} @@ -66,6 +67,7 @@ unsafe impl LifetimeFree for Repr {} /// * `String`, `CompactString` /// * `f32`, `f64` /// * For floats we use [`ryu`] crate which sometimes provides different formatting than [`std`] +/// impl ToCompactString for T { #[inline] fn to_compact_string(&self) -> CompactString {