pub struct Bounds<'tcx> {
    pub region_bounds: Vec<(Binder<'tcx, Region<'tcx>>, Span)>,
    pub trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, BoundConstness)>,
    pub projection_bounds: Vec<(PolyProjectionPredicate<'tcx>, Span)>,
    pub implicitly_sized: Option<Span>,
}
Expand description

Collects together a list of type bounds. These lists of bounds occur in many places in Rust’s syntax:

trait Foo: Bar + Baz { }
           ^^^^^^^^^ supertrait list bounding the `Self` type parameter

fn foo<T: Bar + Baz>() { }
          ^^^^^^^^^ bounding the type parameter `T`

impl dyn Bar + Baz
         ^^^^^^^^^ bounding the forgotten dynamic type

Our representation is a bit mixed here – in some cases, we include the self type (e.g., trait_bounds) but in others we do not

Fields§

§region_bounds: Vec<(Binder<'tcx, Region<'tcx>>, Span)>

A list of region bounds on the (implicit) self type. So if you had T: 'a + 'b this might would be a list ['a, 'b] (but the T is not explicitly included).

§trait_bounds: Vec<(PolyTraitRef<'tcx>, Span, BoundConstness)>

A list of trait bounds. So if you had T: Debug this would be T: Debug. Note that the self-type is explicit here.

§projection_bounds: Vec<(PolyProjectionPredicate<'tcx>, Span)>

A list of projection equality bounds. So if you had T: Iterator<Item = u32> this would include <T as Iterator>::Item => u32. Note that the self-type is explicit here.

§implicitly_sized: Option<Span>

Some if there is no ?Sized predicate. The span is the location in the source of the T declaration which can be cited as the source of the T: Sized requirement.

Implementations§

Converts a bounds list into a flat set of predicates (like where-clauses). Because some of our bounds listings (e.g., regions) don’t include the self-type, you must supply the self-type here (the param_ty parameter).

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.

Size: 88 bytes