Rust variables: Difference between revisions
From wikinotes
No edit summary |
|||
Line 15: | Line 15: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
</blockquote><!-- Literals --> | </blockquote><!-- Literals --> | ||
= Constants = | |||
<blockquote> | |||
Constants can be declared in any scope (including global). | |||
<syntaxhighlight lang="rust"> | |||
const SALT: &str = "$6$r1ohStL5/UwpNnls"; | |||
static RETRIES: i8 = 5; | |||
</syntaxhighlight> | |||
</blockquote><!-- Constants --> | |||
= Introspection = | = Introspection = |
Revision as of 23:58, 6 September 2021
Assignment
let age: u8 = 200; // typed let age = 200u8; // type-suffix let age = 200; // implied type
Literals
let float = 3.14; // f64 let integer = 7; // i32
Constants
Constants can be declared in any scope (including global).
const SALT: &str = "$6$r1ohStL5/UwpNnls"; static RETRIES: i8 = 5;
Introspection
// use std::any::type_name; (todo - learn)