Skip to content

Commit

Permalink
remove once_cell dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
SludgePhD committed Jun 18, 2023
1 parent fe5ea91 commit f095ec6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ keywords = ["libva", "video", "decode", "codec", "acceleration"]
[dependencies]
libloading = "0.8.0"
bitflags = "2.3.2"
once_cell = "1.13.1"
raw-window-handle = { version = "0.5.0", features = ["alloc"] }
log = "0.4.17"
bytemuck = { version = "1.12.1", features = ["derive", "min_const_generics"] }
Expand Down
12 changes: 7 additions & 5 deletions src/dlopen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use std::{
ffi::c_void,
os::raw::{c_char, c_float, c_int, c_uchar, c_uint},
sync::OnceLock,
};

use crate::{
Expand All @@ -23,8 +24,6 @@ use crate::{
Entrypoint, Profile,
};

use once_cell::sync::OnceCell;

/// `dylib! {}`
macro_rules! dylib {
(
Expand Down Expand Up @@ -64,9 +63,12 @@ macro_rules! dylib {
}
}

pub fn get() -> Result<&'static Self, libloading::Error> {
static CELL: OnceCell<$strukt> = OnceCell::new();
CELL.get_or_try_init(Self::load)
pub fn get() -> Result<&'static Self, &'static libloading::Error> {
static CELL: OnceLock<Result<$strukt, libloading::Error>> = OnceLock::new();
match CELL.get_or_init(Self::load) {
Ok(this) => Ok(this),
Err(e) => Err(e),
}
}

$(
Expand Down
6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl VAError {

pub(crate) enum Repr {
Libva(&'static str, VAError),
Libloading(libloading::Error),
Libloading(&'static libloading::Error),
Utf8Error(Utf8Error),
TryFromIntError(TryFromIntError),
Other(String),
Expand Down Expand Up @@ -117,8 +117,8 @@ impl From<Utf8Error> for Repr {
}
}

impl From<libloading::Error> for Repr {
fn from(v: libloading::Error) -> Self {
impl From<&'static libloading::Error> for Repr {
fn from(v: &'static libloading::Error) -> Self {
Self::Libloading(v)
}
}
Expand Down

0 comments on commit f095ec6

Please sign in to comment.