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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)