Struct cargo_gazelle::List
source · pub struct List<T> {
pub(crate) items: Vec<T>,
pub(crate) objects: Vec<Rc<dyn ToBazelDefinition>>,
}
Expand description
Helper for formatting a list of items.
use cargo_gazelle::{List, QuotedString, ToBazelDefinition};
let deps: List<QuotedString> = List::new(vec![QuotedString::new("tokio")]);
assert_eq!(deps.to_bazel_definition(), "[\"tokio\"]");
Fields§
§items: Vec<T>
§objects: Vec<Rc<dyn ToBazelDefinition>>
Implementations§
source§impl<T> List<T>
impl<T> List<T>
pub fn new<E: Into<T>, I: IntoIterator<Item = E>>(items: I) -> Self
pub fn empty() -> Self
sourcepub fn concat_other(self, other: impl ToBazelDefinition + 'static) -> Self
pub fn concat_other(self, other: impl ToBazelDefinition + 'static) -> Self
Concatenate another Bazel object to this list.
Concretely this will result in a generated Bazel list like [ ... ] + <concat>
.
TODO(parkmcar): This feels a bit off, maybe the API should be something like
LinkedList
?
sourcepub fn push_front<E: Into<T>>(&mut self, val: E)
pub fn push_front<E: Into<T>>(&mut self, val: E)
Push a value of T
to the front of the list.
sourcepub fn extend<E: Into<T>, I: IntoIterator<Item = E>>(&mut self, vals: I)
pub fn extend<E: Into<T>, I: IntoIterator<Item = E>>(&mut self, vals: I)
Extend self
with the values from vals
.
Trait Implementations§
source§impl<A> FromIterator<A> for List<A>
impl<A> FromIterator<A> for List<A>
source§fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self
Creates a value from an iterator. Read more
Auto Trait Implementations§
impl<T> Freeze for List<T>
impl<T> !RefUnwindSafe for List<T>
impl<T> !Send for List<T>
impl<T> !Sync for List<T>
impl<T> Unpin for List<T>where
T: Unpin,
impl<T> !UnwindSafe for List<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)