Replace once_cell w/ nightly LazyLock/LazyCell and stablilized OnceCell

This commit is contained in:
Asriel Camora 2023-06-04 12:41:19 -07:00
parent 951a45547c
commit 948428fb04
18 changed files with 32 additions and 32 deletions

3
Cargo.lock generated
View file

@ -200,7 +200,6 @@ dependencies = [
"gdk4-win32",
"gtk4",
"ntapi",
"once_cell",
"plugins_core",
"rmp-serde",
"rmpv",
@ -931,7 +930,6 @@ dependencies = [
"embed-manifest",
"gtk4",
"libadwaita",
"once_cell",
"plugins_core",
"plugins_epic",
"tokio",
@ -1259,7 +1257,6 @@ dependencies = [
"chrono",
"deps",
"fragile",
"once_cell",
"plugins_core",
"rand",
"reqwest",

View file

@ -1,5 +1,6 @@
[workspace]
members = ["app", "plugins/epic"]
members = ["app"]
resolver = "2"
[profile.release]
strip = "debuginfo"

View file

@ -16,7 +16,6 @@ gtk = { package = "gtk4", version = "0.6", features = ["v4_10"] }
adw = { package = "libadwaita", version = "0.4", features = ["v1_2"] }
plugins_core = { path = "../plugins/core" }
plugins_epic = { path = "../plugins/epic" }
once_cell = "*"
tokio = "*"
[build-dependencies]

View file

@ -1,4 +1,5 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
#![feature(lazy_cell)]
mod widgets;
use gtk::prelude::*;

View file

@ -8,7 +8,7 @@ use gtk::{
traits::{GtkWindowExt, WidgetExt},
IconTheme,
};
use once_cell::unsync::OnceCell;
use std::cell::OnceCell;
subclassed_gobject!(App => "L4App",
@inner AppInner,

View file

@ -1,15 +1,16 @@
use super::{models, PageGames, PagePlugins, SettingsWindow};
use adw::subclass::prelude::*;
use deps::{plugins::PluginRegistry, utils::composite_widget};
#[cfg(debug_assertions)]
use gtk::traits::WidgetExt;
use gtk::{
gio::{self, prelude::*, ApplicationCommandLine, ListStore},
glib,
prelude::StaticType,
traits::{GtkWindowExt, WidgetExt},
traits::GtkWindowExt,
CompositeTemplate,
};
use once_cell::unsync::OnceCell;
use std::cell::RefCell;
use std::cell::{OnceCell, RefCell};
composite_widget!(AppWindow => "L4AppWindow",
@inner AppWindowInner!,

View file

@ -1,6 +1,5 @@
use deps::utils::item_model;
use gtk::glib::ParamSpecString;
use once_cell::sync::Lazy;
use plugins_core::prelude::*;
use std::sync::{Arc, Weak};

View file

@ -3,7 +3,6 @@ use gtk::{
gdk::{Paintable, Texture},
glib::{ParamSpecObject, ParamSpecString},
};
use once_cell::sync::Lazy;
use plugins_core::prelude::*;
use std::sync::{Arc, Weak};

View file

@ -6,8 +6,7 @@ use gtk::{
traits::GtkWindowExt,
CompositeTemplate, StringList, TemplateChild,
};
use once_cell::unsync::OnceCell;
use std::cell::RefCell;
use std::cell::{OnceCell, RefCell};
use super::models;

1
deps/Cargo.toml vendored
View file

@ -17,7 +17,6 @@ superslice = "*"
rmp-serde = "*"
rmpv = { version = "*", features = ["with-serde"] }
serde = "*"
once_cell = "*"
winreg = { version = "*", features = ["transactions"] }
[dev-dependencies]

1
deps/lib.rs vendored
View file

@ -1,4 +1,5 @@
#![feature(int_roundings)]
#![feature(lazy_cell)]
#![allow(dead_code)]
pub mod archive;

View file

@ -1,8 +1,10 @@
use crate::utils::{register_protocol, Storage};
use gtk::gdk_pixbuf::Pixbuf;
use once_cell::sync::Lazy;
use plugins_core::prelude::*;
use std::{path::Path, sync::RwLock};
use std::{
path::Path,
sync::{LazyLock, RwLock},
};
pub struct Client {
storage: RwLock<Storage>,
@ -44,14 +46,14 @@ impl core::Identity for Client {
}
fn version(&self) -> &'static Version {
static VERSION: Lazy<Version> =
Lazy::new(|| Version::parse(env!("CARGO_PKG_VERSION")).unwrap());
static VERSION: LazyLock<Version> =
LazyLock::new(|| Version::parse(env!("CARGO_PKG_VERSION")).unwrap());
&VERSION
}
fn authors(&self) -> &'static [&'static str] {
static AUTHORS: Lazy<Vec<&str>> =
Lazy::new(|| env!("CARGO_PKG_AUTHORS").split(':').collect());
static AUTHORS: LazyLock<Vec<&str>> =
LazyLock::new(|| env!("CARGO_PKG_AUTHORS").split(':').collect());
&AUTHORS
}

View file

@ -3,11 +3,12 @@ macro_rules! item_model {
($name:tt, $inner_name:tt, $glib_name:expr, ($($arg_name:ident: $arg_type:ty),* $(,)?), |$inner:ident| {$($param_spec:ident $(::<$param_turbofish:ty>)? ($prop_name:expr) => $prop_getter:expr),* $(,)?}) => {
mod imp {
use super::$inner_name as Inner;
use once_cell::unsync::OnceCell;
use gtk::glib;
use gtk::subclass::prelude::*;
use gtk::glib::{ParamSpec, Value};
use std::ops::Deref;
use std::cell::OnceCell;
use std::sync::LazyLock;
use super::*;
#[derive(Default)]
@ -23,7 +24,7 @@ macro_rules! item_model {
impl ObjectImpl for $name {
fn properties() -> &'static [ParamSpec] {
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
static PROPERTIES: LazyLock<Vec<ParamSpec>> = LazyLock::new(|| {
vec![
$($param_spec::builder$(::<$param_turbofish>)?($prop_name).read_only().build(),)*
]

View file

@ -16,7 +16,6 @@ serde_json = "*"
chrono = { version = "*", features = ["serde"] }
tokio = "*"
fragile = "*"
once_cell = "*"
[build-dependencies]
build-scripts = { path = "../../build" }

View file

@ -1,5 +1,6 @@
#![feature(trait_alias)]
#![feature(async_fn_in_trait)]
#![feature(lazy_cell)]
#![allow(incomplete_features)]
#![allow(dead_code)]

View file

@ -11,9 +11,8 @@ use deps::utils::Dispatcher;
use fragile::Fragile;
use gtk::gdk_pixbuf::Pixbuf;
use gtk::glib;
use once_cell::sync::Lazy;
use plugins_core::prelude::*;
use std::sync::{Arc, RwLock};
use std::sync::{Arc, LazyLock, RwLock};
struct PluginGui {
image_icon: Pixbuf,
@ -42,14 +41,14 @@ impl core::Identity for Plugin {
}
fn version(&self) -> &'static Version {
static VERSION: Lazy<Version> =
Lazy::new(|| Version::parse(env!("CARGO_PKG_VERSION")).unwrap());
static VERSION: LazyLock<Version> =
LazyLock::new(|| Version::parse(env!("CARGO_PKG_VERSION")).unwrap());
&VERSION
}
fn authors(&self) -> &'static [&'static str] {
static AUTHORS: Lazy<Vec<&str>> =
Lazy::new(|| env!("CARGO_PKG_AUTHORS").split(':').collect());
static AUTHORS: LazyLock<Vec<&str>> =
LazyLock::new(|| env!("CARGO_PKG_AUTHORS").split(':').collect());
&AUTHORS
}

View file

@ -2,7 +2,6 @@ use crate::config::SavedUserCreds;
use adw::{subclass::prelude::*, AboutWindow};
use deps::utils::{composite_widget, Dispatcher};
use gtk::{glib, traits::GtkWindowExt, CompositeTemplate, TemplateChild};
use once_cell::unsync::OnceCell;
use plugins_core::prelude::{
adw::Avatar,
gtk::{
@ -14,6 +13,7 @@ use plugins_core::prelude::{
*,
};
use reqwest::Client;
use std::cell::OnceCell;
composite_widget!(Account => "EpicAccount",
@inner AccountInner!,

View file

@ -3,9 +3,11 @@ use crate::config::{Config, SavedUserCreds};
use adw::{subclass::prelude::*, AboutWindow, ExpanderRow};
use deps::utils::composite_widget;
use gtk::{glib, traits::GtkWindowExt, CompositeTemplate, TemplateChild};
use once_cell::unsync::OnceCell;
use plugins_core::prelude::*;
use std::sync::{Arc, RwLock};
use std::{
cell::OnceCell,
sync::{Arc, RwLock},
};
composite_widget!(Settings => "EpicSettings",
@inner SettingsInner!,