mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-11 04:18:39 +08:00
rust: kernel: str: Implement Debug for CString
Make it possible to use a `CString` with the `pr_*` macros directly. That is, instead of: pr_debug!("trying to open {:?}\n", &*filename); we can now write: pr_debug!("trying to open {:?}\n", filename); Signed-off-by: Asahi Lina <lina@asahilina.net> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com> Link: https://lore.kernel.org/r/20230714-cstring-debug-v1-1-4e7c3018dd4f@asahilina.net [ Reworded to use Alice's commit message as discussed. ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
a39b6ac378
commit
c3f41b0030
@ -608,6 +608,12 @@ impl<'a> TryFrom<&'a CStr> for CString {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for CString {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Debug::fmt(&**self, f)
|
||||
}
|
||||
}
|
||||
|
||||
/// A convenience alias for [`core::format_args`].
|
||||
#[macro_export]
|
||||
macro_rules! fmt {
|
||||
|
Loading…
Reference in New Issue
Block a user