parent
b2f09c1165
commit
ce223a62f1
@ -278,7 +278,18 @@ This will print:
|
||||
|
||||
Many more bytes than graphemes!
|
||||
|
||||
# Other Documentation
|
||||
# `Deref` coercions
|
||||
|
||||
* [the `&str` API documentation](../std/str/index.html)
|
||||
* [the `String` API documentation](../std/string/index.html)
|
||||
References to `String`s will automatically coerce into `&str`s. Like this:
|
||||
|
||||
```
|
||||
fn hello(s: &str) {
|
||||
println!("Hello, {}!", s);
|
||||
}
|
||||
|
||||
let slice = "Steve";
|
||||
let string = "Steve".to_string();
|
||||
|
||||
hello(slice);
|
||||
hello(&string);
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user