pub struct FieldId { /* private fields */ }🔬This is a nightly-only experimental API. (
type_info)Expand description
Field representing type ID. Representing a field of a struct, tuple or enum variant.
Implementations§
Source§impl FieldId
impl FieldId
Sourcepub const fn type_id(self) -> TypeId
🔬This is a nightly-only experimental API. (type_info)
pub const fn type_id(self) -> TypeId
type_info)Returns the TypeId of the actual field type.
#![feature(type_info)]
use std::any::TypeId;
struct Point {
x: u32,
y: u32,
}
assert_eq!(
const { TypeId::of::<Point>().field(0, 0).type_id() },
TypeId::of::<u32>()
);Sourcepub const fn name(self) -> &'static str
🔬This is a nightly-only experimental API. (type_info)
pub const fn name(self) -> &'static str
type_info)Returns the name of the field.
#![feature(type_info)]
use std::any::TypeId;
struct Point {
x: u32,
y: u32,
}
assert_eq!(
const { TypeId::of::<Point>().field(0, 0).name() },
"x",
);Sourcepub const fn offset(self) -> usize
🔬This is a nightly-only experimental API. (type_info)
pub const fn offset(self) -> usize
type_info)Returns the offset of the field wrt to its containing type.
#![feature(type_info)]
use std::any::TypeId;
#[repr(C)]
struct Point {
x: u32,
y: u32,
}
assert_eq!(
const { TypeId::of::<Point>().field(0, 1).offset() },
4,
);Trait Implementations§
impl Copy for FieldId
impl Eq for FieldId
Source§impl Ord for FieldId
impl Ord for FieldId
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for FieldId
impl PartialOrd for FieldId
impl StructuralPartialEq for FieldId
Auto Trait Implementations§
impl Freeze for FieldId
impl RefUnwindSafe for FieldId
impl Send for FieldId
impl Sync for FieldId
impl Unpin for FieldId
impl UnsafeUnpin for FieldId
impl UnwindSafe for FieldId
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
Mutably borrows from an owned value. Read more