docs

core::reflect::field

이 페이지의 내용

API 참조는 영어로만 있습니다. 표준 라이브러리 소스의 영어 문서 주석에서 만듭니다.

Field, one field of a struct or variant.

Structs

FieldSource

pub struct Field

One field of an Inspect struct, or of one variant of an enum.

  • pub fn name(self) -> str§

    Source

    The name; "0", "1", .. in a tuple struct or variant.

  • pub fn renamed_from(self) -> str§

    Source

    The name it had before a #[renamed_from("..")], else empty.

  • pub fn type_ref(self) -> TypeRef§

    Source

    Its type.

  • pub fn offset(self) -> usize§

    Source

    Its offset in bytes from the start of the value; usize::MAX when it has no fixed place.

  • pub fn index(self) -> usize§

    Source

    Its position in declaration order.

  • pub fn is_pub(self) -> bool§

    Source

    A plain pub field.

  • pub fn has_default(self) -> bool§

    Source

    It has a = expr default.

  • pub fn attr<A>(self) -> A | none§

    Source

    The runtime attribute A on the field, if it has one: f.attr::<Range>().

  • pub fn attrs(self) -> List<Attr>§

    Source

    The runtime attributes on the field.

  • pub fn get(self, owner: any) -> any | none§

    Source

    The field's value in owner; none when owner is not of the field's type (or holds another variant).

  • pub fn get_as<T>(self, owner: any) -> T | none§

    Source

    The field's value as a T, as cast::<T>(field.get(owner)).

  • pub fn set(self, ref owner: any, value: any) -> bool§

    Source

    Sets the field in owner to value; false when owner is not of the field's type or value does not fit it (an integer fits when its value does). owner gets a changed copy: a struct is a value. A variant's payload is read-only.

Trait implementations 2