-
Notifications
You must be signed in to change notification settings - Fork 71
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
Make the FloatFuncs trait a sealed public trait, add sin/sinf. #332
Conversation
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'm not a Kurbo maintainer, so I'm not certain that they would want this
@@ -5,6 +5,10 @@ | |||
|
|||
#![allow(missing_docs)] |
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.
Do we know why this is here? Does any of this new public API need docs, even just something very simple?
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 looks like this is here to avoid documenting the existing pub const GAUSS_LEGENDRE_COEFFS
* values.
I added basically a stub documentation explaining the trait, and pointing to the std implementation for further docs.
src/common.rs
Outdated
@@ -5,6 +5,10 @@ | |||
|
|||
#![allow(missing_docs)] | |||
|
|||
mod common_sealed { |
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'm not sure that common_sealed
is a great name for this - I think I'd prefer something like:
mod sealed {
/// Seals [super::FloatFunc]
pub trait FloatFuncsSealed {}
}
I don't think the Rust project documents sealed traits itself, so I think we should also probably have a link which explains it.
I don't know what link that would be, however
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.
fixed in cb3c29d
src/common.rs
Outdated
@@ -14,13 +18,16 @@ macro_rules! define_float_funcs { | |||
=> $lname:ident/$lfname:ident; | |||
)+) => { | |||
#[cfg(not(feature = "std"))] | |||
pub(crate) trait FloatFuncs : Sized { | |||
pub trait FloatFuncs : Sized + common_sealed::Sealed { |
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.
This should have some docs now that it's public
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.
Should be fixed in 85ad5eb
One thing this patch doesn't try to fix is It is perhaps worth adding that. |
src/common.rs
Outdated
@@ -6,7 +6,9 @@ | |||
#![allow(missing_docs)] | |||
|
|||
mod sealed { | |||
pub trait Sealed {} | |||
/// A sealed trait which [sealed trait](https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/) which stops this trait |
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 this reads:
A sealed trait which sealed trait which..., which doesn't seem right
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.
whoops fixed in bdfa0e7
Hey @ratmice sorry if this is a silly question, but why do we need to seal the trait? |
I just did it in the spirit of it being the more conservative change, i.e. it is easy to unseal it later, but sealing it would be a breaking change. So honestly no good reason. |
@ratmice Would you mind putting a comment on the sealing trait along these lines? Then future me knows we can remove the sealing if we need to :). Other than that LGTM. |
src/common.rs
Outdated
/// A [sealed trait](https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/) | ||
/// which stops this trait from being derived outside the library. This could be relaxed | ||
/// in the future if there is are good reasons to allow outside impls. |
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.
/// A [sealed trait](https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/) | |
/// which stops this trait from being derived outside the library. This could be relaxed | |
/// in the future if there is are good reasons to allow outside impls. | |
/// A [sealed trait](https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/) | |
/// which stops [super::FloatFuncs] from being implemented outside kurbo. This could be relaxed | |
/// in the future if there are good reasons to allow outside impls. |
I'd also probably change 'outside' to 'external' in the final line
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.
Should really be fixed now in 4a849c3
If it's alright i'll squash/force push this all down to one commit with the initial commit message. |
That would be alright, although that will also happen as part of the merge process |
This trait, with the addition of sin/sinf is needed to build peniko with the `--no-default-features --features libm` combination. The approach taken here is that rather than duplicating this common module in peniko, to make it pub, and add the sin/sinf. for peniko.
6b935f2
to
f1daabf
Compare
Co-authored-by: Daniel McNab <[email protected]>
Co-authored-by: Daniel McNab <[email protected]>
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.
LGTM, feel free to make any changes/improvements if you'd like
I'm happy with it as is, and ran the peniko patch on top of this revision through it's CI. I don't believe anything in a peniko review would require changes here, but feel like I |
This trait, with the addition of sin/sinf is needed to build peniko with the
--no-default-features --features libm
combination (added in the pr below).The approach taken here is that rather than duplicating this common module in peniko, to make it pub, and add the sin/sinf. for peniko. This trait is only conditionally defined so use of it in peniko would look something like:
This patch is in regards to fixing the testsuite failures for default features added in
linebender/peniko#23