aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2017-12-18 22:23:07 +0100
committeralex <[email protected]>2017-12-18 22:23:07 +0100
commit143fddd83f1fc93c070e36bf31906d2631c68f97 (patch)
tree7d2f0ff78cab7c72e86d044d0022b9565dc44bf4 /src/framework
parentFix ifs (diff)
downloadserenity-143fddd83f1fc93c070e36bf31906d2631c68f97.tar.xz
serenity-143fddd83f1fc93c070e36bf31906d2631c68f97.zip
Actually fix `Args`'s `parse` and add a few tests (#236)
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/standard/args.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/framework/standard/args.rs b/src/framework/standard/args.rs
index 1076507..e940f8c 100644
--- a/src/framework/standard/args.rs
+++ b/src/framework/standard/args.rs
@@ -79,15 +79,10 @@ fn parse<T: FromStr>(s: &mut String, delimiter: &str) -> Result<T, T::Err>
where T::Err: StdError {
let mut pos = s.find(delimiter).unwrap_or_else(|| s.len());
-
let res = (&s[..pos]).parse::<T>().map_err(Error::Parse);
- // First find out whether the delimiter is 2 chars or longer,
- // if so add those extras to the position.
- // Otherwise just add `1` for 1 char delimiters.
- if delimiter.len() > 1 {
+
+ if pos < s.len() {
pos += delimiter.len();
- } else if pos < s.len() {
- pos += 1;
}
s.drain(..pos);
@@ -214,7 +209,7 @@ impl Args {
pub fn full(&self) -> &str { &self.message }
/// The amount of args.
- ///
+ ///
/// # Examples
///
/// ```rust