From be2ba23ae7735ab42b87a16ba12f21e47dd078f3 Mon Sep 17 00:00:00 2001 From: "Carson M." Date: Tue, 12 Dec 2023 21:16:06 -0600 Subject: [PATCH] refactor: remove once_cell dependency --- Cargo.toml | 3 +-- src/message.rs | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 792be88..f7a285f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ repository = "https://github.com/vitri-ent/vmc" documentation = "https://docs.rs/vmc" readme = "README.md" edition = "2021" -keywords = [ "virtual-motion-capture", "osc" ] +keywords = [ "osc" ] categories = [ "network-programming", "asynchronous" ] authors = [ "Carson M. " @@ -25,7 +25,6 @@ serde = { version = "1.0", optional = true, features = [ "derive" ] } tokio = { version = "1.30", features = [ "net" ] } tokio-stream = "0.1" thiserror = "1.0" -once_cell = "1.15" [dev-dependencies] tokio = { version = "1.30", features = [ "net", "macros", "rt-multi-thread" ] } diff --git a/src/message.rs b/src/message.rs index 2ee32da..f025fe4 100644 --- a/src/message.rs +++ b/src/message.rs @@ -1,9 +1,8 @@ //! Submodule for Virtual Motion Capture-specific messages. -use std::{str::FromStr, time::Instant}; +use std::{str::FromStr, sync::OnceLock, time::Instant}; use nalgebra::{Quaternion, Scale3, UnitQuaternion, Vector3}; -use once_cell::sync::Lazy; use crate::{osc::OSCMessage, IntoOSCMessage, OSCPacket, OSCType, VMCError, VMCResult}; @@ -724,8 +723,8 @@ impl Time { /// Creates a new time message, automatically tracking relative time using a monotonic clock. pub fn elapsed() -> Self { - static EPOCH: Lazy = Lazy::new(Instant::now); - Self(EPOCH.elapsed().as_secs_f32()) + static EPOCH: OnceLock = OnceLock::new(); + Self(EPOCH.get_or_init(Instant::now).elapsed().as_secs_f32()) } }