static
and const
In older Rust, you had to explicitly write the 'static
lifetime in any static
or const
that needed a lifetime:
# mod foo { const NAME: &'static str = "Ferris"; # } # mod bar { static NAME: &'static str = "Ferris"; # }
But 'static
is the only possible lifetime there. So Rust now assumes the 'static
lifetime, and you don't have to write it out:
# mod foo { const NAME: &str = "Ferris"; # } # mod bar { static NAME: &str = "Ferris"; # }
In some situations, this can remove a lot of boilerplate:
# mod foo { // old const NAMES: &'static [&'static str; 2] = &["Ferris", "Bors"]; # } # mod bar { // new const NAMES: &[&str; 2] = &["Ferris", "Bors"]; # }