Struct Set

Source
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>

Source

pub fn new() -> Result<Self, AllocationError>

Creates a new, initially empty set.

Source§

impl<'a, T> Set<'a, T>

Source

pub fn is_empty(&self) -> bool

Tests whether set is empty i.e. contains no elements.

Source

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);
Source

pub fn clear(&mut self)

Clears out the contents of a set.

Source

pub fn copy_from(&mut self, other: &Self)

Makes the contents of self equal to the contents of other.

Source

pub fn contains_set(&self, other: &Self) -> bool

Tests whether self contains other set.

Source

pub fn clone_static(&self) -> Set<'static, T>

Constructs a copy of the set with 'static lifetime.

Source§

impl<'a, T> Set<'a, T>
where T: Into<u32>,

Source

pub fn contains(&self, value: T) -> bool

Tests whether a value belongs to set.

Source

pub fn insert(&mut self, value: T)

Inserts a value to set.

§Panics

Will panic if value is sys::HB_SET_VALUE_INVALID.

Source

pub fn remove(&mut self, value: T)

Removes a value from set.

Source

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);
Source

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>
where T: TryFrom<u32>,

Source

pub fn iter(&self) -> SetIter<'_, 'a, T>

Constructs an iterator over the set.

Source§

impl<'a, T> Set<'a, T>

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<'a, T> Clone for Set<'a, T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, T> Debug for Set<'a, T>
where T: TryFrom<u32> + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T> FromIterator<T> for Set<'a, T>
where T: Into<u32>,

Source§

fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'a, T> Hash for Set<'a, T>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'s, 'a, T> IntoIterator for &'s Set<'a, T>
where T: TryFrom<u32>,

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = SetIter<'s, 'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, T> PartialEq for Set<'a, T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a, T> Eq for Set<'a, T>
where T: Eq,

Auto Trait Implementations§

§

impl<'a, T> Freeze for Set<'a, T>

§

impl<'a, T> RefUnwindSafe for Set<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> !Send for Set<'a, T>

§

impl<'a, T> !Sync for Set<'a, T>

§

impl<'a, T> Unpin for Set<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for Set<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.