-
Notifications
You must be signed in to change notification settings - Fork 6
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
Introduce FixedPoint::into_bits #12
Conversation
@@ -194,6 +194,10 @@ impl<I, P> FixedPoint<I, P> { | |||
pub const fn as_bits(&self) -> &I { | |||
&self.inner | |||
} | |||
|
|||
pub fn into_bits(self) -> I { |
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.
- I think it can be
const fn
. - Add
#[inline]
in order to enable inlining across crates.
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 consumes self. The compiler said no.
- Sure.
@@ -4,7 +4,7 @@ use core::fmt::{Display, Formatter, Result}; | |||
use derive_more::Error; | |||
|
|||
#[cfg_attr(feature = "std", derive(Error))] | |||
#[derive(Clone, Debug, PartialEq)] | |||
#[derive(Clone, Copy, Debug, PartialEq)] |
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.
The Copy
instance prevents us from adding a non-trivial object inside (i.e stacktraces).
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.
At the moment this error doesn't contain it.
Once you decide to add, you can remove Copy (adding a new variant is also considered to be a breaking change).
Travis CI failed due to some warnings from clippy that aren't related to my changes. Could you take a look? |
Closed in favor of #14 |
We use FixedPoint for calculations, but at the end we want to convert it into u128.
Currently, we have to write:
or
I think it's much better to write:
Also, made
ArithmeticError
andFromDecimalError
Copy because they are simple and it enablesResult<T, E>: Copy
.