forked from Orchid/orchid
New plans for macros
About to move them completely to stdlib
This commit is contained in:
@@ -1,24 +1,23 @@
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::size_of;
|
||||
|
||||
use orchid_api::system::SysId;
|
||||
|
||||
use crate::api;
|
||||
use crate::system::{DynSystemCard, SystemCard};
|
||||
|
||||
pub struct SystemHandle<C: SystemCard> {
|
||||
pub(crate) _card: PhantomData<C>,
|
||||
pub(crate) id: SysId,
|
||||
pub(crate) id: api::SysId,
|
||||
}
|
||||
impl<C: SystemCard> SystemHandle<C> {
|
||||
pub(crate) fn new(id: SysId) -> Self { Self { _card: PhantomData, id } }
|
||||
pub fn id(&self) -> SysId { self.id }
|
||||
pub(crate) fn new(id: api::SysId) -> Self { Self { _card: PhantomData, id } }
|
||||
pub fn id(&self) -> api::SysId { self.id }
|
||||
}
|
||||
impl<C: SystemCard> Clone for SystemHandle<C> {
|
||||
fn clone(&self) -> Self { Self::new(self.id) }
|
||||
}
|
||||
|
||||
pub trait DynSystemHandle {
|
||||
fn id(&self) -> SysId;
|
||||
fn id(&self) -> api::SysId;
|
||||
fn get_card(&self) -> &dyn DynSystemCard;
|
||||
}
|
||||
|
||||
@@ -32,6 +31,6 @@ pub fn leak_card<T: Default>() -> &'static T {
|
||||
}
|
||||
|
||||
impl<C: SystemCard> DynSystemHandle for SystemHandle<C> {
|
||||
fn id(&self) -> SysId { self.id }
|
||||
fn id(&self) -> api::SysId { self.id }
|
||||
fn get_card(&self) -> &'static dyn DynSystemCard { leak_card::<C>() }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user