Coding in Rust until it's missing a basic feature...

preview_player
Показать описание
Rust is the language of the future ... unless the future involves basic arithmetic
Рекомендации по теме
Комментарии
Автор

I've tried to learn rust, every time i try i just absolutely lose my mind
Return to C like an omegachad

dexahtheman
Автор

Make into float becuse int × float
Sometimes returns int or float
And that something that rust trying to stop

hapashreguiem
Автор

Nahh bro, Rust compiler protects you from segfaults, memory leaks and the billion dollar mistake.

prevv
Автор

Don't know if this video is meant to be ironic or not. The int is implicitly cast to a float in C. In Rust you have to explicitly cast. Being explicit is usually seen as a virtue by programmers.
Where can I find pattern matching, traits, iterators, explicit lifetime management, an integrated package manager and build tool etc. in C? Oh right, I can't. Talk about missing basic features...

jesperpersson
Автор

y... yes... you can only do math on floats with floats... it's not that big of a deal

VixieTSQ
Автор

I like rust but oh god is multi threading a headache with the Mutexes everywhere

imfastboi
Автор

Use 2.0 the f32 instead. Don't be misleading. Implicit conversion bad.

whong
Автор

i have plans for world domination, how do I find you?

williamy
Автор

it can't implicitly statically turn an int into a float at compiletime? even when it's completely safe?

SamualN
Автор

I switched to from C++ to Rust about a year ago, and I really like it. Yes, it has some weird nuances but they are all very minor.
When comparing two languages it is important to look at their pros, cons and tradeoffs.
For example, in Rust you are forced to explicitly convert ints to floats when doing multiplications, however rust lets you use struct syntax on primitives:
let c = a.max(b).clamp(0.0, 1.0); // a and b are f64 for example
In my opinion the above syntax is very clean and it is something that C++ doesn't support.

Rust has many great features such as zero cost abstractions, comprehensive macro system, type inference and type matching. Dismissing it just because there is a singular design choice you disagree with is a bit short sighted.

You clearly made this video because you are a programmer and you had (at least a passing) interest in Rust, so let me leave you with something I guarantee you think you will really like: Rust's enums.
enum Temperature {
Celsius(f64),
Fahrenheit(f64),
Kelvin(f64),
}



impl Temperature {
pub fn celsius(c: f64) -> Self { Self::Celsius(c) }
pub fn fahrenheit(f: f64) -> Self { Self::Fahrenheit(f) }
pub fn kelvin(k: f64) -> Self { Self::Kelvin(k) }

pub fn c(&self) -> f64 {
match *self {
Self::Celsius(c) => c,
Self::Fahrenheit(f) => (f - 32.0) / 1.8,
Self::Kelvin(k) => k - 273.15
}
}

// I think you get the idea :)
}



fn main() {
let room =
println!("room temperature in F: {}", room.c());
}

varonroy
Автор

literally add a dot after the number you cnile

ion_propulsion
Автор

I can't stand rust evangelism. Meanwhile my employer: we take our C# codebase and rewrite it in C

felenov
welcome to shbcf.ru