Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Args internals to a lexer approach #326

Merged
merged 10 commits into from
Jun 4, 2018
Merged

Modify Args internals to a lexer approach #326

merged 10 commits into from
Jun 4, 2018

Conversation

arqunis
Copy link
Member

@arqunis arqunis commented Jun 2, 2018

This is an overhaul to the method-of-parsing things into "arguments" to an approach that's:

  1. Better Unicode complaint
  2. Easy to understand
  3. Faster (by my measurements, around ~10k nanoseconds)

Also, for convenience, this adds 2 new methods:

  • rewind - Goes one step behind
  • restore - Goes back to the start

(And tweaks docs as well)

@arqunis arqunis added the enhancement An improvement to Serenity. label Jun 2, 2018
@arqunis
Copy link
Member Author

arqunis commented Jun 2, 2018

@serenity-rs/ferris-elite-collection-of-epic-code please review

@Lakelezz Lakelezz self-requested a review June 4, 2018 18:17
@@ -261,7 +359,10 @@ impl Args {
&s[1..end]
}

/// The amount of args.
/// The full amount of recognized arguments.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we settled for British English, we should write recognised.

self.offset >= self.args.len()
}

/// Go one step behind
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot a dot after behind.

///
/// let mut args = Args::new("42 69 95", &[" ".to_string()]);
///
/// // Lets parse 'em numbers!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Let's.

///
/// // Oh, no! I actually wanted to multiply all of them by 2!
/// // I don't want to call `rewind` 3 times manually....
/// // Wait, i could just go entirely back!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to capitalise i.

@@ -316,25 +483,12 @@ impl Args {
///
/// assert_eq!(args.len_quoted(), 2); // `2` because `["42", "69"]`
/// ```
#[deprecated(since = "0.5.3", note = "its task was merged with `len`, please use it instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should depreciation-notes start capitalised?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really.
Though, i suppose i could.

@arqunis arqunis merged commit ff9edc0 into serenity-rs:master Jun 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to Serenity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants