[][src]Struct twilight_command_parser::Arguments

pub struct Arguments<'a> { /* fields omitted */ }

An iterator over command arguments.

Implementations

impl<'a> Arguments<'a>[src]

pub fn new(buf: &'a str) -> Self[src]

Returns a new iterator of arguments from a buffer.

pub fn as_str(&self) -> &str[src]

Returns a view of the underlying buffer of arguments.

This is exactly like std::str::Chars::as_str.

Examples

When the command is "!echo foo bar baz" and the command is "echo", then this returns "foo bar baz".

use twilight_command_parser::{Command, CommandParserConfig, Parser};

let mut config = CommandParserConfig::new();
config.add_prefix("!");
config.add_command("echo", false);
let parser = Parser::new(config);

if let Some(Command { arguments, .. }) = parser.parse("!echo foo bar baz") {
    assert_eq!("foo bar baz", arguments.as_str());
}

pub fn into_remainder(self) -> Option<&'a str>[src]

Returns the remainder of the buffer that hasn't been parsed.

Examples

If you have extracted two arguments already, then you can consume the rest of the arguments:

use twilight_command_parser::Arguments;

let mut args = Arguments::new("1 2 3 4 5");
assert_eq!(Some("1"), args.next());
assert_eq!(Some("2"), args.next());
assert_eq!(Some("3 4 5"), args.into_remainder());

Trait Implementations

impl<'a> Clone for Arguments<'a>[src]

impl<'a> Debug for Arguments<'a>[src]

impl<'a> From<&'a str> for Arguments<'a>[src]

impl<'a> Iterator for Arguments<'a>[src]

type Item = &'a str

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for Arguments<'a>[src]

impl<'a> Send for Arguments<'a>[src]

impl<'a> Sync for Arguments<'a>[src]

impl<'a> Unpin for Arguments<'a>[src]

impl<'a> UnwindSafe for Arguments<'a>[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, 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.