{name} is my primary name, {name} and {name} are my second names. I like them all but {name} is my favourite. Both ‹{name}› and ‹{name}› are fine
The enum
in Rust is a proper algebraic datatype, meaning that enum variants can be simple variants,
contain datafields or even other types, which allows for awesome stuff like this:
enum WebEvent
{
PageLoad,
PageUnload,
KeyPress(char),
Paste(String),
Click { x: i64, y: i64 },
}
The match
is similar to a switch in other languages but more powerful:
match event
{
WebEvent::PageLoad => println!("page loaded"),
WebEvent::PageUnload => println!("page unloaded"),
WebEvent::KeyPress(c) => println!("pressed '{c}'"),
WebEvent::Paste(string) => println!("pasted \"{string}\""),
WebEvent::Click{x, y} => println!("clicked at x={x}, y={y}"),
}
It can also take in a tuple and do proper pattern matching:
match (a, b, c)
{
(1, 'c', 3) => todo!(),
(2, 'a', 3) => todo!(),
(3, 'f', 1) => todo!(),
(5, 'b', 1) => todo!(),
(_, _, _) => todo!(),
}
Tuples also allow for multiple return values and destructuring:
fn f(x: f64) -> (f64, f64) { (x.sin(), x.cos()) }
let (x, y) = f(1.2345);
println!("x={x:.2}, y={y:.2}");
There's no null
in Rust‼ 🥳 🎊 🎉 Instead, there's the Option
type:
enum Option<T>
{
None,
Some(T),
}
Similarly, there are no exceptions, no try
, catch
and finally
, only Result
s:
enum Result<T, E>
{
Ok(T),
Err(E),
}
- Use any unicode character as variable name
- No need for multiplication operator when multiplying with numbers
- Optional function parameters
- Default function parameters
- Multiple dispatch
- Function piping
It is so weird to call programming/software engineering an interest of mine considering i'm studying to get a bacchelor to get a job in that field. Having a job in a field automatically makes that field a chore for me but i am genuinely interestd in computer science.
Currently running Arch Linux on everything with KDE because it offers the most up to date and the widest selection of software among all linux distros.
Interested in numerical analysis, data science & physics simulations.
Likes to speak & learn languages.
Fluent in: [en], [de], [hu]
Ok in: [fr]
Currently learning: [ru], [es]
Currently studying computer science.
Occasional hobbies include ❯❯❯
- 🪢 Knots
- 🖋️ Calligraphy
- 📷 Photography
- 🪢 Macramé
- 🌸 Anime 💮
- 🎮 Video games