jr priprava 5
This commit is contained in:
@@ -1,19 +1,10 @@
|
||||
use chrono::prelude::*;
|
||||
|
||||
|
||||
fn main() {
|
||||
// 1. How to create it
|
||||
let letter: char = 'a'; // Use SINGLE quotes for char
|
||||
let emoji: char = '🦀'; // Even emojis are exactly ONE char
|
||||
|
||||
// 2. Why it's useful
|
||||
// You can ask it questions:
|
||||
println!("{}", letter.is_alphabetic()); // Prints: true
|
||||
println!("{}", letter.is_numeric()); // Prints: false
|
||||
|
||||
// 3. Converting to a number (The "Address" of the letter)
|
||||
// Every letter has a unique number in the world (Unicode).
|
||||
let number = 'a' as u32;
|
||||
println!("{}", number); // Prints: 65
|
||||
|
||||
// 4. Converting a number back to a letter
|
||||
let back_to_char = std::char::from_u32(97);
|
||||
println!("{:?}", back_to_char); // Prints: Some('A')
|
||||
let utc: DateTime<Utc> = Utc::now();
|
||||
let local: DateTime<Local> = Local::now();
|
||||
|
||||
println!("{utc}");
|
||||
println!("{local}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user