3 ms·
> &'static str I'm hoping there's a more...friendly way to write that (I'm assuming that's for literals). Edit: ~str, see: https://github.com/mozilla/rust/wik
by mattgreenrocks 13y ago
> &'static str
I'm hoping there's a more...friendly way to write that (I'm assuming that's for literals).
Edit: ~str, see: https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmers https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmer...
- pcwalton 13y agoNo, "&'static str" is the type of a string literal. It's pretty easy to parse once you're familiar with lifetimes: it means "a reference to a string that lives forever".
- steveklabnik 13y agoThe friendliest way to write it is to simply not and let the compiler infer it.
- AnimalMuppet 13y agoThat is in fact the best way... until it's not. If I understand correctly (and I may not), there are times when you have to write it.
- dbaupp 13y agoYou're correct; at the moment function signatures have to be written in full. (This may be relaxed slightly in future, that said, it's very very unlikely to be loosened to full Haskell-style whole-program inference.)
- termie 13y agoStuff like this is going to scare a lot of people away, sadly.