Skip to content

Commit efd15c8

Browse files
committed
doc: languagues: rust: Reformat
Refill the text to 100 columns instead of 72 to match the rest of the project. Signed-off-by: David Brown <[email protected]>
1 parent 63097df commit efd15c8

File tree

1 file changed

+45
-60
lines changed

1 file changed

+45
-60
lines changed

doc/develop/languages/rust/index.rst

Lines changed: 45 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,25 @@
33
Rust Language Support
44
#####################
55

6-
Rust is a systems programming language focused on safety, speed, and
7-
concurrency. Designed to prevent common programming errors such as
8-
null pointer dereferencing and buffer overflows, Rust emphasizes
9-
memory safety without sacrificing performance. Its powerful type
10-
system and ownership model ensure thread-safe programming, making it
11-
an ideal choice for developing reliable and efficient low-level code.
12-
Rust's expressive syntax and modern features make it a robust
13-
alternative for developers working on embedded systems, operating
14-
systems, and other performance-critical applications.
6+
Rust is a systems programming language focused on safety, speed, and concurrency. Designed to
7+
prevent common programming errors such as null pointer dereferencing and buffer overflows, Rust
8+
emphasizes memory safety without sacrificing performance. Its powerful type system and ownership
9+
model ensure thread-safe programming, making it an ideal choice for developing reliable and
10+
efficient low-level code. Rust's expressive syntax and modern features make it a robust alternative
11+
for developers working on embedded systems, operating systems, and other performance-critical
12+
applications.
1513

1614
Enabling Rust Support
1715
*********************
1816

19-
Currently, Zephyr supports applications written in Rust and C. The
20-
enable Rust support, you must select the :kconfig:option:`CONFIG_RUST`
21-
in the application configuration file.
17+
Currently, Zephyr supports applications written in Rust and C. The enable Rust support, you must
18+
select the :kconfig:option:`CONFIG_RUST` in the application configuration file.
2219

23-
The rust toolchain is separate from the rest of the Zephyr SDK. It
24-
is recommended to use the `rustup`_ tool to install the rust
25-
toolchain. In addition to the base compiler, you will need to install
26-
core libraries for the target(s) you wish to compile on. It is
27-
easiest to determine what needs to be installed by trying a build.
28-
The diagnostics from the rust compilation will indicate the rust
29-
command needed to install the appropriate target support:
20+
The rust toolchain is separate from the rest of the Zephyr SDK. It is recommended to use the
21+
`rustup`_ tool to install the rust toolchain. In addition to the base compiler, you will need to
22+
install core libraries for the target(s) you wish to compile on. It is easiest to determine what
23+
needs to be installed by trying a build. The diagnostics from the rust compilation will indicate
24+
the rust command needed to install the appropriate target support:
3025

3126
.. _rustup: https://rustup.rs/
3227

@@ -39,10 +34,9 @@ command needed to install the appropriate target support:
3934
= note: the `thumbv7m-none-eabi` target may not be installed
4035
= help: consider downloading the target with `rustup target add thumb7m-none-eabi`
4136
42-
In this case, the given ``rustup`` command will install the needed
43-
target support. The target needed will depend on both the board
44-
selected, as well as certain configuration choices (such as whether
45-
floating point is enabled).
37+
In this case, the given ``rustup`` command will install the needed target support. The target
38+
needed will depend on both the board selected, as well as certain configuration choices (such as
39+
whether floating point is enabled).
4640

4741
Writing a Rust Application
4842
**************************
@@ -52,8 +46,7 @@ See :zephyr_file:`samples/rust` for examples of an application.
5246
CMake files
5347
-----------
5448

55-
The application should contain a :file:`CMakeFiles.txt`, similar to
56-
the following:
49+
The application should contain a :file:`CMakeFiles.txt`, similar to the following:
5750

5851
.. code-block:: cmake
5952
@@ -67,22 +60,20 @@ the following:
6760
Cargo files
6861
-----------
6962

70-
Rust applications are built with Cargo. The Zephyr build system will
71-
configure and invoke cargo in your application directory, with options
72-
set so that it can find the Zephyr support libraries, and that the
73-
output will be contained within the Zephyr build directory.
63+
Rust applications are built with Cargo. The Zephyr build system will configure and invoke cargo in
64+
your application directory, with options set so that it can find the Zephyr support libraries, and
65+
that the output will be contained within the Zephyr build directory.
7466

75-
The :file:`Cargo.toml` will need to have a ``[lib]`` section that sets
76-
``crate-type = ["staticlib"]``, and will need to include ``zephyr =
77-
"0.1.0"`` as a dependency. You can use crates.io and the Crate
78-
ecosystem to include any other dependencies you need. Just make sure
79-
that you use crates that support building with no-std.
67+
The :file:`Cargo.toml` will need to have a ``[lib]`` section that sets ``crate-type =
68+
["staticlib"]``, and will need to include ``zephyr = "0.1.0"`` as a dependency. You can use
69+
crates.io and the Crate ecosystem to include any other dependencies you need. Just make sure that
70+
you use crates that support building with no-std.
8071

8172
Application
8273
-----------
8374

84-
The application source itself should live in file:`src/lib.rs`. A few
85-
things are needed. A minimal file would be:
75+
The application source itself should live in file:`src/lib.rs`. A few things are needed. A minimal
76+
file would be:
8677

8778
.. code-block:: rust
8879
@@ -94,30 +85,25 @@ things are needed. A minimal file would be:
9485
extern "C" fn rust_main() {
9586
}
9687
97-
The ``no_std`` declaration is needed to prevent the code from
98-
referencing the ``std`` library. The extern reference will cause the
99-
zephyr crate to be brought in, even if nothing from it is used.
100-
Practically, any meaningful Rust application on Zephyr will use
101-
something from this crate, and this line is not necessary. Lastly,
102-
the main declaration exports the main symbol so that it can be called
103-
by C code. The build ``rust_cargo_application()`` cmake function will
104-
include a small C file that will call into this from the C main
105-
function.
88+
The ``no_std`` declaration is needed to prevent the code from referencing the ``std`` library. The
89+
extern reference will cause the zephyr crate to be brought in, even if nothing from it is used.
90+
Practically, any meaningful Rust application on Zephyr will use something from this crate, and this
91+
line is not necessary. Lastly, the main declaration exports the main symbol so that it can be
92+
called by C code. The build ``rust_cargo_application()`` cmake function will include a small C file
93+
that will call into this from the C main function.
10694

10795
Zephyr Functionality
10896
********************
10997

110-
The bindings to Zephyr for Rust are under development, and are
111-
currently rather minimalistic.
98+
The bindings to Zephyr for Rust are under development, and are currently rather minimalistic.
11299

113100
Bool Kconfig settings
114101
---------------------
115102

116-
Boolean Kconfig settings can be used from within Rust code. Due to
117-
design constraints by the Rust language, settings that affect
118-
compilation must be determined before the build is made. In order to
119-
use this in your application, you will need to use the
120-
``zephyr-build`` crate, provided, to make these symbols available.
103+
Boolean Kconfig settings can be used from within Rust code. Due to design constraints by the Rust
104+
language, settings that affect compilation must be determined before the build is made. In order to
105+
use this in your application, you will need to use the ``zephyr-build`` crate, provided, to make
106+
these symbols available.
121107

122108
To your ``Cargo.toml`` file, add the following:
123109

@@ -126,17 +112,16 @@ To your ``Cargo.toml`` file, add the following:
126112
[build-dependencies]
127113
zephyr-build = "0.1.0"
128114
129-
Then, you will need a ``build.rs`` file to call the support function.
130-
The following will work:
115+
Then, you will need a ``build.rs`` file to call the support function. The following will work:
131116

132117
.. code-block:: rust
133118
134119
fn main() {
135120
zephyr_build::export_bool_kconfig();
136121
}
137122
138-
At this point, it will be possible to use the ``cfg`` directive in
139-
Rust on boolean Kconfig values. For example:
123+
At this point, it will be possible to use the ``cfg`` directive in Rust on boolean Kconfig values.
124+
For example:
140125

141126
.. code-block:: rust
142127
@@ -149,8 +134,8 @@ Rust on boolean Kconfig values. For example:
149134
Other Kconfig settings
150135
----------------------
151136

152-
All bool, numeric and string Kconfig settings are accessible from the
153-
``zephyr::kconfig`` module. For example:
137+
All bool, numeric and string Kconfig settings are accessible from the ``zephyr::kconfig`` module.
138+
For example:
154139

155140
.. code-block:: rust
156141
@@ -159,5 +144,5 @@ All bool, numeric and string Kconfig settings are accessible from the
159144
Other functionality
160145
-------------------
161146

162-
Access to other functionality within zephyr is a work-in-progress, and
163-
this document will be updated as that is done.
147+
Access to other functionality within zephyr is a work-in-progress, and this document will be updated
148+
as that is done.

0 commit comments

Comments
 (0)