Struct mit_commit::Trailers
source · [−]pub struct Trailers<'a> { /* private fields */ }
Expand description
A Collection of Trailer
Implementations
sourceimpl<'a> Trailers<'a>
impl<'a> Trailers<'a>
sourcepub fn iter(&self) -> Iter<'_, Trailer<'_>>
pub fn iter(&self) -> Iter<'_, Trailer<'_>>
Iterate over the Trailers
Examples
use mit_commit::{Trailer, Trailers};
let trailers = Trailers::from(vec![
Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into(),
),
Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into(),
),
Trailer::new("Relates-to".into(), "#124".into()),
]);
let mut iterator = trailers.iter();
assert_eq!(
iterator.next(),
Some(&Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into()
))
);
assert_eq!(
iterator.next(),
Some(&Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into()
))
);
assert_eq!(
iterator.next(),
Some(&Trailer::new("Relates-to".into(), "#124".into()))
);
assert_eq!(iterator.next(), None);
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many Trailers
are there
Examples
use mit_commit::{Trailer, Trailers};
let trailers = Trailers::from(vec![
Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into(),
),
Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into(),
),
]);
assert_eq!(trailers.len(), 2)
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Are there no Trailers
Examples
use mit_commit::{Trailer, Trailers};
assert_eq!(
Trailers::from(vec![
Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into()
),
Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into()
),
])
.is_empty(),
false
);
let trailers: Vec<Trailer> = Vec::new();
assert_eq!(Trailers::from(trailers).is_empty(), true)
Trait Implementations
sourceimpl<'a> IntoIterator for Trailers<'a>
impl<'a> IntoIterator for Trailers<'a>
sourcefn into_iter(self) -> Self::IntoIter
fn into_iter(self) -> Self::IntoIter
Iterate over the Trailers
Examples
use mit_commit::{Trailer, Trailers};
let trailers = Trailers::from(vec![
Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into(),
),
Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into(),
),
Trailer::new("Relates-to".into(), "#124".into()),
]);
let mut iterator = trailers.into_iter();
assert_eq!(
iterator.next(),
Some(Trailer::new(
"Co-authored-by".into(),
"Billie Thompson <billie@example.com>".into()
))
);
assert_eq!(
iterator.next(),
Some(Trailer::new(
"Co-authored-by".into(),
"Someone Else <someone@example.com>".into()
))
);
assert_eq!(
iterator.next(),
Some(Trailer::new("Relates-to".into(), "#124".into()))
);
assert_eq!(iterator.next(), None);
impl<'a> StructuralPartialEq for Trailers<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for Trailers<'a>
impl<'a> Send for Trailers<'a>
impl<'a> Sync for Trailers<'a>
impl<'a> Unpin for Trailers<'a>
impl<'a> UnwindSafe for Trailers<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more