Introduction to Rust Programming Language (2/2)

preview_player
Показать описание
The Rust programming language has been the most loved language by developers on the Stack Overflow annual developer survey for the last 7 years in a row! Come find out why!

This will be an introductory course to the Rust language, but assumes you already have the basics of programming. Not recommended for beginners to programming overall.

Рекомендации по теме
Комментарии
Автор

"?Sized" more means "not _necessarily_ Sized" than "not Sized". In that sense, I think it makes sense for it to have a question mark instead of a bang.

Speykious
Автор

15:25, won't drop the array. Since arrays implement Copy.
34:58 Prelude, not preamble.
56:27 It's not that we are crossing thread boundaries. The issue is that threads have a 'static lifetime, because the compiler doesn't know when the thread will die. This means the thread outlives the reference (unless you're referencing static data). If you're using scoped threads, then the lifetime of the thread is the lifetime of the scope. As long as the scope doesn't outlive the data, it can reference that data.
1:08:59 if you're using Tokio, you probably want tokio::sync::RwLock instead of std's.
1:25:15 afaik, that won't be unless the tasks are already spawned. see: SO 63756169. The tasks will run concurrently, but not parallel.

pedantic
Автор

3:16 Raw pointer *does* contain the length, and therefore the reference does too:

let ptr_sz = core::mem::size_of::<*const u8>();
let ptr_slice_sz = core::mem::size_of::<*const [u8]>();
println!(" pointer size {}", ptr_sz);
println!("slice pointer size {}", ptr_slice_sz);
assert_eq!(ptr_slice_sz, ptr_sz * 2);

kinositajona
Автор

It's very confusing to call `()` the "null" type. It could make them think that there actually _is_ some kind of `null` in Rust, when it's clearly not the case.
Its official name is the "unit" type, equivalent to a struct with no fields: it's just itself and nothing else, contains no information. It acts the same way as `void` from languages like C, C++, C# and Java.

Speykious
visit shbcf.ru