Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active October 16, 2024 19:54
Show Gist options
  • Save dacr/18d78e7eca129b739dfbf4bea7a359a5 to your computer and use it in GitHub Desktop.
Save dacr/18d78e7eca129b739dfbf4bea7a359a5 to your computer and use it in GitHub Desktop.
hello rust types / published by https://github.com/dacr/code-examples-manager #b93afc98-2ee0-4db5-b281-9bc712ebb785/1b9511a2a745623d4dc96a2a72203dd93f465678
#!/usr/bin/env rust-script
// summary : hello rust types
// keywords : rust, types, @testable
// publish : gist
// authors : David Crosson
// license : Apache NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2)
// id : b93afc98-2ee0-4db5-b281-9bc712ebb785
// created-on : 2024-10-12T20:40:49+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : ./$file
fn main() {
let i: i32 = 666;
println!("The value of i is: {}", i);
let flag: bool = false;
println!("The value of flag is: {}", flag);
let c = '🚀';
println!("The value of c is: {}", c);
let f: f32 = 3.14;
println!("The value of f is: {}", f);
let pointer: &i32 = &i;
println!("The value of pointer is: {}", pointer);
let slice: &str = "rust ⚠️";
println!("The value of slice is: {}", slice);
let arr: [i32; 3] = [1, 2, 3];
//println!("The value of arr is: {}", arr); // => CAN'T COMPILE
println!("The value of arr is: {:?}", arr);
println!("arr[0] = {}", arr[0]);
println!("arr size = {}", arr.len());
let tuple: (i32, f64, char) = (42, 3.14, 'a');
println!("The value of tuple is: {:?}", tuple);
println!("tuple.0: {}", tuple.0);
println!("tuple.1: {}", tuple.1);
println!("tuple.2: {}", tuple.2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment