#Mutating and borrowing, (owning)

47 messages · Page 1 of 1 (latest)

zealous temple
#

Have you read the rust book?

ancient walrus
#

well mutability and ownership are two separate parts in the language

#

to be mutable means you can change something

#

so you can do this:

let mut x = 0;
x += 1;

but not this:

let x = 0;
x += 1;
ornate mulch
#

Yes

ancient walrus
#

yes

#

oh hi alpha

ornate mulch
#

Hi sensei

ancient walrus
#

you might see code that "change" an immutable variable, like this:

let x = 0;
let x = x + 30;

and this is entirely okay in Rust, unlike some other languages

#

so?

olive shellBOT
#
30()
#
10()
ancient walrus
#

nope

#

the big difference is, the first one is creating another variable entirely with the same name

#

which means you can change its type

#
let x = 0; // this is an i32
let x = x.to_string(); // this is a String
#

you can't do this with mutable variables

let mut x = 0;
x = x.to_string(); // nope
#

i'm not sure i get what you mean?

#

ah. you're asking to do something like this?'

#

yeah

#

so that's actually a discouraged pattern in Rust

#

Rust really, really doesn't like global state

#

you can do it, but you're not really supposed to do it

#

what's the error message?

#

well, what's the error message 😛

#

i can't help you if i don't even have an idea what's wrong

#

most likely rust-analyzer is still indexing

#

and that blocks the build directory and file caches

hallow merlin
#

could also be VS Code integrated terminal not updating because it's not selected (it does that sometimes for me)

ancient walrus
#

hmmmmmmmmmmmmmm

#

could be a wayland issue, not really sure

#

looks like SDL2 is looking for the wayland API and it can't find it

#

yeah the tutorial wasn't really updated after august 2021

#

yeah again, bit outdated

#

the primary contributor, @Lokathor#2627 is in this server so perhaps you can ask them

#

well i don't think people will just tell you to do raw OGL for guis haha

#

you can ask in #gui-and-ui for recommendations, but i personally like druid the best

#

other options include egui and iced

#

yeah swing right?

#

well druid is a bit like it since it's widget based, but eh

#

you'll see the differences

#

mhm

#

you ended up with Rusty C

#

you mean to improve the code or like, work on something else?