Skip to content

Commit

Permalink
update docs for VecExtns
Browse files Browse the repository at this point in the history
  • Loading branch information
vaivaswatha committed Jul 8, 2024
1 parent 82a5da4 commit a111db2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/utils/vec_exns.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
//! Extend functionality of Rust vectors.

/// This trait provides additionaly functionality for Rust vectors
pub trait VecExtns<T> {
// Insert a new element and get back its index in the container.
/// Insert a new element and get back its index in the container.
fn push_back(&mut self, t: T) -> usize;
// Insert a new element, constructed by calling `ctor`,
// and get back its index in the container. `ctor` will
// receve the index as a parameter. This is useful when the
// element inserted needs to know its index.
/// Insert a new element, constructed by calling `ctor`,
/// and get back its index in the container. `ctor` will
/// receve the index as a parameter. This is useful when the
/// element inserted needs to know its index.
fn push_back_with(&mut self, ctor: impl FnMut(usize) -> T) -> usize;
// Create and initialize a new vector.

/// Create and initialize a new vector.
fn new_init<U: FnMut(usize) -> T>(size: usize, initf: U) -> Vec<T>;
}

Expand Down

0 comments on commit a111db2

Please sign in to comment.