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

path: Refactor set_extension and contains_nul #13395

Merged
merged 2 commits into from
Apr 11, 2014

Conversation

Ryman
Copy link
Contributor

@Ryman Ryman commented Apr 8, 2014

Also some minor cleanup in Path related to this.

@alexcrichton
Copy link
Member

Could you elaborate a little more on what the use case is for requiring the Container trait? I would expect that it's just "one more trait" to implement, and it doesn't have a particularly compelling reason to require.

@Ryman
Copy link
Contributor Author

Ryman commented Apr 10, 2014

It was more that it felt implied, but I guess you're right and it could be restrictive/bothersome to require it.

Would you instead accept if I instead extend BytesContainer to have byte_len()? The default trait implementation should actually handle most needs then.

@alexcrichton
Copy link
Member

I would figure that byte_len would be the equivalent of container_as_bytes().byte_len().

I think that this trait may be seeing a bit more prime time than it was intended for, sadly, it's mostly just to make Path::new "just work" most of the time.

@Ryman
Copy link
Contributor Author

Ryman commented Apr 11, 2014

Updated commits do as mentioned above, feel free to close pr if unwanted.

@alexcrichton
Copy link
Member

Would you be ok with omitting the addition of the byte_len() method, but keeping your refactoring of the path module? It seems like you had some good refactorings in there, and it'd be a shame to lose them!

Some(ref s) => {
if contains_nul(s) { None }
else {
Some(unsafe { GenericPathUnsafe::new_unchecked(*s) })
}
Copy link
Member

Choose a reason for hiding this comment

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

Stylistically, this if/else should look like:

if contains_nul(s) {
    None
} else {
    Some(...)
}

@Ryman
Copy link
Contributor Author

Ryman commented Apr 11, 2014

Nuked byte_len() addition and fixed if style.

@alexcrichton alexcrichton changed the title libstd::path: Implement Container for BytesContainer implementers path: Refactor set_extension and contains_nul Apr 11, 2014
bors added a commit that referenced this pull request Apr 11, 2014
…xcrichton

Also some minor cleanup in Path related to this.
@bors bors closed this Apr 11, 2014
@bors bors merged commit 9b9ad9b into rust-lang:master Apr 11, 2014
flip1995 pushed a commit to flip1995/rust that referenced this pull request Oct 18, 2024
…nishearth

Add lint for unnecessary lifetime bounded &str return

Closes rust-lang#305.

Currently implemented with a pretty strong limitation that it can only see the most basic implicit return, but this should be fixable by something with more time and brain energy than me. Cavets from rust-lang#13388 apply, as I have not had a review on my clippy lints yet so am pretty new to this.

```
changelog: [`unnecessary_literal_bound`]:  Add lint for unnecessary lifetime bounded &str return.
```
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.

3 participants