Re:A Week with Mozilla's Rust
by dbaupp on Thursday August 22, 2013 @03:47AM
(#6255731)
~str isn't inherently mutable; it's an owned string, and so is mutable if placed in a mutable variable.
The reason it's used here is so that the error messages can be constructed at runtime e.g. `fmt!("line %u: trailing characters", line_number)`, if it was using &'static str (i.e. a compile-time literal) then one could only use hard-coded error messages.
The reason it's used here is so that the error messages can be constructed at runtime e.g. `fmt!("line %u: trailing characters", line_number)`, if it was using &'static str (i.e. a compile-time literal) then one could only use hard-coded error messages.