pub struct UnsyncStringSet(/* private fields */);Expand description
Holds unique strings and provides StringRefs to fetch them later.
This is a newtype around SliceSet
Implementations§
Source§impl UnsyncStringSet
impl UnsyncStringSet
pub fn try_with_capacity(capacity: usize) -> Result<Self, SetError>
Sourcepub fn try_new() -> Result<Self, SetError>
pub fn try_new() -> Result<Self, SetError>
Creates a new string set, which initially holds the empty string and
other well-known strings. The well-known strings are always
available and can be fetched using the WELL_KNOWN_STRING_REFS.
Sourcepub unsafe fn insert_unique_uncontended(
&mut self,
str: &str,
) -> Result<StringRef, SetError>
pub unsafe fn insert_unique_uncontended( &mut self, str: &str, ) -> Result<StringRef, SetError>
§Safety
- The hash must be the same as if the str was re-hashed with the hasher the string set would use.
- The string must be unique within the set.
Sourcepub unsafe fn insert_unique_uncontended_with_hash(
&mut self,
hash: u64,
str: &str,
) -> Result<StringRef, SetError>
pub unsafe fn insert_unique_uncontended_with_hash( &mut self, hash: u64, str: &str, ) -> Result<StringRef, SetError>
Inserts a string into the string set without checking for duplicates, using a pre-calculated hash.
§Safety
- The caller must ensure that the hash was computed using the same hasher the string set would use.
- The string must be unique within the set.
Sourcepub fn try_insert(&mut self, str: &str) -> Result<StringRef, SetError>
pub fn try_insert(&mut self, str: &str) -> Result<StringRef, SetError>
Adds the string to the string set if it isn’t present already, and returns a handle to the string that can be used to retrieve it later.
Sourcepub unsafe fn try_insert_with_hash(
&mut self,
hash: u64,
str: &str,
) -> Result<StringRef, SetError>
pub unsafe fn try_insert_with_hash( &mut self, hash: u64, str: &str, ) -> Result<StringRef, SetError>
Adds the string to the string set if it isn’t present already, using a pre-calculated hash. Returns a handle to the string that can be used to retrieve it later.
§Safety
The caller must ensure that the hash was computed using the same hasher the string set would use.
Sourcepub fn string_ids(&self) -> impl Iterator<Item = StringRef> + '_
pub fn string_ids(&self) -> impl Iterator<Item = StringRef> + '_
Returns an iterator over all strings in the set as StringRefs.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> usize
Sourcepub unsafe fn get_string(&self, id: StringRef) -> &str
pub unsafe fn get_string(&self, id: StringRef) -> &str
§Safety
The caller must ensure that the StringId was obtained from this set
(or is a well-known id) and that the set outlives the returned &str.