Rust variables: Difference between revisions

From wikinotes
No edit summary
Line 2: Line 2:
<blockquote>
<blockquote>
<syntaxhighlight lang="rust">
<syntaxhighlight lang="rust">
let test_env: bool = true;
let age: u8 = 200;   // typed
let age = 200u8;    // type-suffix
let age = 200;      // implied type
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Assignment -->
</blockquote><!-- Assignment -->

Revision as of 23:24, 29 August 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

Introspection

use std::any::type_name;