Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rust versions of the examples #8

Merged
merged 13 commits into from
Jul 9, 2024
Merged

Conversation

chrysn
Copy link

@chrysn chrysn commented Jun 21, 2024

The Rust examples are kept as parallel exercises, so that it is up to the user to pick their language among those languages supported.

The examples are generally kept close to the C examples (except for example where doing #7 differently). The SAUL example has a 5th task that pulls in SAUL actuators.

There is quite some duplication in the README texts, and just enough variation that we can't symlink them. I don't have any good plan for maintaining them other than awareness (at latest in PR reviewers) that updates here might also require updates there -- then again, as there is also duplication between the examples, that awareness is probably here anyway.

@MrKevinWeiss
Copy link

Nice, give me some time to go through it!

Copy link

@MrKevinWeiss MrKevinWeiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stumbled a bit on rust04-saul Task 5 but I guess the idea here is to force people to actually think. Co-pilot could figure it out so I think it is OK.

One other suggestion would be being more explicit with the types rather than making everything let... but that is a __weak__ suggestion.

Long story short everything works (on master) and I would be OK merging this in as is or if you want to adapt it slightly.


println!("Read acceleration: {accel:?}");
```

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it would be good to hsve some nice copy paste info for changing

        assert!(matches!(accel.unit(), Some(Unit::GForce)));
        assert_eq!(accel.scale(), -3);

As finding the semantics for the Unit was not so obvious for me.

@chrysn
Copy link
Author

chrysn commented Jul 3, 2024 via email

@MrKevinWeiss
Copy link

What do you mean by the copy-paste info item?

Since I didn't have my whole toolchain setup I didn't really know the different types and didn't want to search my filesystem where the cargo put the definitions of Unit... Something like in runst04-saul Task 3:

Don't forget to adapt the asserts to check the correct types!

assert!(matches!(accel.unit(), Some(Unit::GForce)));
assert_eq!(accel.scale(), -3);

@MrKevinWeiss
Copy link

No point waiting I guess :)

@MrKevinWeiss MrKevinWeiss merged commit 3ace898 into inetrg:master Jul 9, 2024
@chrysn chrysn deleted the rust branch August 16, 2024 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants