Skip to content

Commit 181095f

Browse files
authored
Merge pull request #1002 from Concordium/add-bump-alloc
Add bump alloc feature documentation
2 parents 50ae91b + c260287 commit 181095f

File tree

1 file changed

+29
-14
lines changed

1 file changed

+29
-14
lines changed

source/mainnet/smart-contracts/guides/no-std.rst

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,46 +37,54 @@ You can update your `Cargo.toml` file by using:
3737
.. code-block:: rust
3838
3939
[dependencies]
40-
concordium-std = { version = "6.0", default-features = false }
40+
concordium-std = { version = "10.0", default-features = false }
4141
4242
.. note::
4343

4444
To compile your smart contracts, a memory `allocator <https://docs.rs/concordium-std/6.0.0/concordium_std/#use-a-custom-allocator>`_ is used.
4545
``concordium-std`` version ``<6.0.0`` hard-coded the use of the `wee_alloc <https://docs.rs/wee_alloc/>`_ allocator.
46-
In ``concordium-std`` version ``>=6.0.0``, ``wee_alloc`` is a feature and needs to be explicitly enabled.
46+
In ``concordium-std`` version in the range of ``>=6.0.0`` and ``<10.0.0``, ``wee_alloc`` is a feature and needs to be explicitly enabled.
47+
In ``concordium-std`` version ``>=10.0.0``, `bump_alloc <https://docs.rs/concordium-std/10.0.0/concordium_std/#use-a-custom-allocator>`_ is a feature and needs to be explicitly enabled.
4748
When ``std`` feature is enabled, the allocator provided by the Rust standard library is used
48-
by default but when the ``wee_alloc`` feature is enabled in addition, `wee_alloc <https://docs.rs/wee_alloc/>`_ is used instead.
49+
by default but when the ``wee_alloc``/``bump_alloc`` feature is enabled in addition, `bump_alloc <https://docs.rs/concordium-std/10.0.0/concordium_std/#use-a-custom-allocator>`_ ( or `wee_alloc <https://docs.rs/wee_alloc/>`_) is used instead.
4950

50-
You can enable the ``std`` feature and the ``wee_alloc`` feature in ``concordium-std`` version ``>=6.0.0`` by using:
51+
You can enable the ``std`` feature and the ``wee_alloc`` feature in ``concordium-std`` version in the range of ``>=6.0.0`` and ``<10.0.0`` by using:
5152

5253
.. code-block:: rust
5354
5455
[dependencies]
5556
concordium-std = {version = "6.0", features = ["wee_alloc"]}
5657
57-
Alternatively, if you want to test with and without ``wee_alloc`` enabled add a ``wee_alloc`` feature to the smart contract crate as follows:
58+
You can enable the ``std`` feature and the ``bump_alloc`` feature in ``concordium-std`` version ``>=10.0.0`` by using:
59+
60+
.. code-block:: rust
61+
62+
[dependencies]
63+
concordium-std = {version = "10.0", features = ["bump_alloc"]}
64+
65+
Alternatively, if you want to test with and without ``wee_alloc``/``bump_alloc`` enabled add a ``wee_alloc``/``bump_alloc`` feature to the smart contract crate as follows:
5866

5967
.. code-block:: rust
6068
6169
[features]
62-
default = ["std", "wee_alloc"]
70+
default = ["std", "bump_alloc"]
6371
std = ["concordium-std/std"]
64-
wee_alloc = ["concordium-std/wee_alloc"]
72+
bump_alloc = ["concordium-std/bump_alloc"]
6573
66-
The above code blocks will use the `wee_alloc <https://docs.rs/wee_alloc/>`_ allocator and not the allocator
74+
The above code blocks will use the `bump_alloc <https://docs.rs/concordium-std/10.0.0/concordium_std/#use-a-custom-allocator>`_ allocator and not the allocator
6775
provided by the Rust standard library when compiled with the default features as follows:
6876

6977
.. code-block:: console
7078
7179
$cargo concordium build
7280
73-
When ``no_std`` is used either ``wee_alloc`` must be enabled, or another global allocator
74-
must be set in the smart contract. You can add the ``wee_alloc`` feature by using:
81+
When ``no_std`` is used either ``wee_alloc``/``bump_alloc`` must be enabled, or another global allocator
82+
must be set in the smart contract. You can add the ``wee_alloc``/``bump_alloc`` feature by using e.g.:
7583

7684
.. code-block:: rust
7785
7886
[features]
79-
wee_alloc = ["concordium-std/wee_alloc"]
87+
bump_alloc = ["concordium-std/bump_alloc"]
8088
8189
To be able to toggle between with and without std, also add a ``std`` to your
8290
own module, which enables the ``std`` feature of ``concordium-std``:
@@ -104,12 +112,19 @@ you can pass extra arguments for ``cargo``:
104112

105113
.. code-block:: console
106114
107-
$cargo +nightly concordium build -- --no-default-features --features wee_alloc
115+
$cargo +nightly concordium build -- --no-default-features --features bump_alloc
108116
109117
.. note::
110118

111-
The above command works with ``concordium-std`` version ``>=6.0.0``, because the
112-
``wee_alloc`` feature needs to be explicitly enabled.
119+
The above command works with ``concordium-std`` version ``>=10.0.0``, because the
120+
``bump_alloc`` feature needs to be explicitly enabled.
121+
122+
If you use ``concordium-std`` version in the range of ``>=6.0.0`` and ``<10.0.0`` use the following instead:
123+
124+
.. code-block:: console
125+
126+
$cargo +nightly concordium build -- --no-default-features --features wee_alloc
127+
113128
If you use ``concordium-std`` version ``<6.0.0`` use the following instead:
114129

115130
.. code-block:: console

0 commit comments

Comments
 (0)