calyx_ir

Struct IdList

Source
pub struct IdList<T: GetName>(/* private fields */);
Expand description

A wrapper struct exposing an ordered collection of named entities within an RRC with deterministic iteration and constant-time look-up on names directly. The struct assumes that the name of an entity cannot change. Doing so will introduce incorrect results for look-ups.

Implementations§

Source§

impl<T: GetName> IdList<T>

Source

pub fn clear(&mut self)

Removes all elements from the collection

Source

pub fn is_empty(&self) -> bool

Returns true if there are no elements in the list.

Source

pub fn len(&self) -> usize

Source

pub fn retain<F>(&mut self, f: F) -> u64
where F: FnMut(&RRC<T>) -> bool,

Keep only the elements in the collection which satisfy the given predicate and return the number of elements removed.

Source

pub fn add(&mut self, item: RRC<T>)

Add a new element to the colleciton

Source

pub fn remove<S>(&mut self, name: S) -> Option<RRC<T>>
where S: Into<Id>,

Source

pub fn append(&mut self, items: impl Iterator<Item = RRC<T>>)

Add all elements to the collection

Source

pub fn iter(&self) -> impl Clone + Iterator<Item = &RRC<T>>

Returns an iterator over immutable references

Source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut RRC<T>>

Returns an iterator over mutable references. Likely a pointless method as this is a collection of RRCs.

Source

pub fn drain(&mut self) -> impl Iterator<Item = RRC<T>> + use<T>

Removes all elements from the collection and returns an iterator over the owned elements.

Source

pub fn find<S>(&self, name: S) -> Option<RRC<T>>
where S: Into<Id>,

Returns the element indicated by the name, if present, otherwise None.

Trait Implementations§

Source§

impl<T: Debug + GetName> Debug for IdList<T>

Source§

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

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

impl<T: GetName> Default for IdList<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T, F> From<F> for IdList<T>
where T: GetName, F: IntoIterator<Item = RRC<T>>,

Source§

fn from(list: F) -> Self

Converts to this type from the input type.
Source§

impl<'a, T: GetName> IntoIterator for &'a IdList<T>

Simple iter impl delegating to the Values.

Source§

type Item = &'a Rc<RefCell<T>>

The type of the elements being iterated over.
Source§

type IntoIter = Values<'a, Id, Rc<RefCell<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

Auto Trait Implementations§

§

impl<T> Freeze for IdList<T>

§

impl<T> !RefUnwindSafe for IdList<T>

§

impl<T> !Send for IdList<T>

§

impl<T> !Sync for IdList<T>

§

impl<T> Unpin for IdList<T>

§

impl<T> !UnwindSafe for IdList<T>

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.