linux/rust
Nakamura Shuta bf074eb689 rust: str: improve safety comment for CString::try_from_fmt
Improve the safety comment for the `inc_len()` call in
`CString::try_from_fmt()` to clarify why `bytes_written()` is
guaranteed not to exceed the buffer capacity.

The current comment states that bytes written is bounded by size,
but does not explain that this invariant is maintained because:
1. The `Formatter` is created with `size` as its capacity limit
2. The `?` operators on `write_fmt` and `write_str` ensure early
   return if writing exceeds this limit

Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/20221114145329.0f47a3ab@GaryWorkstation/
Link: https://github.com/Rust-for-Linux/linux/issues/936
Signed-off-by: Nakamura Shuta <nakamura.shuta@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260119062925.1647-1-nakamura.shuta@gmail.com
[ Updated tags: it was a suggestion from Gary from the mailing list
  (the linked issue is mostly about adding a `debug_assert_eq!`).
    - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-03-23 00:08:55 +01:00
..
bindings Char/Misc/IIO driver changes for 7.0-rc1 2026-02-17 09:11:04 -08:00
helpers rust: jump_label: add __rust_helper to helpers 2026-03-10 11:29:16 +01:00
kernel rust: str: improve safety comment for CString::try_from_fmt 2026-03-23 00:08:55 +01:00
macros Rust changes for v6.20 / v7.0 2026-02-10 11:53:01 -08:00
pin-init Rust fixes for v7.0-rc1 2026-02-22 08:43:31 -08:00
proc-macro2
quote
syn
uapi
.gitignore
.kunitconfig
Makefile Rust fixes for v7.0-rc1 2026-02-22 08:43:31 -08:00
bindgen_parameters
build_error.rs
compiler_builtins.rs
exports.c
ffi.rs