aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2018-07-13 19:39:42 +0200
committeracdenisSK <[email protected]>2018-07-13 21:21:09 +0200
commitb520ec708c375e09838b9f25fd285790b856bb97 (patch)
tree9bcc51682beb47eb5760686ff815f741b166fc46 /src
parentFix doc links with no anchor (diff)
downloadserenity-b520ec708c375e09838b9f25fd285790b856bb97.tar.xz
serenity-b520ec708c375e09838b9f25fd285790b856bb97.zip
Add docs for `Args::new`
Diffstat (limited to 'src')
-rw-r--r--src/framework/standard/args.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/framework/standard/args.rs b/src/framework/standard/args.rs
index 194fadf..d72537c 100644
--- a/src/framework/standard/args.rs
+++ b/src/framework/standard/args.rs
@@ -304,6 +304,33 @@ pub struct Args {
}
impl Args {
+ /// Create a new instance of `Args` for parsing arguments.
+ ///
+ /// For more reference, look at [`Args`]'s struct documentation.
+ ///
+ /// # Example
+ ///
+ /// ```rust
+ /// use serenity::framework::standard::Args;
+ ///
+ /// let mut args = Args::new(
+ /// // Our source from where we'll parse over.
+ /// "the quick brown fox jumps over the lazy",
+ ///
+ /// // The "delimiters", or aka the separators. They denote how we distinguish arguments as their own.
+ /// // For this instance, we'll use one delimiter. The space (`0x20`), which will separate the arguments.
+ /// &[" ".to_string()],
+ /// );
+ ///
+ /// assert_eq!(args.single::<String>().unwrap(), "the");
+ /// assert_eq!(args.single::<String>().unwrap(), "quick");
+ /// assert_eq!(args.single::<String>().unwrap(), "brown");
+ ///
+ /// // We should not see `the quick brown` again.
+ /// assert_eq!(args.rest(), "fox jumps over the lazy");
+ /// ```
+ ///
+ /// [`Args`]: #struct.Args.html
pub fn new(message: &str, possible_delimiters: &[String]) -> Self {
let delims = possible_delimiters
.iter()