[][src]Struct syntax_ext::deriving::generic::MethodDef

pub struct MethodDef<'a> {
    pub name: &'a str,
    pub generics: LifetimeBounds<'a>,
    pub explicit_self: Option<Option<PtrTy<'a>>>,
    pub args: Vec<(Ty<'a>, &'a str)>,
    pub ret_ty: Ty<'a>,
    pub attributes: Vec<Attribute>,
    pub is_unsafe: bool,
    pub unify_fieldless_variants: bool,
    pub combine_substructure: RefCell<CombineSubstructureFunc<'a>>,
}
🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Fields

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

name of the method

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

List of generics, e.g. R: rand::Rng

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Whether there is a self argument (outer Option) i.e. whether this is a static function, and whether it is a pointer (inner Option)

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Arguments other than the self argument

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Return type

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Can we combine fieldless variants for enums into a single match arm?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Methods

impl<'a> MethodDef<'a>
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

#[derive(PartialEq)]
struct A { x: i32, y: i32 }

// equivalent to:
impl PartialEq for A {
    fn eq(&self, other: &A) -> bool {
        match *self {
            A {x: ref __self_0_0, y: ref __self_0_1} => {
                match *other {
                    A {x: ref __self_1_0, y: ref __self_1_1} => {
                        __self_0_0.eq(__self_1_0) && __self_0_1.eq(__self_1_1)
                    }
                }
            }
        }
    }
}

// or if A is repr(packed) - note fields are matched by-value
// instead of by-reference.
impl PartialEq for A {
    fn eq(&self, other: &A) -> bool {
        match *self {
            A {x: __self_0_0, y: __self_0_1} => {
                match other {
                    A {x: __self_1_0, y: __self_1_1} => {
                        __self_0_0.eq(&__self_1_0) && __self_0_1.eq(&__self_1_1)
                    }
                }
            }
        }
    }
}

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

#[derive(PartialEq)]
enum A {
    A1,
    A2(i32)
}

// is equivalent to

impl PartialEq for A {
    fn eq(&self, other: &A) -> ::bool {
        match (&*self, &*other) {
            (&A1, &A1) => true,
            (&A2(ref self_0),
             &A2(ref __arg_1_0)) => (*self_0).eq(&(*__arg_1_0)),
            _ => {
                let __self_vi = match *self { A1(..) => 0, A2(..) => 1 };
                let __arg_1_vi = match *other { A1(..) => 0, A2(..) => 1 };
                false
            }
        }
    }
}

(Of course __self_vi and __arg_1_vi are unused for PartialEq, and those subcomputations will hopefully be removed as their results are unused. The point of __self_vi and __arg_1_vi is for PartialOrd; see #15503.)

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Creates a match for a tuple of all self_args, where either all variants match, or it falls into a catch-all for when one variant does not match. There are N + 1 cases because is a case for each of the N variants where all of the variants match, and one catch-all for when one does not match. As an optimization we generate code which checks whether all variants match first which makes llvm see that C-like enums can be compiled into a simple equality check (for PartialEq). The catch-all handler is provided access the variant index values for each of the self-args, carried in precomputed variables.

let __self0_vi = unsafe {
    std::intrinsics::discriminant_value(&self) } as i32;
let __self1_vi = unsafe {
    std::intrinsics::discriminant_value(&arg1) } as i32;
let __self2_vi = unsafe {
    std::intrinsics::discriminant_value(&arg2) } as i32;

if __self0_vi == __self1_vi && __self0_vi == __self2_vi && ... {
    match (...) {
        (Variant1, Variant1, ...) => Body1
        (Variant2, Variant2, ...) => Body2,
        ...
        _ => ::core::intrinsics::unreachable()
    }
}
else {
    ... // catch-all remainder can inspect above variant index values.
}

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Auto Trait Implementations

impl<'a> !Send for MethodDef<'a>

impl<'a> !Sync for MethodDef<'a>

Blanket Implementations

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<E> SpecializationError for E
[src]

🔬 This is a nightly-only experimental API. (rustc_private)

this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via Cargo.toml instead?

Create an error for a missing method specialization. Defaults to panicking with type, trait & method names. S is the encoder/decoder state type, T is the type being encoded/decoded, and the arguments are the names of the trait and method that should've been overridden. Read more

impl<T> Erased for T
[src]

impl<T> Send for T where
    T: ?Sized
[src]

impl<T> Sync for T where
    T: ?Sized
[src]

impl<T> Erased for T