A half-hour to learn Rust Jan 27, 2020 · 51 minute read · rust maybe the site's reading time estimator is broken? sarcasm intended. But seriously, it is good to have people writing things like this.
half-hours is only the compilation time.
A half-hour to learn Rust
31–40 of 342 posts
Re: A half-hour to learn Rust
#32I've heard this many times before, but as the guide[1] says:
"You might encounter it in two situations... Both are related but subtly different and this is a common source for confusion when learning Rust."
'static means different things for references and trait objects.
ie.
'a: 'static --> reference with lifetime 'a lives forever and can never be dropped.
T: 'static --> Type T has no references in it; it is effectively 'entirely owned' by the owner of an instance of T.
These are totally different things with the same name.
(I believe technically there are actually three; `` is a type constraint and `T + 'static` is a trait bound, but that both mean the same thing as far as I know)
[1] - https://doc.rust-lang.org/rust-by-example/scope/lifetime/sta...
Re: A half-hour to learn Rust
#33That is the best article on Rust I've ever seen. Better than the Rust book. I've been saying that Rust needed a book that wasn't written by the designers of the language, who are too close to it. Now we have one.
But it only covers the very basics. Disclaimer: I've only scrolled through it, but the code snippets are all small. It does show an admirable amount of Rust's syntax, but it's not very discoverable, whereas the book is reasonably well structured (although not for novices, who have forgotten a specific term). The link also doesn't deal with larger programs: there's not an Rc on the page, let alone something like an Ar…
Re: A half-hour to learn Rust
#34Re: A half-hour to learn Rust
#35That is the best article on Rust I've ever seen. Better than the Rust book. I've been saying that Rust needed a book that wasn't written by the designers of the language, who are too close to it. Now we have one.
But it only covers the very basics. Disclaimer: I've only scrolled through it, but the code snippets are all small. It does show an admirable amount of Rust's syntax, but it's not very discoverable, whereas the book is reasonably well structured (although not for novices, who have forgotten a specific term). The link also doesn't deal with larger programs: there's not an Rc on the page, let alone something like an Ar…
No substiture for the book, though.
Re: A half-hour to learn Rust
#36> There is a special lifetime, named 'static, which is valid for the entire program's lifetime. I've heard this many times before, but as the guide[1] says: "You might encounter it in two situations... Both are related but subtly different and this is a common source for confusion when learning Rust." 'static means different things for references and trait objects. ie. 'a: 'static --> reference with lifetime 'a lives…
Lifetime: lifetime means that the first lifetime outlives (is as long or longer) the second
Type: lifetime means that the type is constrained by the lifetime. Because 'static means "the lifetime of the whole process". That means that the type is not constrained.
Re: A half-hour to learn Rust
#37> There is a special lifetime, named 'static, which is valid for the entire program's lifetime. I've heard this many times before, but as the guide[1] says: "You might encounter it in two situations... Both are related but subtly different and this is a common source for confusion when learning Rust." 'static means different things for references and trait objects. ie. 'a: 'static --> reference with lifetime 'a lives…
Another way to think about it is that “T: ‘static” restricts all references in T to be static, in the same way that “‘a: ‘static” restricts ‘a to ‘static. The case when T doesn’t contain any references is then just a boring base case.
Re: A half-hour to learn Rust
#38A half-hour to learn Rust Jan 27, 2020 · 51 minute read · rust maybe the site's reading time estimator is broken? sarcasm intended. But seriously, it is good to have people writing things like this.
Programmers don't read, they skim in half the time, then auto-complete in their mind with false assumptions!
Re: A half-hour to learn Rust
#39if(..){
Notation seriously.
Re: A half-hour to learn Rust
#40I quite like the format (though this post is much better than mine) of lots of small snippets of code showing how something is used.