pub struct TypeInfo {
pub ty: TypeId,
pub name: &'static str,
pub size: usize,
pub align: usize,
pub fn_drop: FnDropRaw,
pub is_send: bool,
pub is_sync: bool,
pub is_default: bool,
pub fn_default: FnDefaultRaw,
pub is_clone: bool,
pub fn_clone: FnCloneRaw,
}
Expand description
Type information such as TypeId
, name, size, and alignment.
Also, the struct contains additional information shown below.
- Type erased drop function.
- Whether the type is
Send
or not. - Whether the type is
Sync
or not. - Whether the type is
Clone
or not and type erased clone function. - Whether the type is
Default
or not and type erased default function.
It’s highly encouraged to use tinfo
macro to construct this struct to
avoid incorrect construction.
§Examples
use my_ecs::tinfo;
let x = tinfo!(i32);
assert!(x.is_send && x.is_sync && x.is_default && x.is_clone);
let x = tinfo!(std::rc::Rc<i32>);
assert!(!x.is_send && !x.is_sync && x.is_default && x.is_clone);
Fields§
§ty: TypeId
Type id.
name: &'static str
Type name.
This field may differ from rust version to version.
size: usize
Type size in bytes.
Size must be a multiple of align
including zero.
align: usize
Type alignment in bytes.
Alignment must be a power of two, at lease one.
fn_drop: FnDropRaw
Raw Drop::drop
function pointer for the item type.
is_send: bool
Whether the type is Send
or not.
is_sync: bool
Whether the type is Sync
or not.
is_default: bool
Whether the type is Default
or not.
fn_default: FnDefaultRaw
Raw Default::default
function pointer for the item type.
If the item type is not Default
, calling this function causes panic.
is_clone: bool
Whether the type is Clone
or not.
fn_clone: FnCloneRaw
Raw Clone::clone
function pointer for the item type.
If the item type is not Clone
, calling this function causes panic.
Implementations§
Source§impl TypeInfo
impl TypeInfo
Sourcepub fn new<T: 'static>(
is_send: bool,
is_sync: bool,
fn_default: Option<FnDefaultRaw>,
fn_clone: Option<FnCloneRaw>,
) -> Self
pub fn new<T: 'static>( is_send: bool, is_sync: bool, fn_default: Option<FnDefaultRaw>, fn_clone: Option<FnCloneRaw>, ) -> Self
Creates a TypeInfo
for the given type.
§Examples
use my_ecs::ds::{TypeInfo, TypeHelper};
#[derive(Clone)]
struct X;
// Creates `TypeInfo` for the `X`.
let is_send = true;
let is_sync = true;
let fn_default = None;
let fn_clone = Some(TypeHelper::<X>::FN_CLONE);
let info = TypeInfo::new::<X>(is_send, is_sync, fn_default, fn_clone);
Sourcepub fn is_type_of<T: 'static>(&self) -> bool
pub fn is_type_of<T: 'static>(&self) -> bool
Returns true if the type information is about the given type.
§Examples
use my_ecs::prelude::*;
let tinfo = tinfo!(i32);
assert!(tinfo.is_type_of::<i32>());
Trait Implementations§
impl Copy for TypeInfo
impl Eq for TypeInfo
impl StructuralPartialEq for TypeInfo
Auto Trait Implementations§
impl Freeze for TypeInfo
impl RefUnwindSafe for TypeInfo
impl Send for TypeInfo
impl Sync for TypeInfo
impl Unpin for TypeInfo
impl UnwindSafe for TypeInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more