You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider automatically converting Strings to string slices when a string is passed into a string slice context. Please pardon my total lack of experience with rust but I think this shouldn't introduce any bugs in the program since a string slice is a more restricted type than a String. Any thoughts?
Example:
fn takes_slice(slice: &str) {
println!("Got: {}", slice);
}
fn main() {
let s = "Hello".to_string();
takes_slice(s);
}
instead of ...
fn main() {
let s = "Hello".to_string();
takes_slice(s.as_slice());
}
May be we can provide a conversion operator like C++ does?