diff --git a/src/bytes.rs b/src/bytes.rs index ccfd1a5..001835a 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -428,10 +428,13 @@ where } } -impl HipByt<'static, B> { +impl HipByt<'static, B> +where + B: Backend, +{ /// Creates a new `HipByt` from a static slice without copying the slice. /// - /// Handy shortcut to make a `HipByt<'static, _>`. + /// Handy shortcut to make a `HipByt<'static, _>` out of a `&'static [u8]`. /// /// # Examples /// @@ -442,6 +445,7 @@ impl HipByt<'static, B> { /// let b = HipByt::from_static(b"hello\0"); /// assert_eq!(b.len(), 6); /// ``` + #[inline] #[must_use] pub const fn from_static(bytes: &'static [u8]) -> Self { Self::borrowed(bytes) diff --git a/src/string.rs b/src/string.rs index c5bd5a6..ca1a373 100644 --- a/src/string.rs +++ b/src/string.rs @@ -684,6 +684,30 @@ where } } +impl HipStr<'static, B> +where + B: Backend, +{ + /// Creates a new `HipStr` from a static string slice without copying the slice. + /// + /// Handy shortcut to make a `HipStr<'static, _>` out of a `&'static str`. + /// + /// # Examples + /// + /// Basic usage: + /// + /// ``` + /// # use hipstr::HipStr; + /// let s = HipStr::from_static("hello"); + /// assert_eq!(s.len(), 5); + /// ``` + #[inline] + #[must_use] + pub const fn from_static(value: &'static str) -> Self { + Self::borrowed(value) + } +} + // Manual implementation needed to remove trait bound on B::RawPointer. impl<'borrow, B> Clone for HipStr<'borrow, B> where