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

uu+tests: use strip_prefix and strip_suffix #2726

Merged
merged 1 commit into from
Nov 1, 2021

Conversation

thomasqueirozb
Copy link
Contributor

This closes #2719

I opened this as a draft because of this:

if let Some(second) = arg.chars().nth(1) {
match second {
'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7' => {
// TODO: use strip_prefix() once minimum rust version reaches 1.45.0
*arg = arg[1..arg.len()].to_string();
return true;
}

I don't really see the benefit of using strip_prefix here since the prefix is already known to be there. IMO it would just add more complexity.

Once someone responds to this I will either remove the comment or implement it using strip_prefix

@jhscheer
Copy link
Contributor

If I remember correctly, the first if was part of the work around because strip_prefix() wasn't available.
I think I had something like this in mind:

if let Some(arg_stripped) = arg.strip_prefix('-') {
    if let Some(second) = arg.chars().nth(1) {
        match second {
            'r' | 'w' | 'x' | 'X' | 's' | 't' | 'u' | 'g' | 'o' | '0'..='7' => {
                *arg = arg_stripped.to_string();
                return true; 
            }
            _ => {}
        }
    }
}

@thomasqueirozb
Copy link
Contributor Author

@jhscheer I failed to look one line above of what I mentioned...

@thomasqueirozb thomasqueirozb marked this pull request as ready for review October 24, 2021 15:23
Copy link
Contributor

@miDeb miDeb left a comment

Choose a reason for hiding this comment

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

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use strip_suffix() as we are using Rust > 1.45
3 participants