livellosegreto.it is one of the many independent Mastodon servers you can use to participate in the fediverse.
Livello Segreto è il social etico che ha rispetto di te e del tuo tempo.

Administered by:

Server stats:

1.2K
active users

#rustlings

0 posts0 participants0 posts today

Started #Rustlings, a #RustLang tutorial thing (on a recommendation here). The first several exercises made me concerned that it might be stuff I’ve already learned. I checked ahead in the repo and it looks like the later stuff is appropriate for me. Tried not to spoil anything.

Returned to my learning #rust journey. This time using the Zed editor on #fedora #silverblue

Obviously, Rust is installed and updated through a flatpak Sdk extension so it's just a case of making that available to Zed (which is already done for GNOME Builder).

The Zed terminal panel is used to install rustlings using Cargo and then initialise the empty rustlings directory Zed was started in (cd .. ; rustlings init).

Then execute rustlings run with The Rust Book in a browser.

Continued thread

Ok here's a first question I encountered while working on the #rustlings :

When defining a function, what does it mean to put the `mut` keyword in front of the argument's *name* vs. in front the the argument's *type*? E.g. what's the difference between the following two lines:

```
fn some_function(mut some_arg: SomeType) {
fn some_function(some_arg: mut SomeType) {
```

I think maybe I need to put #rustlings aside for a bit and read up a bit more.

I'm hitting the point where I am perma-stumped on some of the exercises.

Like, I really don't understand map_err or why I would want it. The examples aren't making much sense yet.

Not giving up, just changing tactics :)

My latest sticking point:

github.com/rust-lang/rustlings

GitHubrustlings/exercises/13_error_handling/errors6.rs at main · rust-lang/rustlings:crab: Small exercises to get you used to reading and writing Rust code! - rust-lang/rustlings

Hey, if any of y'all are interested in learning #C, I made a project in the spirit of #rustlings and #ziglings: Ceilings! It's still a WIP, but if you know #cprogramming, and there are any improvements to be made, pls open an issue (or better yet, fork)! I'm making the exercises as I learn C myself, following along with my old copy of K&R and a PDF of C Programming: A Modern Approach 😇

github.com/Pinjontall94/ceilin

GitHubGitHub - Pinjontall94/ceilings: Ceilings - Rustlings and Ziglings for C!Ceilings - Rustlings and Ziglings for C! Contribute to Pinjontall94/ceilings development by creating an account on GitHub.

Help me Fediverse #rust Wan Kinobe, you're my only hope! :)

I'm working on a #rustlings exercise:
github.com/rust-lang/rustlings

This is the first time I'm irretrievably stuck.

My code:

gist.github.com/feoh/524771797

This is the error I get:

error[E0308]: mismatched types
--> exercises/hashmaps/hashmaps3.rs:42:27
|
42 | let team1: Team = scores.entry(team_1_name).or_insert(Team {
| _________________----^
| | |
| | expected due to this
43 | | goals_scored: team_1_score,
44 | | goals_conceded: team_2_score,
45 | | });
| |__________^ expected Team, found &mut Team

error[E0308]: mismatched types
--> exercises/hashmaps/hashmaps3.rs:46:27
|
46 | let team2: Team = scores.entry(team_2_name).or_insert(Team {
| _________________----^
| | |
| | expected due to this
47 | | goals_scored: team_2_score,
48 | | goals_conceded: team_1_score,
49 | | });
| |__________^ expected Team, found &mut Team

error: aborting due to 2 previous errors

Do I somehow want to copy my modified team1 / team2 Team structs into immutable versions so the insert will work?

This is for an exercise, so "Do your damn homework and figure it out bright boy" is entirely acceptable as well, but I've not been this stuck in the hundreds of exercises I've done thus far :)

Thanks!

GitHubrustlings/exercises/11_hashmaps/hashmaps3.rs at main · rust-lang/rustlings:crab: Small exercises to get you used to reading and writing Rust code! - rust-lang/rustlings

I've finally made it, started learning Rust, read most of the book and finished rustlings.

Now looking around for interesting projects to quickly ramp up my skill ;-)

I had few approaches to Rust but never enough space to master it. But now it looks that a lot of work in a space i'm good at (data processing and databases) is written in Rust. E.g. #ParadeDB or #NeonDB they're both written in it.

Do you want to have a single key input prompt in the terminal? 🤔

Normally, stdin is line buffered. This means that your program won't receive the input before pressing ENTER 🫤

To deactivate line buffering on any system except Windows, you can use the termios API in rustix 🦀

More about termios:
man7.org/linux/man-pages/man3/

More about rustix:
docs.rs/rustix

The next version of #Rustlings will use this to improve its prompt ✨

A probably silly thing I'm struggling with a bit working through #rustlings

You install the crate, run rustlings init. Now you have a directory with exercises you can code and fix the tests through which you can attain Rust enlightenment :)

The folder it gives you has a .git in it, which means I can't do my usual trick for cross machine sharing of checking in to a private Github repo.

Trying to copy the whole directory over to my NAS doesn't preserve the state correctly somehow - SMB shenanigans with the Synology filesystem perhaps? Not sure.

I work on 2-3 machines all the time, and would love to have my rustlings exercises wherever I am.

As I'm typing this, I realize I could just create a VM on one of my Proxmox servers for this, but that feels a bit heavyweight.

I'll keep prodding at it :)