[][src]Struct twilight_mention::parse::MentionIter

pub struct MentionIter<'a, T> { /* fields omitted */ }

Iterator of mentions within a buffer.

Unlike when parsing a mention directly via ParseMention::parse, incomplete mentions - such as when a "<" is found but not valid trailing mention syntax - will not result in errors.

The iterator returns items consisting of 3 items: the mention itself followed by the starting index and ending index of the mention's source in the buffer.

Examples

Iterate over all of the mentioned users:

use twilight_mention::ParseMention;
use twilight_model::id::UserId;

let buf = "<@123> some <@456> users <@789>!";
let mut iter = UserId::iter(buf);
assert!(matches!(iter.next(), Some((UserId(123), _, _))));
assert!(matches!(iter.next(), Some((UserId(456), _, _))));
assert!(matches!(iter.next(), Some((UserId(789), _, _))));

Implementations

impl<'a, T> MentionIter<'a, T>[src]

#[must_use]pub fn as_str(&self) -> &'a str[src]

Return an immutable reference to the underlying buffer of the iterator.

Trait Implementations

impl<'a, T: Clone> Clone for MentionIter<'a, T>[src]

impl<'a, T: Debug> Debug for MentionIter<'a, T>[src]

impl<'a, T: ParseMention + Debug> Iterator for MentionIter<'a, T>[src]

type Item = (T, usize, usize)

Found mention followed by the start and ending indexes in the source string returned by as_str.

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for MentionIter<'a, T> where
    T: RefUnwindSafe
[src]

impl<'a, T> Send for MentionIter<'a, T> where
    T: Send
[src]

impl<'a, T> Sync for MentionIter<'a, T> where
    T: Sync
[src]

impl<'a, T> Unpin for MentionIter<'a, T> where
    T: Unpin
[src]

impl<'a, T> UnwindSafe for MentionIter<'a, T> where
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.