| 1 | <h2 id="layout" class="section-header"> {# #} |
| 2 | Layout<a href="#layout" class="anchor">§</a> {# #} |
| 3 | </h2> {# #} |
| 4 | <div class="docblock"> {# #} |
| 5 | {% match type_layout_size %} |
| 6 | {% when Ok(type_layout_size) %} |
| 7 | <div class="warning"> {# #} |
| 8 | <p> {# #} |
| 9 | <strong>Note:</strong> Most layout information is <strong>completely {#+ #} |
| 10 | unstable</strong> and may even differ between compilations. {#+ #} |
| 11 | The only exception is types with certain <code>repr(...)</code> {#+ #} |
| 12 | attributes. Please see the Rust Reference's {#+ #} |
| 13 | <a href="https://doc.rust-lang.org/reference/type-layout.html">“Type Layout”</a> {#+ #} |
| 14 | chapter for details on type layout guarantees. {# #} |
| 15 | </p> {# #} |
| 16 | </div> {# #} |
| 17 | <p><strong>Size:</strong> {{+ type_layout_size|safe }}</p> {# #} |
| 18 | {% if !variants.is_empty() %} |
| 19 | <p> {# #} |
| 20 | <strong>Size for each variant:</strong> {# #} |
| 21 | </p> {# #} |
| 22 | <ul> {# #} |
| 23 | {% for (name, layout_size) in variants %} |
| 24 | <li> {# #} |
| 25 | <code>{{ name }}</code>: {#+ #} |
| 26 | {{ layout_size|safe }} |
| 27 | </li> {# #} |
| 28 | {% endfor %} |
| 29 | </ul> {# #} |
| 30 | {% endif %} |
| 31 | {# This kind of layout error can occur with valid code, e.g. if you try to |
| 32 | get the layout of a generic type such as `Vec<T>`. #} |
| 33 | {% when Err(LayoutError::Unknown(_)) %} |
| 34 | <p> {# #} |
| 35 | <strong>Note:</strong> Unable to compute type layout, {#+ #} |
| 36 | possibly due to this type having generic parameters. {#+ #} |
| 37 | Layout can only be computed for concrete, fully-instantiated types. {# #} |
| 38 | </p> {# #} |
| 39 | {# This kind of error probably can't happen with valid code, but we don't |
| 40 | want to panic and prevent the docs from building, so we just let the |
| 41 | user know that we couldn't compute the layout. #} |
| 42 | {% when Err(LayoutError::SizeOverflow(_)) %} |
| 43 | <p> {# #} |
| 44 | <strong>Note:</strong> Encountered an error during type layout; {#+ #} |
| 45 | the type was too big. {# #} |
| 46 | </p> {# #} |
| 47 | {% when Err(LayoutError::ReferencesError(_)) %} |
| 48 | <p> {# #} |
| 49 | <strong>Note:</strong> Encountered an error during type layout; {#+ #} |
| 50 | the type references errors. {# #} |
| 51 | </p> {# #} |
| 52 | {% when Err(LayoutError::NormalizationFailure(_, _)) %} |
| 53 | <p> {# #} |
| 54 | <strong>Note:</strong> Encountered an error during type layout; {#+ #} |
| 55 | the type failed to be normalized. {# #} |
| 56 | </p> {# #} |
| 57 | {% when Err(LayoutError::Cycle(_)) %} |
| 58 | <p> {# #} |
| 59 | <strong>Note:</strong> Encountered an error during type layout; {#+ #} |
| 60 | the type's layout depended on the type's layout itself. {# #} |
| 61 | </p> {# #} |
| 62 | {% endmatch %} |
| 63 | </div> {# #} |