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

String has duplicate from_str() functions #16024

Closed
alexchandel opened this issue Jul 27, 2014 · 2 comments
Closed

String has duplicate from_str() functions #16024

alexchandel opened this issue Jul 27, 2014 · 2 comments

Comments

@alexchandel
Copy link

One is in impl String in libcollections/string.rs and has the signature fn from_str(string: &str) -> String.

The other is in impl FromStr for String in libstd/from_str.rs and has the signature fn from_str(s: &str) -> Option<String>. In fact, FromStr::from_str() actually calls String::from_str().

This situation probably came about because struct String exists in libcollections, which you could conceivably have without libstd in a freestanding environment, and the FromStr trait lives in libstd.

Conceivably, FromStr could be moved to a different crate, or a dependency on libstd could be introduced to libcollections.

@bluss
Copy link
Member

bluss commented Jul 27, 2014

It isn't a duplication or conflict, String::from_str is a natural constructor function for String and the other is a result of implementing that trait. They won't be confused in practice.

@steveklabnik
Copy link
Member

@bluss is correct.

bors added a commit to rust-lang-ci/rust that referenced this issue Dec 11, 2023
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

No branches or pull requests

3 participants