pub struct Set<'a, T>(/* private fields */);Expand description
Set objects represent a mathematical set of integer values.
Sets are used in non-shaping APIs to query certain sets of characters or glyphs, or other integer values.
Implementations§
Source§impl<T> Set<'static, T>
impl<T> Set<'static, T>
Sourcepub fn new() -> Result<Self, AllocationError>
pub fn new() -> Result<Self, AllocationError>
Creates a new, initially empty set.
Source§impl<'a, T> Set<'a, T>
impl<'a, T> Set<'a, T>
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of elements in the set.
Note that this returns the number of elements in the underlying raw set over u32, not the number of
elements that can be represented as T. This is especially evident when the set is over chars and invalid
code points have been added with Self::insert_range.
let mut set = CharSet::new()?;
set.insert_range('\u{D7FF}'..'\u{E000}'); // Add all surrogate pairs (and \u{D7FF} for technical reasons)
assert_eq!(set.len(), 2049);Sourcepub fn copy_from(&mut self, other: &Self)
pub fn copy_from(&mut self, other: &Self)
Makes the contents of self equal to the contents of other.
Sourcepub fn contains_set(&self, other: &Self) -> bool
pub fn contains_set(&self, other: &Self) -> bool
Tests whether self contains other set.
Sourcepub fn clone_static(&self) -> Set<'static, T>
pub fn clone_static(&self) -> Set<'static, T>
Constructs a copy of the set with 'static lifetime.
Source§impl<'a, T> Set<'a, T>
impl<'a, T> Set<'a, T>
Sourcepub fn insert_range(&mut self, range: impl RangeBounds<T>)where
T: Clone + 'static,
pub fn insert_range(&mut self, range: impl RangeBounds<T>)where
T: Clone + 'static,
Inserts a range of values to set.
§Panics
Will panic if range explicitly contains sys::HB_SET_VALUE_INVALID:
U32Set::new()?.insert_range(u32::MAX-10..=u32::MAX);These still work:
U32Set::new()?.insert_range(u32::MAX-10..);
U32Set::new()?.insert_range(u32::MAX-10..u32::MAX);Sourcepub fn remove_range(&mut self, range: impl RangeBounds<T>)where
T: Clone + 'static,
pub fn remove_range(&mut self, range: impl RangeBounds<T>)where
T: Clone + 'static,
Removes a range of values from set.
Source§impl<'a, T> Set<'a, T>
impl<'a, T> Set<'a, T>
Sourcepub fn into_raw(self) -> *mut hb_set_t
pub fn into_raw(self) -> *mut hb_set_t
Converts the set into raw sys::hb_set_t pointer.
This method transfers the ownership of the set to the caller. It is up to the caller to call
sys::hb_set_destroy to free the pointer, or call Self::from_raw to convert it back into Set.
Sourcepub fn as_raw(&self) -> *mut hb_set_t
pub fn as_raw(&self) -> *mut hb_set_t
Exposes the raw inner pointer without transferring the ownership.
Unlike Self::into_raw, this method does not transfer the ownership of the pointer to the caller.
Sourcepub unsafe fn from_raw(set: *mut hb_set_t) -> Self
pub unsafe fn from_raw(set: *mut hb_set_t) -> Self
Constructs a set from raw sys::hb_set_t pointer.
§Safety
The given set pointer must either be constructed by some Harfbuzz function, or be returned from
Self::into_raw.