Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: rust: Add error handling sections

Add error handling sections to the documentation and use it
to link to the existing code documentation. This will allow
to extend that documentation, use intra-doc links and test
the examples.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://lore.kernel.org/rust-for-linux/CANiq72keOdXy0LFKk9SzYWwSjiD710v=hQO4xi+5E4xNALa6cA@mail.gmail.com/
Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Link: https://lore.kernel.org/r/20250115062552.1970768-1-dirk.behme@de.bosch.com
[ Slightly tweaked wording. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Dirk Behme and committed by
Miguel Ojeda
562cc3cd 52ae96f5

+15
+8
Documentation/rust/coding-guidelines.rst
··· 373 373 For more information about diagnostics in Rust, please see: 374 374 375 375 https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html 376 + 377 + Error handling 378 + -------------- 379 + 380 + For some background and guidelines about Rust for Linux specific error handling, 381 + please see: 382 + 383 + https://rust.docs.kernel.org/kernel/error/type.Result.html#error-codes-in-c-and-rust
+7
Documentation/rust/testing.rst
··· 123 123 Thus, we presently simply print an error to the kernel log if an assertion 124 124 actually failed. Additionally, doctests are not run for nonpublic functions. 125 125 126 + Since these tests are examples, i.e. they are part of the documentation, they 127 + should generally be written like "real code". Thus, for example, instead of 128 + using ``unwrap()`` or ``expect()``, use the ``?`` operator. For more background, 129 + please see: 130 + 131 + https://rust.docs.kernel.org/kernel/error/type.Result.html#error-codes-in-c-and-rust 132 + 126 133 The ``#[test]`` tests 127 134 --------------------- 128 135