freamon

joined 1 year ago
MODERATOR OF
[–] freamon 4 points 9 months ago (1 children)

From the install doc:

My way around this is to use ngrok.com, which is a quick and simple way to create a temporary VPN with a domain and SSL. On the free plan your domain changes often, which will break federation every time you reconnect.

You can now get 1 free static url with ngrok's free plan. The 'free' part of it is that it needs relaunching after a certain period of time (every 2 days, maybe?) but it works well enough to develop things.

[–] freamon 4 points 9 months ago (8 children)

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.

[–] freamon 3 points 9 months ago* (last edited 9 months ago) (1 children)

I wondered the same, and tried use rand::rngs::ThreadRng but the compiler wouldn't accept it, and suggest I use the trait instead. So it looks like the compiler can be helpful in identifying these things (and maybe traits are the first thing that Rust developers look for when reading the docs for a crate).

(wrongness edited out and hopefully corrected in new comment)

[–] freamon 5 points 9 months ago (12 children)

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.

[–] freamon 6 points 9 months ago (3 children)

Strange that blahaj.zone has loads of communities related to gender and sexuality, but never seemed to have one before that was just called 'trans'.

[–] freamon 17 points 9 months ago (1 children)

Whatever you think about the season, this sort of 'Worst Thing Ever!' is blatant clickbait for groups on social media that are working themselves into a froth about nothing. The author is just scouring Reddit and YouTube, and throwing their shitty takes back at them for easy likes.

[–] freamon 4 points 9 months ago

"OK Diablo, we've got a great tagline for a movie, we just need you to write the thing, yeah?"

[–] freamon 8 points 9 months ago

In the UK, there's just been a case of two 15-year kids being convicted of a brutal murder, so it's as relevant as ever (the actors in the film are much older, but the book is about young teenagers and that terrifying phase they go through of depleted empathy)

[–] freamon 5 points 9 months ago (1 children)

Given that the US is usually regarded as more optimistic than the UK, Burgess said something like he was the rare victim of 'American Pessimism' regarding the decision of the American publishers to leave out the final chapter. Unlike the UK version, the US one also had translations for all the Nadsat slang (it's arguable whether it's better to pick it all up from context or not)

[–] freamon 3 points 9 months ago (1 children)

They have each other on their allowed list, I see, but nothing else. So maybe it's just a case of seeing whether other test instances could be added to that list.

view more: ‹ prev next ›