Added convenience ext for hashing into uuid
This commit is contained in:
parent
c500dc9c42
commit
1ff7a7a23e
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -608,7 +608,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bevy_icon_creator"
|
name = "bevy_icon_creator"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bevy",
|
"bevy",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "bevy_icon_creator"
|
name = "bevy_icon_creator"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Franklin E. Blanco"]
|
authors = ["Franklin E. Blanco"]
|
||||||
description = "A plugin to automatically create Icons from entities/models in bevy"
|
description = "A plugin to automatically create Icons from entities/models in bevy"
|
||||||
|
12
src/hash_to_uuid_ext.rs
Normal file
12
src/hash_to_uuid_ext.rs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
use std::hash::{DefaultHasher, Hash, Hasher};
|
||||||
|
|
||||||
|
use bevy::utils::Uuid;
|
||||||
|
|
||||||
|
pub trait HashToUuidExt: Hash {
|
||||||
|
fn to_uuid(&self) -> Uuid {
|
||||||
|
let mut default_hasher = DefaultHasher::new();
|
||||||
|
self.hash(&mut default_hasher);
|
||||||
|
let hash = default_hasher.finish();
|
||||||
|
Uuid::from_u128(hash as u128)
|
||||||
|
}
|
||||||
|
}
|
@ -5,6 +5,7 @@ mod state;
|
|||||||
mod utils;
|
mod utils;
|
||||||
mod set_image_on_load;
|
mod set_image_on_load;
|
||||||
mod register_types;
|
mod register_types;
|
||||||
|
mod hash_to_uuid_ext;
|
||||||
|
|
||||||
pub mod image_ext;
|
pub mod image_ext;
|
||||||
pub mod plugin;
|
pub mod plugin;
|
||||||
|
Loading…
Reference in New Issue
Block a user