freamon
aka freamon@lemmy.world, freamon@feddit.nl, and any username from lemmon.website
This account is currently parked, and I’m using https://piefed.social/u/andrew_s
The window is frosted, but if that mannequin ever comes to life, the neighbours will be treated to a suggestive silhouette.
I would argue that I’m not asking it to be a queryable thing or a datastore. I wouldn’t expect a community’s ‘Accept’ of a ‘Follow’ to contain loads of data about past activity because that’s not a logical or practical thing to encapsulate. For an Undo though, there’s already a small, fixed-length encapsulated object inside, consistent with how ActivityPub is used for other circumstances. Since it’s there anyway, I don’t see the value in it containing incorrect, made-up data, when it may as well have the correct data.
Fargo’s just finished an entertaining run. I wasn’t sure about the finale, but I’m going to watch it again now I know what they were going for (also, it had so many fade-to-blacks for what would be an ad-break that that I thought ‘is this the final scene?’ about 5 times).
True Detective’s back! Sort of: there was a clearly a show called Night Country that’s been Cloverfielded into the franchise. But Jodie Foster’s awesome (obvs) and the first episode was good, slightly spooky, fun.
I’ve got about 10 minutes left of ep 1 of Monsieur Spade - it’s handsome stuff, but required more concentration than I had last night.
Season 4 of Taskmaster New Zealand is really funny. If nothing else, someone like Bubba shows how comfortably middle-class the UK version has got.
Oh, and I’ve downloaded - but not watched yet - a show called Criminal Record (it’s got Peter Capaldi in it)
My neighbours have played some terrible music before, but this whistling-down-the-drainpipe tune is the worst yet.
I saw a fan-edit of Terminator 3: Rise of the Machines called ‘Terminator 3: The Coming Storm’.
It cuts out all the goofy stuff from the original, leaving a tight 90-minute dystopian thriller that I really enjoyed.
It’s only available in DVD-type quality, but I didn’t mind (I’ve only got a 1080p projector).
For anyone else wondering, btw, it’s because lemmy expects all ‘id’ fields to be unique, so it would error if the inner object actually was a copy of the original vote.
This is just my attempt at answering (I’m learning too):
Macros are easy to use, allowing beginners to write ‘hello world’ for example, but hide a bunch of complicated stuff we’re unlikely to understand until later. (I vaguely remember from Java that just writing something to the console was a whole bunch statements strung together.)
I found it useful to document what each line was doing in the example, to get my head around the terminology.
std
is a crate, io
is a module in the std
crate, and that module provides methods like stdin()
std
is a crate, cmp
is a module in the std
crate, and that module provides enums like Ordering
rand
is a crate, Rng
is a trait from the rand
crate, and that trait provides methods like thread_rng()
Ordering
is a enum - a type with a list of variants with developer-friendly names. In the same way that a ‘DaysOfTheWeek’ enum would have ‘Monday’, ‘Tuesday’ …, etc, Ordering
has Less, Greater, or Equal. match
statements work with enums, in a ‘for this, do that’ kind of way.
Rng
is a trait, which feature a lot in Rust, but is something I’ve had difficulty getting my head around. Where I’m at so far is they mostly provide convenience. The rand
create provides a number of structures in its rngs
module - ThreadRng
, OsRng
, SmallRng
, and StdRng
, depending on what you want to use to generate randomness. Instead of saying ThreadRng
provides the gen_range()
method, and OsRng
provides the gen_range()
method, etc, Rust just says they implement the Rng
trait. Since Rng
provides the gen_range()
method, it means that everything that implements it will provide it.
thread_rng()
returns a ThreadRng
structure, which provides gen_range()
via the Rng
trait, but we need to bring that trait into scope with the use
keyword in order to be able to call it.
For the default behaviour of passing owned vs. borrowed variables, I guess it’s useful to explicitly state “I’m giving this variable to another function, because I don’t intend to use it anymore”, so that if you inadvertently do, the compiler can catch it and error.
Sooo … is passing by value a thing in rust? Or does just about every method take only reference types as arguments?
I think this is an occasion where a vague familiarity with other languages ended up confusing me with Rust. The ‘&’ sign doesn’t mean ‘pass by reference’ in the same way as it does in C. Anything with a size that’s fixed at compile time is typically passed by value, whereas variables who’s size might change are passed by reference. The ‘&’ in Rust isn’t about that. For variables that are passed by reference, the ‘&’ is about whether the ownership of that memory address is transferred or not.
To illustrate:
fn abc(v: String) {
println!("v is {}", v);
}
fn main() {
let mut v=String::from("ab");
v.push('c');
abc(v);
// println!("v is {}", v);
}
works fine as it is, but will error if you uncomment the second println! The ‘v’ variable was passed by reference, but it’s ownership was transferred, so it can’t be referred to again.