forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 475
Closed
Labels
good first issueGood for newcomersGood for newcomers• libRelated to the `rust/` library.Related to the `rust/` library.
Description
In addition to #532, it would be nice to implement Display
for CStr
and BStr
.
Be careful to avoid panicking if invalid UTF-8 is found (i.e. do not attempt to convert it into a &str
). We could escape all non-printable ASCII bytes to avoid losing data (e.g. \x01
). Another way (but lossy) is using a replacement character (e.g. the Unicode one).
Unit-testing is a plus!
[If there was a Display
-like trait that would work for non-UTF-8, we could leave the escaping to Debug
and just submit the bytes as-is for Display
like printk()
does for %s
. But do we actually want this anyway? I don't know about a use case; in printk
it is done like this because it is how printf
works, I assume, and because we use macros to prefix the level etc.]
Metadata
Metadata
Assignees
Labels
good first issueGood for newcomersGood for newcomers• libRelated to the `rust/` library.Related to the `rust/` library.