-
Notifications
You must be signed in to change notification settings - Fork 255
Add Cursor type #717
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
base: master
Are you sure you want to change the base?
Add Cursor type #717
Conversation
This is a no_std variant of `std::io::Cursor`. Fixes rust-embedded#631. The implementation was generated by an LLM by copying the std impl and adapting it. I (Zeeshan) reviewed the code and adjusted small bits. The tests added are further guarantee that the code is doing what it's supposed to do.
| /// The standard library implements some I/O traits on various types which | ||
| /// are commonly used as a buffer, like `Cursor<Vec<u8>>` and `Cursor<&[u8]>`. | ||
| /// | ||
| /// This is the `embedded-io` equivalent of [`std::io::Cursor`]. |
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 this should mention that this also took big parts of the implementation from std?
I'm not sure which amount of attribution is legally required by the licenses, but I think it's at least good style to disclose such copying.
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.
it's at least good style to disclose such copying.
- If it's complicated code and/or it's a specific author(s) to attribute, then I could agree but it's not really the case here.
- In any case, I don't think this should be in user-facing documentation as it doesn't affect users in any way. I'm OK with adding a non-doc comment that says so.
- Is this not true for any other parts of this crate? If it is the case, then we should mention it there too, no? 🤔
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.
It's probably more a personal preference than a rule, and I have no idea if other parts of this crate have been copied from elsewhere. (And my wording "it's at least good style to ..." is likely too strong, I should have written something like "I'd prefer to").
And I agree that it shouldn't be in the user-facing documentation. A simple comment "Parts of this file were copied from std::io::Cursor" would do.
If no one else comments on it, just take it as my personal opinion and feel free to ignore my comment.
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.
Just an opinion: A reason to comment copied code is if it turns out to have a bug the person troubleshooting can check if the original code has already been fixed.
This is a no_std variant of
std::io::Cursor.Fixes #631.
The implementation was generated by an LLM by copying the std impl and adapting it. I (Zeeshan) reviewed the code and adjusted small bits. The tests added are a further assurance that the code is doing what it's supposed to do. Of course, it needs to be still reviewed by at least another person before we can be 100% certain about it.