Skip to main content

LinkList

Struct LinkList 

Source
pub struct LinkList<T> {
    pub nodes: VecDeque<T>,
    pub flags: u32,
}
Expand description

A doubly-ended list, port of struct linklist (Src/zsh.h:563). flags carries LF_ARRAY and friends from Src/subst.c:33.

Fields§

§nodes: VecDeque<T>§flags: u32

Implementations§

Source§

impl<T> LinkList<T>

Source

pub fn new() -> Self

Port of znewlinklist() from Src/linklist.c:116 — heap-arena fresh empty list. Rust uses LinkList::new().

Source

pub fn is_empty(&self) -> bool

Port of the C macro empty(list) (Src/zsh.h:583) — firstnode(list) == NULL.

Source

pub fn len(&self) -> usize

Port of countlinknodes(LinkList list) from Src/linklist.c:304.

Source

pub fn push_front(&mut self, data: T)

Push at the head. Port of the C macro pushnode() (Src/zsh.h).

Source

pub fn push_back(&mut self, data: T)

Push at the tail. Port of addlinknode() (Src/zsh.h) / zaddlinknode() (Src/linklist.c:151).

Source

pub fn pop_front(&mut self) -> Option<T>

Pop the head. Port of getlinknode(LinkList list) (Src/linklist.c:210).

Source

pub fn pop_back(&mut self) -> Option<T>

Pop the tail. Port of remnode(list, lastnode(list)) idiom.

Source

pub fn front(&self) -> Option<&T>

Front-element ref, equivalent to firstnode(list)->dat (Src/zsh.h:576,586).

Source

pub fn front_mut(&mut self) -> Option<&mut T>

front_mut — see implementation.

Source

pub fn back(&self) -> Option<&T>

Back-element ref, equivalent to lastnode(list)->dat (Src/zsh.h:577,586).

Source

pub fn back_mut(&mut self) -> Option<&mut T>

back_mut — see implementation.

Source

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

iter — see implementation.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, T>

iter_mut — see implementation.

Source

pub fn append(&mut self, other: &mut LinkList<T>)

Append other onto the tail; drains other. Port of joinlists() (Src/linklist.c:360).

Source

pub fn clear(&mut self)

Drop every node. Port of freelinklist(list, NULL) (Src/linklist.c:287).

Source

pub fn to_vec(self) -> Vec<T>
where T: Clone,

to_vec — see implementation.

Source

pub fn firstnode(&self) -> Option<usize>

Port of firstnode(X) macro (Src/zsh.h:576) — head node handle. Rust uses usize indices since the VecDeque backing gives O(1) random access matching C’s pointer walk.

Source

pub fn lastnode(&self) -> Option<usize>

Port of lastnode(X) macro (Src/zsh.h:577).

Source

pub fn nextnode(&self, idx: usize) -> Option<usize>

Port of nextnode(X) macro (Src/zsh.h:588).

Source

pub fn prevnode(&self, idx: usize) -> Option<usize>

Port of prevnode(X) macro (Src/zsh.h:589).

Source

pub fn getdata(&self, idx: usize) -> Option<&T>

Port of getdata(X) macro (Src/zsh.h:586).

Source

pub fn setdata(&mut self, idx: usize, data: T)

Port of setdata(X,Y) macro (Src/zsh.h:587).

Source

pub fn empty(&self) -> bool

Port of empty(X) macro (Src/zsh.h:583).

Source

pub fn insertlinknode(&mut self, after_idx: usize, data: T) -> usize

Port of insertlinknode(list, after, dat) macro (Src/zsh.h:580) and the function form (Src/linklist.c:133) — insert after the supplied node index, return the index of the inserted node. WARNING: param names don’t match C — Rust=(after_idx, data) vs C=(list, node, dat)

Source

pub fn delete_node(&mut self, idx: usize) -> Option<T>

Remove + free a node. Port of remnode(LinkList list, LinkNode nd) (Src/linklist.c:251).

Source

pub fn insert_at(&mut self, idx: usize, data: T)

Port of pushlinknode(list, val) head-insert helper.

Trait Implementations§

Source§

impl<T: Clone> Clone for LinkList<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for LinkList<T>

Source§

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

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

impl<T> Default for LinkList<T>

Source§

fn default() -> Self

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

impl<T> FromIterator<T> for LinkList<T>

Source§

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

Creates a value from an iterator. Read more
Source§

impl<T> IntoIterator for LinkList<T>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<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> IntoIterator for &'a LinkList<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'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

Auto Trait Implementations§

§

impl<T> Freeze for LinkList<T>

§

impl<T> RefUnwindSafe for LinkList<T>
where T: RefUnwindSafe,

§

impl<T> Send for LinkList<T>
where T: Send,

§

impl<T> Sync for LinkList<T>
where T: Sync,

§

impl<T> Unpin for LinkList<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for LinkList<T>

§

impl<T> UnwindSafe for LinkList<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> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

Source§

fn deserialize( &self, deserializer: &mut D, ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The type for metadata in pointers and references to Self.
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more