-
Notifications
You must be signed in to change notification settings - Fork 93
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 Clone trait #1438
base: main
Are you sure you want to change the base?
add Clone trait #1438
Conversation
Here are three observations and potential issues from the provided
These issues should be reviewed and addressed to improve code quality and maintainability. |
Pull Request Test Coverage Report for Build 4692Details
💛 - Coveralls |
2be50ba
to
89c90c3
Compare
89c90c3
to
ade1952
Compare
} | ||
|
||
///| | ||
impl Clone for Bytes with mutability() { Mutable } |
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.
We will switch to immutable @Yu-zh
Ok(x) => Ok(T::clone(x)) | ||
Err(x) => Err(E::clone(x)) | ||
} | ||
Immutable => self |
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.
You also need to check E::mutability() here. I'd suggest
match self {
Ok(x) => if T is mutable ...
Err(x) => if E is mutable ...
}
inspect!(get_mutability(oi), content="Immutable") | ||
let ris : Result[Int, String] = Ok(32) | ||
inspect!(get_mutability(ris), content="Immutable") | ||
// TODO, we need to test reference equal |
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.
we have a function physical_equal
but be aware that its behavior is backend-dependent.
what's the motivation for this API? it looks to me we are adding lots of API for a niche use case? |
|
It seems the type |
stm32 use RESET SET, ENABLE DISABLE add new enum for type safe, and more meaningful
... this might be api preference this is just compiletime constant, not depend instance, below is enough |
My fault. It was my mistake. |
cc @Guest0x0 |
Is this referring to discussing the necessity of the mutable API rather than the necessity of the Clone trait? I think the original intention of distinguishing between immutable and mutable in the design was because the Clone behavior of immutable is unreasonable, but there may be some problems with the API design. Users are already explicitly using this API when using Clone, which proves that the cost of deep replication of immutable data structures is visible and affordable for users (we do have such a need, if there is a lot of mutable data stored in an immutable data structure) Sacrificing convenience to distinguish the need for variability may not be ideal. |
cc @Lampese |
I apologize for turning off the previous pull request by mistake.