-
-
Notifications
You must be signed in to change notification settings - Fork 119
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
Replace once_cell
usage with std::sync::OnceLock
#1289
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.
Looks good to me otherwise
bd37ee0
to
e4513d2
Compare
I guess, this PR should be merged first. |
@@ -160,8 +160,10 @@ unsafe extern "C" fn animation_get_size<T: PixbufAnimationImpl>( | |||
} | |||
} | |||
|
|||
static STATIC_IMAGE_QUARK: Lazy<glib::Quark> = | |||
Lazy::new(|| glib::Quark::from_str("gtk-rs-subclass-static-image")); | |||
fn static_image_quark() -> glib::Quark { |
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 am not really a fan of this change tbh, as at the end of the day we don't get rid of once_cell from our dependencies tree. I would keep such Lazy usages
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.
May you explain? This PR literally removes usage of once_cell
crate.
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.
Never mind, I got confused by the tests/examples deps pulling once_cell.
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 also don't like it much but as it's only internal it seems fine to me. We can switch to LazyLock
at a later time once it's stable.
@andy128k can you create an issue about that?
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 actually don't think you need a function here at all, the quark is used only inside a single function which can define the static itself. See gtk-rs/gtk4-rs@3b8e9b0
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.
As I mentioned above, not a fan of the GQuark change but no strong opinion. Otherwise lgtm.
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.
Looks good to me
d53b865
to
dbf7540
Compare
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.
before landing this, someone should do the same for gstreamer as they use the re-exported once_cell crate from glib iirc
But we have a |
Closes #30
Closes #1141
See also
gtk-rs/gir#1532gtk-rs/gir#1537This change does not fully remove
once_cell
. Full removal will break a contract ofglib::Properties
macro.