#[repr(C)]pub struct SmallString {
pub len: u8,
pub str: [u8; 255],
}Expand description
A string of length at most 255, with a more compact on-disk encoding.
Fields§
§len: u8§str: [u8; 255]Implementations§
Source§impl SmallString
impl SmallString
pub fn new() -> Self
pub fn from_str(s: &str) -> Self
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
ⓘ
use pijul_core::small_string::*;
let mut s = SmallString::from_str("blah!");
assert_eq!(s.len(), s.as_str().len());Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
ⓘ
use pijul_core::small_string::*;
let mut s = SmallString::from_str("blah");
s.clear();
assert_eq!(s.as_str(), "");
assert!(s.is_empty());pub fn clone_from_str(&mut self, s: &str)
Sourcepub fn clear(&mut self)
pub fn clear(&mut self)
ⓘ
use pijul_core::small_string::*;
let mut s = SmallString::from_str("blah");
s.clear();
assert!(s.is_empty());pub fn push_str(&mut self, s: &str)
pub fn as_str(&self) -> &str
pub fn as_bytes(&self) -> &[u8] ⓘ
Methods from Deref<Target = SmallStr>§
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
ⓘ
use pijul_core::small_string::*;
let mut s = SmallString::from_str("");
assert!(s.as_small_str().is_empty());
s.push_str("blah");
assert!(!s.as_small_str().is_empty());Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
ⓘ
use pijul_core::small_string::*;
let mut s = SmallString::from_str("blah");
assert_eq!(s.as_small_str().len(), "blah".len())pub fn as_str(&self) -> &str
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn to_owned(&self) -> SmallString
Trait Implementations§
Source§impl AsMut<SmallStr> for SmallString
impl AsMut<SmallStr> for SmallString
Source§impl AsRef<SmallStr> for SmallString
impl AsRef<SmallStr> for SmallString
Source§impl Clone for SmallString
impl Clone for SmallString
Source§impl Debug for SmallString
impl Debug for SmallString
Source§impl Default for SmallString
impl Default for SmallString
Source§impl Deref for SmallString
impl Deref for SmallString
Source§impl DerefMut for SmallString
impl DerefMut for SmallString
Source§impl Display for SmallString
impl Display for SmallString
impl Eq for SmallString
Source§impl FromStr for SmallString
impl FromStr for SmallString
Source§impl Hash for SmallString
impl Hash for SmallString
Source§impl Ord for SmallString
impl Ord for SmallString
Source§fn cmp(&self, x: &SmallString) -> Ordering
fn cmp(&self, x: &SmallString) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for SmallString
impl PartialEq for SmallString
Source§impl PartialOrd for SmallString
impl PartialOrd for SmallString
Auto Trait Implementations§
impl Freeze for SmallString
impl RefUnwindSafe for SmallString
impl Send for SmallString
impl Sync for SmallString
impl Unpin for SmallString
impl UnsafeUnpin for SmallString
impl UnwindSafe for SmallString
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.