-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
Nice, give me some time to go through it! |
There was a problem hiding this 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:?}"); | ||
``` | ||
|
There was a problem hiding this comment.
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.
That (from a compiler PoV needless) type annotations are helpful is
something I've gotten from other sides as well -- so yes, will update.
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 Don't forget to adapt the asserts to check the correct types! assert!(matches!(accel.unit(), Some(Unit::GForce)));
assert_eq!(accel.scale(), -3); |
No point waiting I guess :) |
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.