remove stable hash and fix CI
This commit is contained in:
parent
79e7c305bf
commit
5816d571b3
@ -63,7 +63,6 @@ unicode-xid-ident = ["unicode-xid"] # allow Unicode Standard Annex #31 for ident
|
|||||||
metadata = ["serde", "serde_json", "rhai_codegen/metadata", "smartstring/serde"] # enable exporting functions metadata
|
metadata = ["serde", "serde_json", "rhai_codegen/metadata", "smartstring/serde"] # enable exporting functions metadata
|
||||||
internals = [] # expose internal data structures
|
internals = [] # expose internal data structures
|
||||||
debugging = ["internals"] # enable debugging
|
debugging = ["internals"] # enable debugging
|
||||||
static_hash = []
|
|
||||||
serde = ["dep:serde", "smartstring/serde", "smallvec/serde"] # implement serde for rhai types
|
serde = ["dep:serde", "smartstring/serde", "smallvec/serde"] # implement serde for rhai types
|
||||||
|
|
||||||
# compiling for no-std
|
# compiling for no-std
|
||||||
|
2
build.rs
2
build.rs
@ -8,7 +8,6 @@ fn main() {
|
|||||||
// Tell Cargo that if the given environment variable changes, to rerun this build script.
|
// Tell Cargo that if the given environment variable changes, to rerun this build script.
|
||||||
println!("cargo:rerun-if-changed=build.template");
|
println!("cargo:rerun-if-changed=build.template");
|
||||||
println!("cargo:rerun-if-env-changed=RHAI_AHASH_SEED");
|
println!("cargo:rerun-if-env-changed=RHAI_AHASH_SEED");
|
||||||
if !cfg!(feature = "stable_hash") {
|
|
||||||
let mut contents = String::new();
|
let mut contents = String::new();
|
||||||
|
|
||||||
File::open("build.template")
|
File::open("build.template")
|
||||||
@ -25,4 +24,3 @@ fn main() {
|
|||||||
.write_all(contents.as_bytes())
|
.write_all(contents.as_bytes())
|
||||||
.expect("cannot write to `config/hashing.rs`");
|
.expect("cannot write to `config/hashing.rs`");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -10,21 +10,19 @@
|
|||||||
//! E.g. `env RHAI_AHASH_SEED ="[236,800,954,213]"`
|
//! E.g. `env RHAI_AHASH_SEED ="[236,800,954,213]"`
|
||||||
// [236,800,954,213], haha funny yume nikki reference epic uboachan face numberworld nexus moment 100
|
// [236,800,954,213], haha funny yume nikki reference epic uboachan face numberworld nexus moment 100
|
||||||
|
|
||||||
pub use internal::get_ahash_seed;
|
|
||||||
#[cfg(feature = "static_hash")]
|
|
||||||
pub use internal::set_ahash_seed;
|
|
||||||
|
|
||||||
#[cfg(feature = "static_hash")]
|
|
||||||
mod internal {
|
|
||||||
use core::{
|
use core::{
|
||||||
cell::UnsafeCell,
|
cell::UnsafeCell,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
mem::MaybeUninit,
|
mem::MaybeUninit,
|
||||||
|
panic::{RefUnwindSafe, UnwindSafe},
|
||||||
sync::atomic::{AtomicBool, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
panic::{RefUnwindSafe, UnwindSafe}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SusLock<T> where T: 'static {
|
// Safety: lol
|
||||||
|
struct SusLock<T>
|
||||||
|
where
|
||||||
|
T: 'static,
|
||||||
|
{
|
||||||
initalized: AtomicBool,
|
initalized: AtomicBool,
|
||||||
data: UnsafeCell<MaybeUninit<T>>,
|
data: UnsafeCell<MaybeUninit<T>>,
|
||||||
_marker: PhantomData<T>,
|
_marker: PhantomData<T>,
|
||||||
@ -35,19 +33,15 @@ mod internal {
|
|||||||
SusLock {
|
SusLock {
|
||||||
initalized: AtomicBool::new(false),
|
initalized: AtomicBool::new(false),
|
||||||
data: UnsafeCell::new(MaybeUninit::uninit()),
|
data: UnsafeCell::new(MaybeUninit::uninit()),
|
||||||
_marker: PhantomData
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self) -> Option<&T> {
|
pub fn get(&self) -> Option<&T> {
|
||||||
if self.initalized.load(Ordering::SeqCst) {
|
if self.initalized.load(Ordering::SeqCst) {
|
||||||
Some(
|
Some(unsafe { (&*self.data.get()).assume_init_ref() })
|
||||||
unsafe {
|
|
||||||
(&*self.data.get()).assume_init_ref()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
return None
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,21 +103,10 @@ mod internal {
|
|||||||
///
|
///
|
||||||
/// See [`set_rhai_ahash_seed`] for more.
|
/// See [`set_rhai_ahash_seed`] for more.
|
||||||
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
||||||
const FUNNY_YUMENIKKI_REFERENCE: [u64; 4] = [236,800,954,213];
|
const FUNNY_YUMENIKKI_REFERENCE: Option<[u64; 4]> = {{ AHASH_SEED }};
|
||||||
|
|
||||||
AHASH_SEED.get_or_init(|| Some(FUNNY_YUMENIKKI_REFERENCE)).map(|x| *x).flatten()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "static_hash"))]
|
|
||||||
mod internal {
|
|
||||||
const AHASH_SEED: Option<[u64; 4]> = {{ AHASH_SEED }};
|
|
||||||
|
|
||||||
/// Gets the current Rhai Ahash Seed. If the seed is not yet defined, this will automatically set a seed.
|
|
||||||
/// The default seed is not stable and may change between versions.
|
|
||||||
///
|
|
||||||
/// See [`set_ahash_seed`] for more.
|
|
||||||
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
|
||||||
AHASH_SEED
|
AHASH_SEED
|
||||||
}
|
.get_or_init(|| FUNNY_YUMENIKKI_REFERENCE)
|
||||||
|
.map(|x| *x)
|
||||||
|
.flatten()
|
||||||
}
|
}
|
@ -10,21 +10,19 @@
|
|||||||
//! E.g. `env RHAI_AHASH_SEED ="[236,800,954,213]"`
|
//! E.g. `env RHAI_AHASH_SEED ="[236,800,954,213]"`
|
||||||
// [236,800,954,213], haha funny yume nikki reference epic uboachan face numberworld nexus moment 100
|
// [236,800,954,213], haha funny yume nikki reference epic uboachan face numberworld nexus moment 100
|
||||||
|
|
||||||
pub use internal::get_ahash_seed;
|
|
||||||
#[cfg(feature = "static_hash")]
|
|
||||||
pub use internal::set_ahash_seed;
|
|
||||||
|
|
||||||
#[cfg(feature = "static_hash")]
|
|
||||||
mod internal {
|
|
||||||
use core::{
|
use core::{
|
||||||
cell::UnsafeCell,
|
cell::UnsafeCell,
|
||||||
marker::PhantomData,
|
marker::PhantomData,
|
||||||
mem::MaybeUninit,
|
mem::MaybeUninit,
|
||||||
|
panic::{RefUnwindSafe, UnwindSafe},
|
||||||
sync::atomic::{AtomicBool, Ordering},
|
sync::atomic::{AtomicBool, Ordering},
|
||||||
panic::{RefUnwindSafe, UnwindSafe}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SusLock<T> where T: 'static {
|
// Safety: lol
|
||||||
|
struct SusLock<T>
|
||||||
|
where
|
||||||
|
T: 'static,
|
||||||
|
{
|
||||||
initalized: AtomicBool,
|
initalized: AtomicBool,
|
||||||
data: UnsafeCell<MaybeUninit<T>>,
|
data: UnsafeCell<MaybeUninit<T>>,
|
||||||
_marker: PhantomData<T>,
|
_marker: PhantomData<T>,
|
||||||
@ -35,19 +33,15 @@ mod internal {
|
|||||||
SusLock {
|
SusLock {
|
||||||
initalized: AtomicBool::new(false),
|
initalized: AtomicBool::new(false),
|
||||||
data: UnsafeCell::new(MaybeUninit::uninit()),
|
data: UnsafeCell::new(MaybeUninit::uninit()),
|
||||||
_marker: PhantomData
|
_marker: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get(&self) -> Option<&T> {
|
pub fn get(&self) -> Option<&T> {
|
||||||
if self.initalized.load(Ordering::SeqCst) {
|
if self.initalized.load(Ordering::SeqCst) {
|
||||||
Some(
|
Some(unsafe { (&*self.data.get()).assume_init_ref() })
|
||||||
unsafe {
|
|
||||||
(&*self.data.get()).assume_init_ref()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
return None
|
return None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,21 +103,10 @@ mod internal {
|
|||||||
///
|
///
|
||||||
/// See [`set_rhai_ahash_seed`] for more.
|
/// See [`set_rhai_ahash_seed`] for more.
|
||||||
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
||||||
const FUNNY_YUMENIKKI_REFERENCE: [u64; 4] = [236,800,954,213];
|
const FUNNY_YUMENIKKI_REFERENCE: Option<[u64; 4]> = None;
|
||||||
|
|
||||||
AHASH_SEED.get_or_init(|| Some(FUNNY_YUMENIKKI_REFERENCE)).map(|x| *x).flatten()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "static_hash"))]
|
|
||||||
mod internal {
|
|
||||||
const AHASH_SEED: Option<[u64; 4]> = None;
|
|
||||||
|
|
||||||
/// Gets the current Rhai Ahash Seed. If the seed is not yet defined, this will automatically set a seed.
|
|
||||||
/// The default seed is not stable and may change between versions.
|
|
||||||
///
|
|
||||||
/// See [`set_ahash_seed`] for more.
|
|
||||||
pub fn get_ahash_seed() -> Option<[u64; 4]> {
|
|
||||||
AHASH_SEED
|
AHASH_SEED
|
||||||
}
|
.get_or_init(|| FUNNY_YUMENIKKI_REFERENCE)
|
||||||
|
.map(|x| *x)
|
||||||
|
.flatten()
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user