Sophie

Sophie

distrib > Mageia > 6 > x86_64 > media > core-updates > by-pkgid > fdedb3cf2140df9b6d419a2338ab1caa > files > 6416

rust-doc-1.25.0-1.mga6.x86_64.rpm

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>repr_transparent - </title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="theme-color" content="#ffffff" />

        <base href="../">

        <link rel="stylesheet" href="book.css">
        <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
        <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">

        <link rel="shortcut icon" href="favicon.png">

        <!-- Font Awesome -->
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">

        <link rel="stylesheet" href="highlight.css">
        <link rel="stylesheet" href="tomorrow-night.css">
        <link rel="stylesheet" href="ayu-highlight.css">

        <!-- Custom theme -->
        

        

        <!-- Fetch Clipboard.js from CDN but have a local fallback -->
        <script src="https://cdn.jsdelivr.net/clipboard.js/1.6.1/clipboard.min.js"></script>
        <script>
            if (typeof Clipboard == 'undefined') {
                document.write(unescape("%3Cscript src='clipboard.min.js'%3E%3C/script%3E"));
            }
        </script>

    </head>
    <body class="light">
        <!-- Work around some values being stored in localStorage wrapped in quotes -->
        <script type="text/javascript">
            try {
                var theme = localStorage.getItem('mdbook-theme');
                var sidebar = localStorage.getItem('mdbook-sidebar');

                if (theme.startsWith('"') && theme.endsWith('"')) {
                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
                }

                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
                }
            } catch (e) { }
        </script>

        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme;
            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { } 
            if (theme === null || theme === undefined) { theme = 'light'; }
            document.body.className = theme;
            document.querySelector('html').className = theme;
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var sidebar = 'hidden';
            if (document.body.clientWidth >= 1080) {
                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
                sidebar = sidebar || 'visible';
            }
            document.querySelector('html').classList.add("sidebar-" + sidebar);
        </script>

        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
            <ol class="chapter"><li class="affix"><a href="the-unstable-book.html">The Unstable Book</a></li><li><a href="compiler-flags.html"><strong aria-hidden="true">1.</strong> Compiler flags</a></li><li><ol class="section"><li><a href="compiler-flags/linker-flavor.html"><strong aria-hidden="true">1.1.</strong> linker_flavor</a></li><li><a href="compiler-flags/profile.html"><strong aria-hidden="true">1.2.</strong> profile</a></li><li><a href="compiler-flags/remap-path-prefix.html"><strong aria-hidden="true">1.3.</strong> remap_path_prefix</a></li></ol></li><li><a href="language-features.html"><strong aria-hidden="true">2.</strong> Language features</a></li><li><ol class="section"><li><a href="language-features/abi-msp430-interrupt.html"><strong aria-hidden="true">2.1.</strong> abi_msp430_interrupt</a></li><li><a href="language-features/abi-ptx.html"><strong aria-hidden="true">2.2.</strong> abi_ptx</a></li><li><a href="language-features/abi-thiscall.html"><strong aria-hidden="true">2.3.</strong> abi_thiscall</a></li><li><a href="language-features/abi-unadjusted.html"><strong aria-hidden="true">2.4.</strong> abi_unadjusted</a></li><li><a href="language-features/abi-vectorcall.html"><strong aria-hidden="true">2.5.</strong> abi_vectorcall</a></li><li><a href="language-features/abi-x86-interrupt.html"><strong aria-hidden="true">2.6.</strong> abi_x86_interrupt</a></li><li><a href="language-features/advanced-slice-patterns.html"><strong aria-hidden="true">2.7.</strong> advanced_slice_patterns</a></li><li><a href="language-features/allocator-internals.html"><strong aria-hidden="true">2.8.</strong> allocator_internals</a></li><li><a href="language-features/allow-fail.html"><strong aria-hidden="true">2.9.</strong> allow_fail</a></li><li><a href="language-features/allow-internal-unsafe.html"><strong aria-hidden="true">2.10.</strong> allow_internal_unsafe</a></li><li><a href="language-features/allow-internal-unstable.html"><strong aria-hidden="true">2.11.</strong> allow_internal_unstable</a></li><li><a href="language-features/arbitrary-self-types.html"><strong aria-hidden="true">2.12.</strong> arbitrary_self_types</a></li><li><a href="language-features/asm.html"><strong aria-hidden="true">2.13.</strong> asm</a></li><li><a href="language-features/associated-type-defaults.html"><strong aria-hidden="true">2.14.</strong> associated_type_defaults</a></li><li><a href="language-features/attr-literals.html"><strong aria-hidden="true">2.15.</strong> attr_literals</a></li><li><a href="language-features/box-patterns.html"><strong aria-hidden="true">2.16.</strong> box_patterns</a></li><li><a href="language-features/box-syntax.html"><strong aria-hidden="true">2.17.</strong> box_syntax</a></li><li><a href="language-features/catch-expr.html"><strong aria-hidden="true">2.18.</strong> catch_expr</a></li><li><a href="language-features/cfg-target-feature.html"><strong aria-hidden="true">2.19.</strong> cfg_target_feature</a></li><li><a href="language-features/cfg-target-has-atomic.html"><strong aria-hidden="true">2.20.</strong> cfg_target_has_atomic</a></li><li><a href="language-features/cfg-target-thread-local.html"><strong aria-hidden="true">2.21.</strong> cfg_target_thread_local</a></li><li><a href="language-features/cfg-target-vendor.html"><strong aria-hidden="true">2.22.</strong> cfg_target_vendor</a></li><li><a href="language-features/clone-closures.html"><strong aria-hidden="true">2.23.</strong> clone_closures</a></li><li><a href="language-features/compiler-builtins.html"><strong aria-hidden="true">2.24.</strong> compiler_builtins</a></li><li><a href="language-features/concat-idents.html"><strong aria-hidden="true">2.25.</strong> concat_idents</a></li><li><a href="language-features/conservative-impl-trait.html"><strong aria-hidden="true">2.26.</strong> conservative_impl_trait</a></li><li><a href="language-features/const-fn.html"><strong aria-hidden="true">2.27.</strong> const_fn</a></li><li><a href="language-features/const-indexing.html"><strong aria-hidden="true">2.28.</strong> const_indexing</a></li><li><a href="language-features/copy-closures.html"><strong aria-hidden="true">2.29.</strong> copy_closures</a></li><li><a href="language-features/crate-in-paths.html"><strong aria-hidden="true">2.30.</strong> crate_in_paths</a></li><li><a href="language-features/crate-visibility-modifier.html"><strong aria-hidden="true">2.31.</strong> crate_visibility_modifier</a></li><li><a href="language-features/custom-attribute.html"><strong aria-hidden="true">2.32.</strong> custom_attribute</a></li><li><a href="language-features/custom-derive.html"><strong aria-hidden="true">2.33.</strong> custom_derive</a></li><li><a href="language-features/decl-macro.html"><strong aria-hidden="true">2.34.</strong> decl_macro</a></li><li><a href="language-features/default-type-parameter-fallback.html"><strong aria-hidden="true">2.35.</strong> default_type_parameter_fallback</a></li><li><a href="language-features/doc-cfg.html"><strong aria-hidden="true">2.36.</strong> doc_cfg</a></li><li><a href="language-features/doc-masked.html"><strong aria-hidden="true">2.37.</strong> doc_masked</a></li><li><a href="language-features/doc-spotlight.html"><strong aria-hidden="true">2.38.</strong> doc_spotlight</a></li><li><a href="language-features/dotdoteq-in-patterns.html"><strong aria-hidden="true">2.39.</strong> dotdoteq_in_patterns</a></li><li><a href="language-features/dropck-eyepatch.html"><strong aria-hidden="true">2.40.</strong> dropck_eyepatch</a></li><li><a href="language-features/dropck-parametricity.html"><strong aria-hidden="true">2.41.</strong> dropck_parametricity</a></li><li><a href="language-features/dyn-trait.html"><strong aria-hidden="true">2.42.</strong> dyn_trait</a></li><li><a href="language-features/exclusive-range-pattern.html"><strong aria-hidden="true">2.43.</strong> exclusive_range_pattern</a></li><li><a href="language-features/extern-absolute-paths.html"><strong aria-hidden="true">2.44.</strong> extern_absolute_paths</a></li><li><a href="language-features/extern-in-paths.html"><strong aria-hidden="true">2.45.</strong> extern_in_paths</a></li><li><a href="language-features/extern-types.html"><strong aria-hidden="true">2.46.</strong> extern_types</a></li><li><a href="language-features/external-doc.html"><strong aria-hidden="true">2.47.</strong> external_doc</a></li><li><a href="language-features/fn-must-use.html"><strong aria-hidden="true">2.48.</strong> fn_must_use</a></li><li><a href="language-features/fundamental.html"><strong aria-hidden="true">2.49.</strong> fundamental</a></li><li><a href="language-features/generators.html"><strong aria-hidden="true">2.50.</strong> generators</a></li><li><a href="language-features/generic-associated-types.html"><strong aria-hidden="true">2.51.</strong> generic_associated_types</a></li><li><a href="language-features/generic-param-attrs.html"><strong aria-hidden="true">2.52.</strong> generic_param_attrs</a></li><li><a href="language-features/global-allocator.html"><strong aria-hidden="true">2.53.</strong> global_allocator</a></li><li><a href="language-features/global-asm.html"><strong aria-hidden="true">2.54.</strong> global_asm</a></li><li><a href="language-features/i128-type.html"><strong aria-hidden="true">2.55.</strong> i128_type</a></li><li><a href="language-features/in-band-lifetimes.html"><strong aria-hidden="true">2.56.</strong> in_band_lifetimes</a></li><li><a href="language-features/inclusive-range-syntax.html"><strong aria-hidden="true">2.57.</strong> inclusive_range_syntax</a></li><li><a href="language-features/intrinsics.html"><strong aria-hidden="true">2.58.</strong> intrinsics</a></li><li><a href="language-features/lang-items.html"><strong aria-hidden="true">2.59.</strong> lang_items</a></li><li><a href="language-features/link-args.html"><strong aria-hidden="true">2.60.</strong> link_args</a></li><li><a href="language-features/link-cfg.html"><strong aria-hidden="true">2.61.</strong> link_cfg</a></li><li><a href="language-features/link-llvm-intrinsics.html"><strong aria-hidden="true">2.62.</strong> link_llvm_intrinsics</a></li><li><a href="language-features/linkage.html"><strong aria-hidden="true">2.63.</strong> linkage</a></li><li><a href="language-features/log-syntax.html"><strong aria-hidden="true">2.64.</strong> log_syntax</a></li><li><a href="language-features/macro-at-most-once-rep.html"><strong aria-hidden="true">2.65.</strong> macro_at_most_once_rep</a></li><li><a href="language-features/macro-lifetime-matcher.html"><strong aria-hidden="true">2.66.</strong> macro_lifetime_matcher</a></li><li><a href="language-features/macro-reexport.html"><strong aria-hidden="true">2.67.</strong> macro_reexport</a></li><li><a href="language-features/macro-vis-matcher.html"><strong aria-hidden="true">2.68.</strong> macro_vis_matcher</a></li><li><a href="language-features/main.html"><strong aria-hidden="true">2.69.</strong> main</a></li><li><a href="language-features/match-default-bindings.html"><strong aria-hidden="true">2.70.</strong> match_default_bindings</a></li><li><a href="language-features/naked-functions.html"><strong aria-hidden="true">2.71.</strong> naked_functions</a></li><li><a href="language-features/needs-allocator.html"><strong aria-hidden="true">2.72.</strong> needs_allocator</a></li><li><a href="language-features/needs-panic-runtime.html"><strong aria-hidden="true">2.73.</strong> needs_panic_runtime</a></li><li><a href="language-features/nested-impl-trait.html"><strong aria-hidden="true">2.74.</strong> nested_impl_trait</a></li><li><a href="language-features/never-type.html"><strong aria-hidden="true">2.75.</strong> never_type</a></li><li><a href="language-features/nll.html"><strong aria-hidden="true">2.76.</strong> nll</a></li><li><a href="language-features/no-core.html"><strong aria-hidden="true">2.77.</strong> no_core</a></li><li><a href="language-features/no-debug.html"><strong aria-hidden="true">2.78.</strong> no_debug</a></li><li><a href="language-features/non-ascii-idents.html"><strong aria-hidden="true">2.79.</strong> non_ascii_idents</a></li><li><a href="language-features/non-exhaustive.html"><strong aria-hidden="true">2.80.</strong> non_exhaustive</a></li><li><a href="language-features/non-modrs-mods.html"><strong aria-hidden="true">2.81.</strong> non_modrs_mods</a></li><li><a href="language-features/omit-gdb-pretty-printer-section.html"><strong aria-hidden="true">2.82.</strong> omit_gdb_pretty_printer_section</a></li><li><a href="language-features/on-unimplemented.html"><strong aria-hidden="true">2.83.</strong> on_unimplemented</a></li><li><a href="language-features/optin-builtin-traits.html"><strong aria-hidden="true">2.84.</strong> optin_builtin_traits</a></li><li><a href="language-features/overlapping-marker-traits.html"><strong aria-hidden="true">2.85.</strong> overlapping_marker_traits</a></li><li><a href="language-features/panic-runtime.html"><strong aria-hidden="true">2.86.</strong> panic_runtime</a></li><li><a href="language-features/placement-in-syntax.html"><strong aria-hidden="true">2.87.</strong> placement_in_syntax</a></li><li><a href="language-features/platform-intrinsics.html"><strong aria-hidden="true">2.88.</strong> platform_intrinsics</a></li><li><a href="language-features/plugin.html"><strong aria-hidden="true">2.89.</strong> plugin</a></li><li><a href="language-features/plugin-registrar.html"><strong aria-hidden="true">2.90.</strong> plugin_registrar</a></li><li><a href="language-features/prelude-import.html"><strong aria-hidden="true">2.91.</strong> prelude_import</a></li><li><a href="language-features/proc-macro.html"><strong aria-hidden="true">2.92.</strong> proc_macro</a></li><li><a href="language-features/profiler-runtime.html"><strong aria-hidden="true">2.93.</strong> profiler_runtime</a></li><li><a href="language-features/quote.html"><strong aria-hidden="true">2.94.</strong> quote</a></li><li><a href="language-features/repr-simd.html"><strong aria-hidden="true">2.95.</strong> repr_simd</a></li><li><a href="language-features/repr-transparent.html" class="active"><strong aria-hidden="true">2.96.</strong> repr_transparent</a></li><li><a href="language-features/repr128.html"><strong aria-hidden="true">2.97.</strong> repr128</a></li><li><a href="language-features/rustc-attrs.html"><strong aria-hidden="true">2.98.</strong> rustc_attrs</a></li><li><a href="language-features/rustc-const-unstable.html"><strong aria-hidden="true">2.99.</strong> rustc_const_unstable</a></li><li><a href="language-features/rustc-diagnostic-macros.html"><strong aria-hidden="true">2.100.</strong> rustc_diagnostic_macros</a></li><li><a href="language-features/sanitizer-runtime.html"><strong aria-hidden="true">2.101.</strong> sanitizer_runtime</a></li><li><a href="language-features/simd-ffi.html"><strong aria-hidden="true">2.102.</strong> simd_ffi</a></li><li><a href="language-features/slice-patterns.html"><strong aria-hidden="true">2.103.</strong> slice_patterns</a></li><li><a href="language-features/specialization.html"><strong aria-hidden="true">2.104.</strong> specialization</a></li><li><a href="language-features/staged-api.html"><strong aria-hidden="true">2.105.</strong> staged_api</a></li><li><a href="language-features/start.html"><strong aria-hidden="true">2.106.</strong> start</a></li><li><a href="language-features/static-nobundle.html"><strong aria-hidden="true">2.107.</strong> static_nobundle</a></li><li><a href="language-features/stmt-expr-attributes.html"><strong aria-hidden="true">2.108.</strong> stmt_expr_attributes</a></li><li><a href="language-features/structural-match.html"><strong aria-hidden="true">2.109.</strong> structural_match</a></li><li><a href="language-features/target-feature.html"><strong aria-hidden="true">2.110.</strong> target_feature</a></li><li><a href="language-features/termination-trait.html"><strong aria-hidden="true">2.111.</strong> termination_trait</a></li><li><a href="language-features/thread-local.html"><strong aria-hidden="true">2.112.</strong> thread_local</a></li><li><a href="language-features/trace-macros.html"><strong aria-hidden="true">2.113.</strong> trace_macros</a></li><li><a href="language-features/trait-alias.html"><strong aria-hidden="true">2.114.</strong> trait_alias</a></li><li><a href="language-features/type-ascription.html"><strong aria-hidden="true">2.115.</strong> type_ascription</a></li><li><a href="language-features/unboxed-closures.html"><strong aria-hidden="true">2.116.</strong> unboxed_closures</a></li><li><a href="language-features/underscore-lifetimes.html"><strong aria-hidden="true">2.117.</strong> underscore_lifetimes</a></li><li><a href="language-features/universal-impl-trait.html"><strong aria-hidden="true">2.118.</strong> universal_impl_trait</a></li><li><a href="language-features/unsized-tuple-coercion.html"><strong aria-hidden="true">2.119.</strong> unsized_tuple_coercion</a></li><li><a href="language-features/untagged-unions.html"><strong aria-hidden="true">2.120.</strong> untagged_unions</a></li><li><a href="language-features/unwind-attributes.html"><strong aria-hidden="true">2.121.</strong> unwind_attributes</a></li><li><a href="language-features/use-extern-macros.html"><strong aria-hidden="true">2.122.</strong> use_extern_macros</a></li><li><a href="language-features/used.html"><strong aria-hidden="true">2.123.</strong> used</a></li><li><a href="language-features/wasm-import-memory.html"><strong aria-hidden="true">2.124.</strong> wasm_import_memory</a></li></ol></li><li><a href="library-features.html"><strong aria-hidden="true">3.</strong> Library Features</a></li><li><ol class="section"><li><a href="library-features/align-offset.html"><strong aria-hidden="true">3.1.</strong> align_offset</a></li><li><a href="library-features/alloc.html"><strong aria-hidden="true">3.2.</strong> alloc</a></li><li><a href="library-features/alloc-jemalloc.html"><strong aria-hidden="true">3.3.</strong> alloc_jemalloc</a></li><li><a href="library-features/alloc-system.html"><strong aria-hidden="true">3.4.</strong> alloc_system</a></li><li><a href="library-features/allocator-api.html"><strong aria-hidden="true">3.5.</strong> allocator_api</a></li><li><a href="library-features/array-error-internals.html"><strong aria-hidden="true">3.6.</strong> array_error_internals</a></li><li><a href="library-features/ascii-ctype.html"><strong aria-hidden="true">3.7.</strong> ascii_ctype</a></li><li><a href="library-features/box-heap.html"><strong aria-hidden="true">3.8.</strong> box_heap</a></li><li><a href="library-features/box-into-raw-non-null.html"><strong aria-hidden="true">3.9.</strong> box_into_raw_non_null</a></li><li><a href="library-features/box-leak.html"><strong aria-hidden="true">3.10.</strong> box_leak</a></li><li><a href="library-features/bufreader-is-empty.html"><strong aria-hidden="true">3.11.</strong> bufreader_is_empty</a></li><li><a href="library-features/bufreader-seek-relative.html"><strong aria-hidden="true">3.12.</strong> bufreader_seek_relative</a></li><li><a href="library-features/c-void-variant.html"><strong aria-hidden="true">3.13.</strong> c_void_variant</a></li><li><a href="library-features/char-error-internals.html"><strong aria-hidden="true">3.14.</strong> char_error_internals</a></li><li><a href="library-features/coerce-unsized.html"><strong aria-hidden="true">3.15.</strong> coerce_unsized</a></li><li><a href="library-features/collection-placement.html"><strong aria-hidden="true">3.16.</strong> collection_placement</a></li><li><a href="library-features/collections-range.html"><strong aria-hidden="true">3.17.</strong> collections_range</a></li><li><a href="library-features/compiler-builtins-lib.html"><strong aria-hidden="true">3.18.</strong> compiler_builtins_lib</a></li><li><a href="library-features/concat-idents-macro.html"><strong aria-hidden="true">3.19.</strong> concat_idents_macro</a></li><li><a href="library-features/const-type-id.html"><strong aria-hidden="true">3.20.</strong> const_type_id</a></li><li><a href="library-features/core-char-ext.html"><strong aria-hidden="true">3.21.</strong> core_char_ext</a></li><li><a href="library-features/core-float.html"><strong aria-hidden="true">3.22.</strong> core_float</a></li><li><a href="library-features/core-intrinsics.html"><strong aria-hidden="true">3.23.</strong> core_intrinsics</a></li><li><a href="library-features/core-panic.html"><strong aria-hidden="true">3.24.</strong> core_panic</a></li><li><a href="library-features/core-private-bignum.html"><strong aria-hidden="true">3.25.</strong> core_private_bignum</a></li><li><a href="library-features/core-private-diy-float.html"><strong aria-hidden="true">3.26.</strong> core_private_diy_float</a></li><li><a href="library-features/core-slice-ext.html"><strong aria-hidden="true">3.27.</strong> core_slice_ext</a></li><li><a href="library-features/core-str-ext.html"><strong aria-hidden="true">3.28.</strong> core_str_ext</a></li><li><a href="library-features/cursor-mut-vec.html"><strong aria-hidden="true">3.29.</strong> cursor_mut_vec</a></li><li><a href="library-features/deadline-api.html"><strong aria-hidden="true">3.30.</strong> deadline_api</a></li><li><a href="library-features/dec2flt.html"><strong aria-hidden="true">3.31.</strong> dec2flt</a></li><li><a href="library-features/decode-utf8.html"><strong aria-hidden="true">3.32.</strong> decode_utf8</a></li><li><a href="library-features/derive-clone-copy.html"><strong aria-hidden="true">3.33.</strong> derive_clone_copy</a></li><li><a href="library-features/derive-eq.html"><strong aria-hidden="true">3.34.</strong> derive_eq</a></li><li><a href="library-features/drain-filter.html"><strong aria-hidden="true">3.35.</strong> drain_filter</a></li><li><a href="library-features/duration-extras.html"><strong aria-hidden="true">3.36.</strong> duration_extras</a></li><li><a href="library-features/duration-from-micros.html"><strong aria-hidden="true">3.37.</strong> duration_from_micros</a></li><li><a href="library-features/entry-and-modify.html"><strong aria-hidden="true">3.38.</strong> entry_and_modify</a></li><li><a href="library-features/entry-or-default.html"><strong aria-hidden="true">3.39.</strong> entry_or_default</a></li><li><a href="library-features/error-type-id.html"><strong aria-hidden="true">3.40.</strong> error_type_id</a></li><li><a href="library-features/exact-chunks.html"><strong aria-hidden="true">3.41.</strong> exact_chunks</a></li><li><a href="library-features/exact-size-is-empty.html"><strong aria-hidden="true">3.42.</strong> exact_size_is_empty</a></li><li><a href="library-features/fd.html"><strong aria-hidden="true">3.43.</strong> fd</a></li><li><a href="library-features/fd-read.html"><strong aria-hidden="true">3.44.</strong> fd_read</a></li><li><a href="library-features/fixed-size-array.html"><strong aria-hidden="true">3.45.</strong> fixed_size_array</a></li><li><a href="library-features/flt2dec.html"><strong aria-hidden="true">3.46.</strong> flt2dec</a></li><li><a href="library-features/fmt-flags-align.html"><strong aria-hidden="true">3.47.</strong> fmt_flags_align</a></li><li><a href="library-features/fmt-internals.html"><strong aria-hidden="true">3.48.</strong> fmt_internals</a></li><li><a href="library-features/fn-traits.html"><strong aria-hidden="true">3.49.</strong> fn_traits</a></li><li><a href="library-features/fnbox.html"><strong aria-hidden="true">3.50.</strong> fnbox</a></li><li><a href="library-features/from-ref.html"><strong aria-hidden="true">3.51.</strong> from_ref</a></li><li><a href="library-features/from-utf8-error-as-bytes.html"><strong aria-hidden="true">3.52.</strong> from_utf8_error_as_bytes</a></li><li><a href="library-features/fs-read-write.html"><strong aria-hidden="true">3.53.</strong> fs_read_write</a></li><li><a href="library-features/fused.html"><strong aria-hidden="true">3.54.</strong> fused</a></li><li><a href="library-features/future-atomic-orderings.html"><strong aria-hidden="true">3.55.</strong> future_atomic_orderings</a></li><li><a href="library-features/generator-trait.html"><strong aria-hidden="true">3.56.</strong> generator_trait</a></li><li><a href="library-features/get-type-id.html"><strong aria-hidden="true">3.57.</strong> get_type_id</a></li><li><a href="library-features/getpid.html"><strong aria-hidden="true">3.58.</strong> getpid</a></li><li><a href="library-features/hash-map-remove-entry.html"><strong aria-hidden="true">3.59.</strong> hash_map_remove_entry</a></li><li><a href="library-features/heap-api.html"><strong aria-hidden="true">3.60.</strong> heap_api</a></li><li><a href="library-features/i128.html"><strong aria-hidden="true">3.61.</strong> i128</a></li><li><a href="library-features/inclusive-range.html"><strong aria-hidden="true">3.62.</strong> inclusive_range</a></li><li><a href="library-features/int-error-internals.html"><strong aria-hidden="true">3.63.</strong> int_error_internals</a></li><li><a href="library-features/integer-atomics.html"><strong aria-hidden="true">3.64.</strong> integer_atomics</a></li><li><a href="library-features/io.html"><strong aria-hidden="true">3.65.</strong> io</a></li><li><a href="library-features/io-error-internals.html"><strong aria-hidden="true">3.66.</strong> io_error_internals</a></li><li><a href="library-features/ip.html"><strong aria-hidden="true">3.67.</strong> ip</a></li><li><a href="library-features/ip-constructors.html"><strong aria-hidden="true">3.68.</strong> ip_constructors</a></li><li><a href="library-features/iter-rfind.html"><strong aria-hidden="true">3.69.</strong> iter_rfind</a></li><li><a href="library-features/iter-rfold.html"><strong aria-hidden="true">3.70.</strong> iter_rfold</a></li><li><a href="library-features/iterator-step-by.html"><strong aria-hidden="true">3.71.</strong> iterator_step_by</a></li><li><a href="library-features/iterator-try-fold.html"><strong aria-hidden="true">3.72.</strong> iterator_try_fold</a></li><li><a href="library-features/libstd-io-internals.html"><strong aria-hidden="true">3.73.</strong> libstd_io_internals</a></li><li><a href="library-features/libstd-sys-internals.html"><strong aria-hidden="true">3.74.</strong> libstd_sys_internals</a></li><li><a href="library-features/libstd-thread-internals.html"><strong aria-hidden="true">3.75.</strong> libstd_thread_internals</a></li><li><a href="library-features/linked-list-extras.html"><strong aria-hidden="true">3.76.</strong> linked_list_extras</a></li><li><a href="library-features/lookup-host.html"><strong aria-hidden="true">3.77.</strong> lookup_host</a></li><li><a href="library-features/map-entry-replace.html"><strong aria-hidden="true">3.78.</strong> map_entry_replace</a></li><li><a href="library-features/mpsc-select.html"><strong aria-hidden="true">3.79.</strong> mpsc_select</a></li><li><a href="library-features/n16.html"><strong aria-hidden="true">3.80.</strong> n16</a></li><li><a href="library-features/nonnull-cast.html"><strong aria-hidden="true">3.81.</strong> nonnull_cast</a></li><li><a href="library-features/nonzero.html"><strong aria-hidden="true">3.82.</strong> nonzero</a></li><li><a href="library-features/offset-to.html"><strong aria-hidden="true">3.83.</strong> offset_to</a></li><li><a href="library-features/once-poison.html"><strong aria-hidden="true">3.84.</strong> once_poison</a></li><li><a href="library-features/option-filter.html"><strong aria-hidden="true">3.85.</strong> option_filter</a></li><li><a href="library-features/option-ref-mut-cloned.html"><strong aria-hidden="true">3.86.</strong> option_ref_mut_cloned</a></li><li><a href="library-features/panic-abort.html"><strong aria-hidden="true">3.87.</strong> panic_abort</a></li><li><a href="library-features/panic-unwind.html"><strong aria-hidden="true">3.88.</strong> panic_unwind</a></li><li><a href="library-features/pattern.html"><strong aria-hidden="true">3.89.</strong> pattern</a></li><li><a href="library-features/placement-in.html"><strong aria-hidden="true">3.90.</strong> placement_in</a></li><li><a href="library-features/placement-new-protocol.html"><strong aria-hidden="true">3.91.</strong> placement_new_protocol</a></li><li><a href="library-features/pointer-methods.html"><strong aria-hidden="true">3.92.</strong> pointer_methods</a></li><li><a href="library-features/print-internals.html"><strong aria-hidden="true">3.93.</strong> print_internals</a></li><li><a href="library-features/proc-macro-internals.html"><strong aria-hidden="true">3.94.</strong> proc_macro_internals</a></li><li><a href="library-features/process-internals.html"><strong aria-hidden="true">3.95.</strong> process_internals</a></li><li><a href="library-features/profiler-runtime-lib.html"><strong aria-hidden="true">3.96.</strong> profiler_runtime_lib</a></li><li><a href="library-features/ptr-internals.html"><strong aria-hidden="true">3.97.</strong> ptr_internals</a></li><li><a href="library-features/range-contains.html"><strong aria-hidden="true">3.98.</strong> range_contains</a></li><li><a href="library-features/raw.html"><strong aria-hidden="true">3.99.</strong> raw</a></li><li><a href="library-features/rc-downcast.html"><strong aria-hidden="true">3.100.</strong> rc_downcast</a></li><li><a href="library-features/read-initializer.html"><strong aria-hidden="true">3.101.</strong> read_initializer</a></li><li><a href="library-features/refcell-replace-swap.html"><strong aria-hidden="true">3.102.</strong> refcell_replace_swap</a></li><li><a href="library-features/rt.html"><strong aria-hidden="true">3.103.</strong> rt</a></li><li><a href="library-features/rustc-private.html"><strong aria-hidden="true">3.104.</strong> rustc_private</a></li><li><a href="library-features/sanitizer-runtime-lib.html"><strong aria-hidden="true">3.105.</strong> sanitizer_runtime_lib</a></li><li><a href="library-features/set-stdio.html"><strong aria-hidden="true">3.106.</strong> set_stdio</a></li><li><a href="library-features/shared.html"><strong aria-hidden="true">3.107.</strong> shared</a></li><li><a href="library-features/sip-hash-13.html"><strong aria-hidden="true">3.108.</strong> sip_hash_13</a></li><li><a href="library-features/slice-concat-ext.html"><strong aria-hidden="true">3.109.</strong> slice_concat_ext</a></li><li><a href="library-features/slice-get-slice.html"><strong aria-hidden="true">3.110.</strong> slice_get_slice</a></li><li><a href="library-features/slice-internals.html"><strong aria-hidden="true">3.111.</strong> slice_internals</a></li><li><a href="library-features/slice-rotate.html"><strong aria-hidden="true">3.112.</strong> slice_rotate</a></li><li><a href="library-features/slice-rsplit.html"><strong aria-hidden="true">3.113.</strong> slice_rsplit</a></li><li><a href="library-features/sort-internals.html"><strong aria-hidden="true">3.114.</strong> sort_internals</a></li><li><a href="library-features/splice.html"><strong aria-hidden="true">3.115.</strong> splice</a></li><li><a href="library-features/std-internals.html"><strong aria-hidden="true">3.116.</strong> std_internals</a></li><li><a href="library-features/step-trait.html"><strong aria-hidden="true">3.117.</strong> step_trait</a></li><li><a href="library-features/str-escape.html"><strong aria-hidden="true">3.118.</strong> str_escape</a></li><li><a href="library-features/str-internals.html"><strong aria-hidden="true">3.119.</strong> str_internals</a></li><li><a href="library-features/string-retain.html"><strong aria-hidden="true">3.120.</strong> string_retain</a></li><li><a href="library-features/swap-nonoverlapping.html"><strong aria-hidden="true">3.121.</strong> swap_nonoverlapping</a></li><li><a href="library-features/swap-with-slice.html"><strong aria-hidden="true">3.122.</strong> swap_with_slice</a></li><li><a href="library-features/take-set-limit.html"><strong aria-hidden="true">3.123.</strong> take_set_limit</a></li><li><a href="library-features/test.html"><strong aria-hidden="true">3.124.</strong> test</a></li><li><a href="library-features/thread-local-internals.html"><strong aria-hidden="true">3.125.</strong> thread_local_internals</a></li><li><a href="library-features/thread-local-state.html"><strong aria-hidden="true">3.126.</strong> thread_local_state</a></li><li><a href="library-features/toowned-clone-into.html"><strong aria-hidden="true">3.127.</strong> toowned_clone_into</a></li><li><a href="library-features/transpose-result.html"><strong aria-hidden="true">3.128.</strong> transpose_result</a></li><li><a href="library-features/trusted-len.html"><strong aria-hidden="true">3.129.</strong> trusted_len</a></li><li><a href="library-features/try-from.html"><strong aria-hidden="true">3.130.</strong> try_from</a></li><li><a href="library-features/try-trait.html"><strong aria-hidden="true">3.131.</strong> try_trait</a></li><li><a href="library-features/unicode.html"><strong aria-hidden="true">3.132.</strong> unicode</a></li><li><a href="library-features/unix-ppid.html"><strong aria-hidden="true">3.133.</strong> unix_ppid</a></li><li><a href="library-features/unreachable.html"><strong aria-hidden="true">3.134.</strong> unreachable</a></li><li><a href="library-features/unsize.html"><strong aria-hidden="true">3.135.</strong> unsize</a></li><li><a href="library-features/update-panic-count.html"><strong aria-hidden="true">3.136.</strong> update_panic_count</a></li><li><a href="library-features/vec-remove-item.html"><strong aria-hidden="true">3.137.</strong> vec_remove_item</a></li><li><a href="library-features/vec-resize-default.html"><strong aria-hidden="true">3.138.</strong> vec_resize_default</a></li><li><a href="library-features/windows-c.html"><strong aria-hidden="true">3.139.</strong> windows_c</a></li><li><a href="library-features/windows-handle.html"><strong aria-hidden="true">3.140.</strong> windows_handle</a></li><li><a href="library-features/windows-net.html"><strong aria-hidden="true">3.141.</strong> windows_net</a></li><li><a href="library-features/windows-stdio.html"><strong aria-hidden="true">3.142.</strong> windows_stdio</a></li></ol></li></ol>
        </nav>

        <div id="page-wrapper" class="page-wrapper">

            <div class="page">
                
                <div id="menu-bar" class="menu-bar">
                    <div id="menu-bar-sticky-container">
                        <div class="left-buttons">
                            <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
                                <i class="fa fa-bars"></i>
                            </button>
                            <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
                                <i class="fa fa-paint-brush"></i>
                            </button>
                            <ul id="theme-list" class="theme-popup" aria-label="submenu">
                                <li><button class="theme" id="light">Light <span class="default">(default)</span></button></li>
                                <li><button class="theme" id="rust">Rust</button></li>
                                <li><button class="theme" id="coal">Coal</button></li>
                                <li><button class="theme" id="navy">Navy</button></li>
                                <li><button class="theme" id="ayu">Ayu</button></li>
                            </ul>
                        </div>

                        <h1 class="menu-title"></h1>

                        <div class="right-buttons">
                            <a href="print.html" title="Print this book" aria-label="Print this book">
                                <i id="print-button" class="fa fa-print"></i>
                            </a>
                        </div>
                    </div>
                </div>

                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
                <script type="text/javascript">
                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
                    });
                </script>

                <div id="content" class="content">
                    <main>
                        <a class="header" href="language-features/repr-transparent.html#repr_transparent" id="repr_transparent"><h1><code>repr_transparent</code></h1></a>
<p>The tracking issue for this feature is: <a href="https://github.com/rust-lang/rust/issues/43036">#43036</a></p>
<hr />
<p>This feature enables the <code>repr(transparent)</code> attribute on structs, which enables
the use of newtypes without the usual ABI implications of wrapping the value in
a struct.</p>
<a class="header" href="language-features/repr-transparent.html#background" id="background"><h2>Background</h2></a>
<p>It's sometimes useful to add additional type safety by introducing <em>newtypes</em>.
For example, code that handles numeric quantities in different units such as
millimeters, centimeters, grams, kilograms, etc. may want to use the type system
to rule out mistakes such as adding millimeters to grams:</p>
<pre><pre class="playpen"><code class="language-rust">
# #![allow(unused_variables)]
#fn main() {
use std::ops::Add;

struct Millimeters(f64);
struct Grams(f64);

impl Add&lt;Millimeters&gt; for Millimeters {
    type Output = Millimeters;

    fn add(self, other: Millimeters) -&gt; Millimeters {
        Millimeters(self.0 + other.0)
    }
}

// Likewise: impl Add&lt;Grams&gt; for Grams {}
#}</code></pre></pre>
<p>Other uses of newtypes include using <code>PhantomData</code> to add lifetimes to raw
pointers or to implement the &quot;phantom types&quot; pattern. See the <a href="https://doc.rust-lang.org/std/marker/struct.PhantomData.html">PhantomData</a>
documentation and <a href="https://doc.rust-lang.org/nomicon/phantom-data.html">the Nomicon</a> for more details.</p>
<p>The added type safety is especially useful when interacting with C or other
languages. However, in those cases we need to ensure the newtypes we add do not
introduce incompatibilities with the C ABI.</p>
<a class="header" href="language-features/repr-transparent.html#newtypes-in-ffi" id="newtypes-in-ffi"><h2>Newtypes in FFI</h2></a>
<p>Luckily, <code>repr(C)</code> newtypes are laid out just like the type they wrap on all
platforms which Rust currently supports, and likely on many more. For example,
consider this C declaration:</p>
<pre><code class="language-C">struct Object {
    double weight; //&lt; in grams
    double height; //&lt; in millimeters
    // ...
}

void frobnicate(struct Object *);
</code></pre>
<p>While using this C code from Rust, we could add <code>repr(C)</code> to the <code>Grams</code> and
<code>Millimeters</code> newtypes introduced above and use them to add some type safety
while staying compatible with the memory layout of <code>Object</code>:</p>
<pre><pre class="playpen"><code class="language-rust no_run">
# #![allow(unused_variables)]
#fn main() {
#[repr(C)]
struct Grams(f64);

#[repr(C)]
struct Millimeters(f64);

#[repr(C)]
struct Object {
    weight: Grams,
    height: Millimeters,
    // ...
}

extern {
    fn frobnicate(_: *mut Object);
}
#}</code></pre></pre>
<p>This works even when adding some <code>PhantomData</code> fields, because they are
zero-sized and therefore don't have to affect the memory layout.</p>
<p>However, there's more to the ABI than just memory layout: there's also the
question of how function call arguments and return values are passed. Many
common ABI treat a struct containing a single field differently from that field
itself, at least when the field is a scalar (e.g., integer or float or pointer).</p>
<p>To continue the above example, suppose the C library also exposes a function
like this:</p>
<pre><code class="language-C">double calculate_weight(double height);
</code></pre>
<p>Using our newtypes on the Rust side like this will cause an ABI mismatch on many
platforms:</p>
<pre><code class="language-rust ignore">extern {
    fn calculate_weight(height: Millimeters) -&gt; Grams;
}
</code></pre>
<p>For example, on x86_64 Linux, Rust will pass the argument in an integer
register, while the C function expects the argument to be in a floating-point
register. Likewise, the C function will return the result in a floating-point
register while Rust will expect it in an integer register.</p>
<p>Note that this problem is not specific to floats: To give another example,
32-bit x86 linux will pass and return <code>struct Foo(i32);</code> on the stack while
<code>i32</code> is placed in registers.</p>
<a class="header" href="language-features/repr-transparent.html#enter-reprtransparent" id="enter-reprtransparent"><h2>Enter <code>repr(transparent)</code></h2></a>
<p>So while <code>repr(C)</code> happens to do the right thing with respect to memory layout,
it's not quite the right tool for newtypes in FFI. Instead of declaring a C
struct, we need to communicate to the Rust compiler that our newtype is just for
type safety on the Rust side. This is what <code>repr(transparent)</code> does.</p>
<p>The attribute can be applied to a newtype-like structs that contains a single
field. It indicates that the newtype should be represented exactly like that
field's type, i.e., the newtype should be ignored for ABI purpopses: not only is
it laid out the same in memory, it is also passed identically in function calls.</p>
<p>In the above example, the ABI mismatches can be prevented by making the newtypes
<code>Grams</code> and <code>Millimeters</code> transparent like this:</p>
<pre><pre class="playpen"><code class="language-rust">
# #![allow(unused_variables)]
#![feature(repr_transparent)]

#fn main() {
#[repr(transparent)]
struct Grams(f64);

#[repr(transparent)]
struct Millimeters(f64);
#}</code></pre></pre>
<p>In addition to that single field, any number of zero-sized fields are permitted,
including but not limited to <code>PhantomData</code>:</p>
<pre><pre class="playpen"><code class="language-rust">
# #![allow(unused_variables)]
#![feature(repr_transparent)]

#fn main() {
use std::marker::PhantomData;

struct Foo { /* ... */ }

#[repr(transparent)]
struct FooPtrWithLifetime&lt;'a&gt;(*const Foo, PhantomData&lt;&amp;'a Foo&gt;);

#[repr(transparent)]
struct NumberWithUnit&lt;T, U&gt;(T, PhantomData&lt;U&gt;);

struct CustomZst;

#[repr(transparent)]
struct PtrWithCustomZst&lt;'a&gt; {
    ptr: FooPtrWithLifetime&lt;'a&gt;,
    some_marker: CustomZst,
}
#}</code></pre></pre>
<p>Transparent structs can be nested: <code>PtrWithCustomZst</code> is also represented
exactly like <code>*const Foo</code>.</p>
<p>Because <code>repr(transparent)</code> delegates all representation concerns to another
type, it is incompatible with all other <code>repr(..)</code> attributes. It also cannot be
applied to enums, unions, empty structs, structs whose fields are all
zero-sized, or structs with <em>multiple</em> non-zero-sized fields.</p>

                    </main>

                    <nav class="nav-wrapper" aria-label="Page navigation">
                        <!-- Mobile navigation buttons -->
                        
                            <a rel="prev" href="language-features/repr-simd.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                                <i class="fa fa-angle-left"></i>
                            </a>
                        

                        
                            <a rel="next" href="language-features/repr128.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                                <i class="fa fa-angle-right"></i>
                            </a>
                        

                        <div style="clear: both"></div>
                    </nav>
                </div>
            </div>

            <nav class="nav-wide-wrapper" aria-label="Page navigation">
                
                    <a href="language-features/repr-simd.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
                        <i class="fa fa-angle-left"></i>
                    </a>
                

                
                    <a href="language-features/repr128.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
                        <i class="fa fa-angle-right"></i>
                    </a>
                
            </nav>

        </div>


        <!-- Local fallback for Font Awesome -->
        <script>
            if (getComputedStyle(document.querySelector(".fa")).fontFamily !== "FontAwesome") {
                var link = document.createElement('link');
                link.rel = 'stylesheet';
                link.type = 'text/css';
                link.href = '_FontAwesome/css/font-awesome.css';
                document.head.insertBefore(link, document.head.firstChild)
            }
        </script>

        

        

        

        

        <script src="highlight.js"></script>
        <script src="book.js"></script>

        <!-- Custom JS script -->
        

    </body>
</html>