Skip to content

Commit 2872bf8

Browse files
committed
strings: EqStrUntilNul: better documentation and code comments
1 parent 56a3e50 commit 2872bf8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

uefi/src/data_types/strs.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ impl<StrType: AsRef<str> + ?Sized> EqStrUntilNul<StrType> for CStr8 {
147147
.copied()
148148
.map(char::from)
149149
.zip(other.chars())
150-
// this only works as CStr8 is guaranteed to have a fixed character length
150+
// This only works as CStr8 is guaranteed to have a fixed character length
151+
// (unlike UTF-8).
151152
.take_while(|(l, r)| *l != '\0' && *r != '\0')
152153
.any(|(l, r)| l != r);
153154

@@ -354,7 +355,8 @@ impl<StrType: AsRef<str> + ?Sized> EqStrUntilNul<StrType> for CStr16 {
354355
.copied()
355356
.map(char::from)
356357
.zip(other.chars())
357-
// this only works as CStr16 is guaranteed to have a fixed character length
358+
// This only works as CStr16 is guaranteed to have a fixed character length
359+
// (unlike UTF-8 or UTF-16).
358360
.take_while(|(l, r)| *l != '\0' && *r != '\0')
359361
.any(|(l, r)| l != r);
360362

@@ -419,7 +421,8 @@ impl<'a> UnalignedSlice<'a, u16> {
419421
/// The EqStrUntilNul trait helps to compare Rust strings against UEFI string types (UCS-2 strings).
420422
/// The given generic implementation of this trait enables us that we only have to
421423
/// implement one direction (`left.eq_str_until_nul(&right)`) for each UEFI string type and we
422-
/// get the other direction (`right.eq_str_until_nul(&left)`) for free.
424+
/// get the other direction (`right.eq_str_until_nul(&left)`) for free. Hence, the relation is
425+
/// reflexive.
423426
pub trait EqStrUntilNul<StrType: ?Sized> {
424427
/// Checks if the provided Rust string `StrType` is equal to [Self] until the first null-byte
425428
/// is found. An exception is the terminating null-byte of [Self] which is ignored.

0 commit comments

Comments
 (0)