Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace ancient
lazy_static
crate with once_cell
or const
slices
Piggybacking on the [motivation in winit]: `lazy_static!` is a macro whereas `once_cell` achieves the same using generics. Its implementation has also been [proposed for inclusion in `std`], making it easier to switch to a standardized version if/when that happens. The author of that winit PR is making this change to many more crates, slowly turning the scales in favour of `once_cell` in most dependency trees. Furthermore `lazy_static` hasn't published any updates for 3 years. See also [the `once_cell` F.A.Q.]. In addition "constant" `Vec`tor allocations don't need to be wrapped in a `lazy_static!` macro call at all but can be replaced with true `const` slices (or `const` sized arrays, but those are slightly more tedious to construct). [motivation in winit]: rust-windowing/winit#2313 [proposed for inclusion in `std`]: rust-lang/rust#74465 [the `once_cell` F.A.Q.]: https://docs.rs/once_cell/latest/once_cell/#faq
- Loading branch information
Showing
11 changed files
with
93 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
// Not all constants are used when building without the "client" feature | ||
#![allow(dead_code)] | ||
|
||
use once_cell::sync::Lazy; | ||
|
||
use crate::protocol::{ClientSdkInfo, ClientSdkPackage}; | ||
|
||
/// The version of the library | ||
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
const VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
pub(crate) const USER_AGENT: &str = concat!("sentry.rust/", env!("CARGO_PKG_VERSION")); | ||
|
||
lazy_static::lazy_static! { | ||
pub static ref USER_AGENT: String = format!("sentry.rust/{}", VERSION); | ||
pub static ref SDK_INFO: ClientSdkInfo = ClientSdkInfo { | ||
name: "sentry.rust".into(), | ||
pub(crate) static SDK_INFO: Lazy<ClientSdkInfo> = Lazy::new(|| ClientSdkInfo { | ||
name: "sentry.rust".into(), | ||
version: VERSION.into(), | ||
packages: vec![ClientSdkPackage { | ||
name: "cargo:sentry".into(), | ||
version: VERSION.into(), | ||
packages: vec![ClientSdkPackage { | ||
name: "cargo:sentry".into(), | ||
version: VERSION.into(), | ||
}], | ||
integrations: vec![], | ||
}; | ||
} | ||
}], | ||
integrations: vec![], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters