Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates > by-pkgid > 564935689ab5527f955e5449ded02799 > files > 5505

rust-doc-1.19.0-1.mga6.armv7hl.rpm

<!DOCTYPE HTML>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>allocator - </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">

        <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">

        <!-- MathJax -->
        <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>

        <!-- Fetch JQuery from CDN but have a local fallback -->
        <script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
        <script>
            if (typeof jQuery == 'undefined') {
                document.write(unescape("%3Cscript src='jquery.js'%3E%3C/script%3E"));
            }
        </script>
    </head>
    <body class="light">
        <!-- Set the theme before any content is loaded, prevents flash -->
        <script type="text/javascript">
            var theme = localStorage.getItem('theme');
            if (theme == null) { theme = 'light'; }
            $('body').removeClass().addClass(theme);
        </script>

        <!-- Hide / unhide sidebar before it is displayed -->
        <script type="text/javascript">
            var sidebar = localStorage.getItem('sidebar');
            if (sidebar === "hidden") { $("html").addClass("sidebar-hidden") }
            else if (sidebar === "visible") { $("html").addClass("sidebar-visible") }
        </script>

        <div id="sidebar" class="sidebar">
            <ul class="chapter"><li class="affix"><a href="the-unstable-book.html">The Unstable Book</a></li><li><a href="compiler-flags.html"><strong>1.</strong> Compiler flags</a></li><li><ul class="section"><li><a href="compiler-flags/linker-flavor.html"><strong>1.1.</strong> linker_flavor</a></li><li><a href="compiler-flags/remap-path-prefix.html"><strong>1.2.</strong> remap_path_prefix</a></li></ul></li><li><a href="language-features.html"><strong>2.</strong> Language features</a></li><li><ul class="section"><li><a href="language-features/abi-msp430-interrupt.html"><strong>2.1.</strong> abi_msp430_interrupt</a></li><li><a href="language-features/abi-ptx.html"><strong>2.2.</strong> abi_ptx</a></li><li><a href="language-features/abi-sysv64.html"><strong>2.3.</strong> abi_sysv64</a></li><li><a href="language-features/abi-thiscall.html"><strong>2.4.</strong> abi_thiscall</a></li><li><a href="language-features/abi-unadjusted.html"><strong>2.5.</strong> abi_unadjusted</a></li><li><a href="language-features/abi-vectorcall.html"><strong>2.6.</strong> abi_vectorcall</a></li><li><a href="language-features/abi-x86-interrupt.html"><strong>2.7.</strong> abi_x86_interrupt</a></li><li><a href="language-features/advanced-slice-patterns.html"><strong>2.8.</strong> advanced_slice_patterns</a></li><li><a href="language-features/allocator.html" class="active"><strong>2.9.</strong> allocator</a></li><li><a href="language-features/allow-internal-unstable.html"><strong>2.10.</strong> allow_internal_unstable</a></li><li><a href="language-features/asm.html"><strong>2.11.</strong> asm</a></li><li><a href="language-features/associated-consts.html"><strong>2.12.</strong> associated_consts</a></li><li><a href="language-features/associated-type-defaults.html"><strong>2.13.</strong> associated_type_defaults</a></li><li><a href="language-features/attr-literals.html"><strong>2.14.</strong> attr_literals</a></li><li><a href="language-features/box-patterns.html"><strong>2.15.</strong> box_patterns</a></li><li><a href="language-features/box-syntax.html"><strong>2.16.</strong> box_syntax</a></li><li><a href="language-features/catch-expr.html"><strong>2.17.</strong> catch_expr</a></li><li><a href="language-features/cfg-target-feature.html"><strong>2.18.</strong> cfg_target_feature</a></li><li><a href="language-features/cfg-target-has-atomic.html"><strong>2.19.</strong> cfg_target_has_atomic</a></li><li><a href="language-features/cfg-target-thread-local.html"><strong>2.20.</strong> cfg_target_thread_local</a></li><li><a href="language-features/cfg-target-vendor.html"><strong>2.21.</strong> cfg_target_vendor</a></li><li><a href="language-features/compiler-builtins.html"><strong>2.22.</strong> compiler_builtins</a></li><li><a href="language-features/concat-idents.html"><strong>2.23.</strong> concat_idents</a></li><li><a href="language-features/conservative-impl-trait.html"><strong>2.24.</strong> conservative_impl_trait</a></li><li><a href="language-features/const-fn.html"><strong>2.25.</strong> const_fn</a></li><li><a href="language-features/const-indexing.html"><strong>2.26.</strong> const_indexing</a></li><li><a href="language-features/custom-attribute.html"><strong>2.27.</strong> custom_attribute</a></li><li><a href="language-features/custom-derive.html"><strong>2.28.</strong> custom_derive</a></li><li><a href="language-features/default-type-parameter-fallback.html"><strong>2.29.</strong> default_type_parameter_fallback</a></li><li><a href="language-features/drop-types-in-const.html"><strong>2.30.</strong> drop_types_in_const</a></li><li><a href="language-features/dropck-eyepatch.html"><strong>2.31.</strong> dropck_eyepatch</a></li><li><a href="language-features/dropck-parametricity.html"><strong>2.32.</strong> dropck_parametricity</a></li><li><a href="language-features/exclusive-range-pattern.html"><strong>2.33.</strong> exclusive_range_pattern</a></li><li><a href="language-features/fundamental.html"><strong>2.34.</strong> fundamental</a></li><li><a href="language-features/generic-param-attrs.html"><strong>2.35.</strong> generic_param_attrs</a></li><li><a href="language-features/global_asm.html"><strong>2.36.</strong> global_asm</a></li><li><a href="language-features/i128-type.html"><strong>2.37.</strong> i128_type</a></li><li><a href="language-features/inclusive-range-syntax.html"><strong>2.38.</strong> inclusive_range_syntax</a></li><li><a href="language-features/intrinsics.html"><strong>2.39.</strong> intrinsics</a></li><li><a href="language-features/lang-items.html"><strong>2.40.</strong> lang_items</a></li><li><a href="language-features/link-args.html"><strong>2.41.</strong> link_args</a></li><li><a href="language-features/link-cfg.html"><strong>2.42.</strong> link_cfg</a></li><li><a href="language-features/link-llvm-intrinsics.html"><strong>2.43.</strong> link_llvm_intrinsics</a></li><li><a href="language-features/linkage.html"><strong>2.44.</strong> linkage</a></li><li><a href="language-features/log-syntax.html"><strong>2.45.</strong> log_syntax</a></li><li><a href="language-features/macro-reexport.html"><strong>2.46.</strong> macro_reexport</a></li><li><a href="language-features/macro-vis-matcher.html"><strong>2.47.</strong> macro_vis_matcher</a></li><li><a href="language-features/main.html"><strong>2.48.</strong> main</a></li><li><a href="language-features/naked-functions.html"><strong>2.49.</strong> naked_functions</a></li><li><a href="language-features/needs-allocator.html"><strong>2.50.</strong> needs_allocator</a></li><li><a href="language-features/needs-panic-runtime.html"><strong>2.51.</strong> needs_panic_runtime</a></li><li><a href="language-features/never-type.html"><strong>2.52.</strong> never_type</a></li><li><a href="language-features/no-core.html"><strong>2.53.</strong> no_core</a></li><li><a href="language-features/no-debug.html"><strong>2.54.</strong> no_debug</a></li><li><a href="language-features/non-ascii-idents.html"><strong>2.55.</strong> non_ascii_idents</a></li><li><a href="language-features/omit-gdb-pretty-printer-section.html"><strong>2.56.</strong> omit_gdb_pretty_printer_section</a></li><li><a href="language-features/on-unimplemented.html"><strong>2.57.</strong> on_unimplemented</a></li><li><a href="language-features/optin-builtin-traits.html"><strong>2.58.</strong> optin_builtin_traits</a></li><li><a href="language-features/overlapping-marker-traits.html"><strong>2.59.</strong> overlapping_marker_traits</a></li><li><a href="language-features/panic-runtime.html"><strong>2.60.</strong> panic_runtime</a></li><li><a href="language-features/placement-in-syntax.html"><strong>2.61.</strong> placement_in_syntax</a></li><li><a href="language-features/platform-intrinsics.html"><strong>2.62.</strong> platform_intrinsics</a></li><li><a href="language-features/plugin.html"><strong>2.63.</strong> plugin</a></li><li><a href="language-features/plugin-registrar.html"><strong>2.64.</strong> plugin_registrar</a></li><li><a href="language-features/prelude-import.html"><strong>2.65.</strong> prelude_import</a></li><li><a href="language-features/proc-macro.html"><strong>2.66.</strong> proc_macro</a></li><li><a href="language-features/quote.html"><strong>2.67.</strong> quote</a></li><li><a href="language-features/repr-align.html"><strong>2.68.</strong> repr_align</a></li><li><a href="language-features/repr-simd.html"><strong>2.69.</strong> repr_simd</a></li><li><a href="language-features/rustc-attrs.html"><strong>2.70.</strong> rustc_attrs</a></li><li><a href="language-features/rustc-diagnostic-macros.html"><strong>2.71.</strong> rustc_diagnostic_macros</a></li><li><a href="language-features/rvalue-static-promotion.html"><strong>2.72.</strong> rvalue_static_promotion</a></li><li><a href="language-features/sanitizer-runtime.html"><strong>2.73.</strong> sanitizer_runtime</a></li><li><a href="language-features/simd.html"><strong>2.74.</strong> simd</a></li><li><a href="language-features/simd-ffi.html"><strong>2.75.</strong> simd_ffi</a></li><li><a href="language-features/slice-patterns.html"><strong>2.76.</strong> slice_patterns</a></li><li><a href="language-features/specialization.html"><strong>2.77.</strong> specialization</a></li><li><a href="language-features/staged-api.html"><strong>2.78.</strong> staged_api</a></li><li><a href="language-features/start.html"><strong>2.79.</strong> start</a></li><li><a href="language-features/static-nobundle.html"><strong>2.80.</strong> static_nobundle</a></li><li><a href="language-features/stmt-expr-attributes.html"><strong>2.81.</strong> stmt_expr_attributes</a></li><li><a href="language-features/struct-field-attributes.html"><strong>2.82.</strong> struct_field_attributes</a></li><li><a href="language-features/structural-match.html"><strong>2.83.</strong> structural_match</a></li><li><a href="language-features/target-feature.html"><strong>2.84.</strong> target_feature</a></li><li><a href="language-features/thread-local.html"><strong>2.85.</strong> thread_local</a></li><li><a href="language-features/trace-macros.html"><strong>2.86.</strong> trace_macros</a></li><li><a href="language-features/type-ascription.html"><strong>2.87.</strong> type_ascription</a></li><li><a href="language-features/unboxed-closures.html"><strong>2.88.</strong> unboxed_closures</a></li><li><a href="language-features/untagged-unions.html"><strong>2.89.</strong> untagged_unions</a></li><li><a href="language-features/unwind-attributes.html"><strong>2.90.</strong> unwind_attributes</a></li><li><a href="language-features/use-extern-macros.html"><strong>2.91.</strong> use_extern_macros</a></li><li><a href="language-features/used.html"><strong>2.92.</strong> used</a></li></ul></li><li><a href="library-features.html"><strong>3.</strong> Library Features</a></li><li><ul class="section"><li><a href="library-features/alloc-jemalloc.html"><strong>3.1.</strong> alloc_jemalloc</a></li><li><a href="library-features/alloc-system.html"><strong>3.2.</strong> alloc_system</a></li><li><a href="library-features/alloc.html"><strong>3.3.</strong> alloc</a></li><li><a href="library-features/as-c-str.html"><strong>3.4.</strong> as_c_str</a></li><li><a href="library-features/ascii-ctype.html"><strong>3.5.</strong> ascii_ctype</a></li><li><a href="library-features/box-heap.html"><strong>3.6.</strong> box_heap</a></li><li><a href="library-features/c-void-variant.html"><strong>3.7.</strong> c_void_variant</a></li><li><a href="library-features/char-escape-debug.html"><strong>3.8.</strong> char_escape_debug</a></li><li><a href="library-features/coerce-unsized.html"><strong>3.9.</strong> coerce_unsized</a></li><li><a href="library-features/collection-placement.html"><strong>3.10.</strong> collection_placement</a></li><li><a href="library-features/collections-range.html"><strong>3.11.</strong> collections_range</a></li><li><a href="library-features/collections.html"><strong>3.12.</strong> collections</a></li><li><a href="library-features/compiler-builtins-lib.html"><strong>3.13.</strong> compiler_builtins_lib</a></li><li><a href="library-features/compiler-fences.html"><strong>3.14.</strong> compiler_fences</a></li><li><a href="library-features/concat-idents-macro.html"><strong>3.15.</strong> concat_idents_macro</a></li><li><a href="library-features/core-char-ext.html"><strong>3.16.</strong> core_char_ext</a></li><li><a href="library-features/core-float.html"><strong>3.17.</strong> core_float</a></li><li><a href="library-features/core-intrinsics.html"><strong>3.18.</strong> core_intrinsics</a></li><li><a href="library-features/core-panic.html"><strong>3.19.</strong> core_panic</a></li><li><a href="library-features/core-private-bignum.html"><strong>3.20.</strong> core_private_bignum</a></li><li><a href="library-features/core-private-diy-float.html"><strong>3.21.</strong> core_private_diy_float</a></li><li><a href="library-features/core-slice-ext.html"><strong>3.22.</strong> core_slice_ext</a></li><li><a href="library-features/core-str-ext.html"><strong>3.23.</strong> core_str_ext</a></li><li><a href="library-features/dec2flt.html"><strong>3.24.</strong> dec2flt</a></li><li><a href="library-features/decode-utf8.html"><strong>3.25.</strong> decode_utf8</a></li><li><a href="library-features/derive-clone-copy.html"><strong>3.26.</strong> derive_clone_copy</a></li><li><a href="library-features/derive-eq.html"><strong>3.27.</strong> derive_eq</a></li><li><a href="library-features/discriminant-value.html"><strong>3.28.</strong> discriminant_value</a></li><li><a href="library-features/error-type-id.html"><strong>3.29.</strong> error_type_id</a></li><li><a href="library-features/exact-size-is-empty.html"><strong>3.30.</strong> exact_size_is_empty</a></li><li><a href="library-features/fd.html"><strong>3.31.</strong> fd</a></li><li><a href="library-features/fd-read.html"><strong>3.32.</strong> fd_read</a></li><li><a href="library-features/fixed-size-array.html"><strong>3.33.</strong> fixed_size_array</a></li><li><a href="library-features/float-bits-conv.html"><strong>3.34.</strong> float_bits_conv</a></li><li><a href="library-features/flt2dec.html"><strong>3.35.</strong> flt2dec</a></li><li><a href="library-features/fmt-flags-align.html"><strong>3.36.</strong> fmt_flags_align</a></li><li><a href="library-features/fmt-internals.html"><strong>3.37.</strong> fmt_internals</a></li><li><a href="library-features/fn-traits.html"><strong>3.38.</strong> fn_traits</a></li><li><a href="library-features/fnbox.html"><strong>3.39.</strong> fnbox</a></li><li><a href="library-features/from_utf8_error_as_bytes.html"><strong>3.40.</strong> from_utf8_error_as_bytes</a></li><li><a href="library-features/fused.html"><strong>3.41.</strong> fused</a></li><li><a href="library-features/future-atomic-orderings.html"><strong>3.42.</strong> future_atomic_orderings</a></li><li><a href="library-features/get-type-id.html"><strong>3.43.</strong> get_type_id</a></li><li><a href="library-features/heap-api.html"><strong>3.44.</strong> heap_api</a></li><li><a href="library-features/hint-core-should-pause.html"><strong>3.45.</strong> hint_core_should_pause</a></li><li><a href="library-features/i128.html"><strong>3.46.</strong> i128</a></li><li><a href="library-features/inclusive-range.html"><strong>3.47.</strong> inclusive_range</a></li><li><a href="library-features/integer-atomics.html"><strong>3.48.</strong> integer_atomics</a></li><li><a href="library-features/into-boxed-c-str.html"><strong>3.49.</strong> into_boxed_c_str</a></li><li><a href="library-features/into-boxed-os-str.html"><strong>3.50.</strong> into_boxed_os_str</a></li><li><a href="library-features/into-boxed-path.html"><strong>3.51.</strong> into_boxed_path</a></li><li><a href="library-features/io-error-internals.html"><strong>3.52.</strong> io_error_internals</a></li><li><a href="library-features/io.html"><strong>3.53.</strong> io</a></li><li><a href="library-features/ip.html"><strong>3.54.</strong> ip</a></li><li><a href="library-features/iter-rfind.html"><strong>3.55.</strong> iter_rfind</a></li><li><a href="library-features/iterator-step-by.html"><strong>3.56.</strong> iterator_step_by</a></li><li><a href="library-features/libstd-io-internals.html"><strong>3.57.</strong> libstd_io_internals</a></li><li><a href="library-features/libstd-sys-internals.html"><strong>3.58.</strong> libstd_sys_internals</a></li><li><a href="library-features/libstd-thread-internals.html"><strong>3.59.</strong> libstd_thread_internals</a></li><li><a href="library-features/linked-list-extras.html"><strong>3.60.</strong> linked_list_extras</a></li><li><a href="library-features/lookup-host.html"><strong>3.61.</strong> lookup_host</a></li><li><a href="library-features/manually-drop.html"><strong>3.62.</strong> manually_drop</a></li><li><a href="library-features/more-io-inner-methods.html"><strong>3.63.</strong> more_io_inner_methods</a></li><li><a href="library-features/mpsc-select.html"><strong>3.64.</strong> mpsc_select</a></li><li><a href="library-features/n16.html"><strong>3.65.</strong> n16</a></li><li><a href="library-features/never-type-impls.html"><strong>3.66.</strong> never_type_impls</a></li><li><a href="library-features/nonzero.html"><strong>3.67.</strong> nonzero</a></li><li><a href="library-features/offset-to.html"><strong>3.68.</strong> offset_to</a></li><li><a href="library-features/once-poison.html"><strong>3.69.</strong> once_poison</a></li><li><a href="library-features/oom.html"><strong>3.70.</strong> oom</a></li><li><a href="library-features/option-entry.html"><strong>3.71.</strong> option_entry</a></li><li><a href="library-features/panic-abort.html"><strong>3.72.</strong> panic_abort</a></li><li><a href="library-features/panic-unwind.html"><strong>3.73.</strong> panic_unwind</a></li><li><a href="library-features/pattern.html"><strong>3.74.</strong> pattern</a></li><li><a href="library-features/placement-in.html"><strong>3.75.</strong> placement_in</a></li><li><a href="library-features/placement-new-protocol.html"><strong>3.76.</strong> placement_new_protocol</a></li><li><a href="library-features/print-internals.html"><strong>3.77.</strong> print_internals</a></li><li><a href="library-features/proc-macro-internals.html"><strong>3.78.</strong> proc_macro_internals</a></li><li><a href="library-features/question-mark-carrier.html"><strong>3.79.</strong> question_mark_carrier</a></li><li><a href="library-features/rand.html"><strong>3.80.</strong> rand</a></li><li><a href="library-features/range-contains.html"><strong>3.81.</strong> range_contains</a></li><li><a href="library-features/raw.html"><strong>3.82.</strong> raw</a></li><li><a href="library-features/rt.html"><strong>3.83.</strong> rt</a></li><li><a href="library-features/rustc-private.html"><strong>3.84.</strong> rustc_private</a></li><li><a href="library-features/sanitizer-runtime-lib.html"><strong>3.85.</strong> sanitizer_runtime_lib</a></li><li><a href="library-features/set-stdio.html"><strong>3.86.</strong> set_stdio</a></li><li><a href="library-features/shared.html"><strong>3.87.</strong> shared</a></li><li><a href="library-features/sip-hash-13.html"><strong>3.88.</strong> sip_hash_13</a></li><li><a href="library-features/slice-concat-ext.html"><strong>3.89.</strong> slice_concat_ext</a></li><li><a href="library-features/slice-get-slice.html"><strong>3.90.</strong> slice_get_slice</a></li><li><a href="library-features/slice-rotate.html"><strong>3.91.</strong> slice_rotate</a></li><li><a href="library-features/slice-rsplit.html"><strong>3.92.</strong> slice_rsplit</a></li><li><a href="library-features/sort-internals.html"><strong>3.93.</strong> sort_internals</a></li><li><a href="library-features/sort-unstable.html"><strong>3.94.</strong> sort_unstable</a></li><li><a href="library-features/splice.html"><strong>3.95.</strong> splice</a></li><li><a href="library-features/step-by.html"><strong>3.96.</strong> step_by</a></li><li><a href="library-features/step-trait.html"><strong>3.97.</strong> step_trait</a></li><li><a href="library-features/str-checked-slicing.html"><strong>3.98.</strong> str_checked_slicing</a></li><li><a href="library-features/str-escape.html"><strong>3.99.</strong> str_escape</a></li><li><a href="library-features/str-internals.html"><strong>3.100.</strong> str_internals</a></li><li><a href="library-features/str-box-extras.html"><strong>3.101.</strong> str_box_extras</a></li><li><a href="library-features/str-mut-extras.html"><strong>3.102.</strong> str_mut_extras</a></li><li><a href="library-features/test.html"><strong>3.103.</strong> test</a></li><li><a href="library-features/thread-local-internals.html"><strong>3.104.</strong> thread_local_internals</a></li><li><a href="library-features/thread-local-state.html"><strong>3.105.</strong> thread_local_state</a></li><li><a href="library-features/toowned-clone-into.html"><strong>3.106.</strong> toowned_clone_into</a></li><li><a href="library-features/trusted-len.html"><strong>3.107.</strong> trusted_len</a></li><li><a href="library-features/try-from.html"><strong>3.108.</strong> try_from</a></li><li><a href="library-features/try-trait.html"><strong>3.109.</strong> try_trait</a></li><li><a href="library-features/unicode.html"><strong>3.110.</strong> unicode</a></li><li><a href="library-features/unique.html"><strong>3.111.</strong> unique</a></li><li><a href="library-features/unsize.html"><strong>3.112.</strong> unsize</a></li><li><a href="library-features/utf8-error-error-len.html"><strong>3.113.</strong> utf8_error_error_len</a></li><li><a href="library-features/vec-resize-default.html"><strong>3.114.</strong> vec_resize_default</a></li><li><a href="library-features/vec-remove-item.html"><strong>3.115.</strong> vec_remove_item</a></li><li><a href="library-features/windows-c.html"><strong>3.116.</strong> windows_c</a></li><li><a href="library-features/windows-handle.html"><strong>3.117.</strong> windows_handle</a></li><li><a href="library-features/windows-net.html"><strong>3.118.</strong> windows_net</a></li><li><a href="library-features/windows-stdio.html"><strong>3.119.</strong> windows_stdio</a></li></ul></li></ul>
        </div>

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

            <div class="page">
                <div id="menu-bar" class="menu-bar">
                    <div class="left-buttons">
                        <i id="sidebar-toggle" class="fa fa-bars"></i>
                        <i id="theme-toggle" class="fa fa-paint-brush"></i>
                    </div>

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

                    <div class="right-buttons">
                        <i id="print-button" class="fa fa-print" title="Print this book"></i>
                    </div>
                </div>

                <div id="content" class="content">
                    <a class="header" href="language-features/allocator.html#allocator" id="allocator"><h1><code>allocator</code></h1></a>
<p>The tracking issue for this feature is: <a href="https://github.com/rust-lang/rust/issues/27389">#27389</a></p>
<hr />
<p>Sometimes even the choices of jemalloc vs the system allocator aren't enough and
an entirely new custom allocator is required. In this you'll write your own
crate which implements the allocator API (e.g. the same as <code>alloc_system</code> or
<code>alloc_jemalloc</code>). As an example, let's take a look at a simplified and
annotated version of <code>alloc_system</code></p>
<pre><pre class="playpen"><code class="language-rust no_run"># // Only needed for rustdoc --test down below.
# #![feature(lang_items)]
// The compiler needs to be instructed that this crate is an allocator in order
// to realize that when this is linked in another allocator like jemalloc should
// not be linked in.
#![feature(allocator)]
#![allocator]

// Allocators are not allowed to depend on the standard library which in turn
// requires an allocator in order to avoid circular dependencies. This crate,
// however, can use all of libcore.
#![no_std]

// Let's give a unique name to our custom allocator:
#![crate_name = &quot;my_allocator&quot;]
#![crate_type = &quot;rlib&quot;]

// Our system allocator will use the in-tree libc crate for FFI bindings. Note
// that currently the external (crates.io) libc cannot be used because it links
// to the standard library (e.g. `#![no_std]` isn't stable yet), so that's why
// this specifically requires the in-tree version.
#![feature(libc)]
extern crate libc;

// Listed below are the five allocation functions currently required by custom
// allocators. Their signatures and symbol names are not currently typechecked
// by the compiler, but this is a future extension and are required to match
// what is found below.
//
// Note that the standard `malloc` and `realloc` functions do not provide a way
// to communicate alignment so this implementation would need to be improved
// with respect to alignment in that aspect.

#[no_mangle]
pub extern fn __rust_allocate(size: usize, _align: usize) -&gt; *mut u8 {
    unsafe { libc::malloc(size as libc::size_t) as *mut u8 }
}

#[no_mangle]
pub extern fn __rust_allocate_zeroed(size: usize, _align: usize) -&gt; *mut u8 {
    unsafe { libc::calloc(size as libc::size_t, 1) as *mut u8 }
}

#[no_mangle]
pub extern fn __rust_deallocate(ptr: *mut u8, _old_size: usize, _align: usize) {
    unsafe { libc::free(ptr as *mut libc::c_void) }
}

#[no_mangle]
pub extern fn __rust_reallocate(ptr: *mut u8, _old_size: usize, size: usize,
                                _align: usize) -&gt; *mut u8 {
    unsafe {
        libc::realloc(ptr as *mut libc::c_void, size as libc::size_t) as *mut u8
    }
}

#[no_mangle]
pub extern fn __rust_reallocate_inplace(_ptr: *mut u8, old_size: usize,
                                        _size: usize, _align: usize) -&gt; usize {
    old_size // This api is not supported by libc.
}

#[no_mangle]
pub extern fn __rust_usable_size(size: usize, _align: usize) -&gt; usize {
    size
}

# // Only needed to get rustdoc to test this:
# fn main() {}
# #[lang = &quot;panic_fmt&quot;] fn panic_fmt() {}
# #[lang = &quot;eh_personality&quot;] fn eh_personality() {}
# #[lang = &quot;eh_unwind_resume&quot;] extern fn eh_unwind_resume() {}
# #[no_mangle] pub extern fn rust_eh_register_frames () {}
# #[no_mangle] pub extern fn rust_eh_unregister_frames () {}
</code></pre></pre>
<p>After we compile this crate, it can be used as follows:</p>
<pre><code class="language-rust ignore">extern crate my_allocator;

fn main() {
    let a = Box::new(8); // Allocates memory via our custom allocator crate.
    println!(&quot;{}&quot;, a);
}
</code></pre>
<a class="header" href="language-features/allocator.html#custom-allocator-limitations" id="custom-allocator-limitations"><h2>Custom allocator limitations</h2></a>
<p>There are a few restrictions when working with custom allocators which may cause
compiler errors:</p>
<ul>
<li>
<p>Any one artifact may only be linked to at most one allocator. Binaries,
dylibs, and staticlibs must link to exactly one allocator, and if none have
been explicitly chosen the compiler will choose one. On the other hand rlibs
do not need to link to an allocator (but still can).</p>
</li>
<li>
<p>A consumer of an allocator is tagged with <code>#![needs_allocator]</code> (e.g. the
<code>liballoc</code> crate currently) and an <code>#[allocator]</code> crate cannot transitively
depend on a crate which needs an allocator (e.g. circular dependencies are not
allowed). This basically means that allocators must restrict themselves to
libcore currently.</p>
</li>
</ul>

                </div>

                <!-- Mobile navigation buttons -->
                
                    <a href="language-features/advanced-slice-patterns.html" class="mobile-nav-chapters previous">
                        <i class="fa fa-angle-left"></i>
                    </a>
                

                
                    <a href="language-features/allow-internal-unstable.html" class="mobile-nav-chapters next">
                        <i class="fa fa-angle-right"></i>
                    </a>
                

            </div>

            
                <a href="language-features/advanced-slice-patterns.html" class="nav-chapters previous" title="You can navigate through the chapters using the arrow keys">
                    <i class="fa fa-angle-left"></i>
                </a>
            

            
                <a href="language-features/allow-internal-unstable.html" class="nav-chapters next" title="You can navigate through the chapters using the arrow keys">
                    <i class="fa fa-angle-right"></i>
                </a>
            

        </div>


        <!-- Local fallback for Font Awesome -->
        <script>
            if ($(".fa").css("font-family") !== "FontAwesome") {
                $('<link rel="stylesheet" type="text/css" href="_FontAwesome/css/font-awesome.css">').prependTo('head');
            }
        </script>

        <!-- Livereload script (if served using the cli tool) -->
        

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