Introduce opaque window::Id type

This commit is contained in:
Richard 2022-06-21 15:59:45 -03:00 committed by bungoboingo
parent 8fdd5ee8b6
commit ec56c0686d
6 changed files with 48 additions and 12 deletions

View file

@ -1,10 +1,12 @@
//! Build window-based GUI applications.
mod action;
mod event;
mod id;
mod mode;
mod user_attention;
pub use action::Action;
pub use event::Event;
pub use id::Id;
pub use mode::Mode;
pub use user_attention::UserAttention;

16
native/src/window/id.rs Normal file
View file

@ -0,0 +1,16 @@
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};
#[derive(Debug, PartialEq, Eq, Hash)]
/// TODO(derezzedex)
pub struct Id(u64);
impl Id {
/// TODO(derezzedex)
pub fn new(id: impl Hash) -> Id {
let mut hasher = DefaultHasher::new();
id.hash(&mut hasher);
Id(hasher.finish())
}
}