/ cab / runtime / value / string.rs
string.rs
 1  use std::ops;
 2  
 3  use dup::Dupe;
 4  
 5  #[derive(Clone, Dupe, PartialEq, Eq, PartialOrd, Ord, Hash)]
 6  #[expect(clippy::module_name_repetitions)]
 7  pub struct SString(#[doc(hidden)] pub arcstr::Substr);
 8  
 9  #[doc(hidden)]
10  pub mod private {
11     pub use arcstr::literal_substr;
12  }
13  
14  #[macro_export]
15  #[doc(hidden)]
16  macro_rules! __string_new {
17     ($s:literal $(,)?) => {
18        $crate::value::SString($crate::value::string::private::literal_substr!($s))
19     };
20  }
21  
22  pub use crate::__string_new as new;
23  
24  impl From<&str> for SString {
25     fn from(s: &str) -> Self {
26        Self(arcstr::Substr::from(s))
27     }
28  }
29  
30  impl ops::Deref for SString {
31     type Target = str;
32  
33     fn deref(&self) -> &Self::Target {
34        &self.0
35     }
36  }