Skip to content

Commit

Permalink
Replace lazy_static dependency with sync::OnceLock.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Nov 25, 2023
1 parent ff1033b commit d710312
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "geographiclib-rs"
version = "0.2.3"
license = "MIT"
edition = "2018"
rust-version = "1.70.0"

description = "A port of geographiclib in Rust."
authors = ["Federico Dolce <[email protected]>", "Michael Kirk <[email protected]>"]
Expand All @@ -23,7 +24,6 @@ test_short = []
default = ["accurate"]

[dependencies]
lazy_static = "1.4.0"
accurate = { version = "0.3", optional = true, default-features = false }

[dev-dependencies]
Expand Down
7 changes: 3 additions & 4 deletions src/geodesic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use crate::geodesic_capability as caps;
use crate::geodesic_line;
use crate::geomath;
use std::sync;

use std::f64::consts::{FRAC_1_SQRT_2, PI};

Expand Down Expand Up @@ -42,13 +43,11 @@ pub struct Geodesic {
xthresh_: f64,
}

lazy_static! {
static ref WGS84_GEOD: Geodesic = Geodesic::new(WGS84_A, WGS84_F);
}
static WGS84_GEOD: sync::OnceLock<Geodesic> = sync::OnceLock::new();

impl Geodesic {
pub fn wgs84() -> Self {
*WGS84_GEOD
*WGS84_GEOD.get_or_init(|| Geodesic::new(WGS84_A, WGS84_F))
}

pub fn equatorial_radius(&self) -> f64 {
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,3 @@ mod geomath;
mod polygon_area;
pub use polygon_area::PolygonArea;
pub use polygon_area::Winding;

#[macro_use]
extern crate lazy_static;

0 comments on commit d710312

Please sign in to comment.