Skip to content

Commit b0af4f9

Browse files
tamirdojeda
authored andcommitted
rust: alloc: use kernel::fmt
Reduce coupling to implementation details of the formatting machinery by avoiding direct use for `core`'s formatting traits and macros. This backslid in commit 9def0d0 ("rust: alloc: add Vec::push_within_capacity"). Reviewed-by: Alice Ryhl <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Signed-off-by: Tamir Duberstein <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent 5cc5d80 commit b0af4f9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

rust/kernel/alloc/kvec/errors.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
//! Errors for the [`Vec`] type.
44
5-
use kernel::fmt::{self, Debug, Formatter};
5+
use kernel::fmt;
66
use kernel::prelude::*;
77

88
/// Error type for [`Vec::push_within_capacity`].
99
pub struct PushError<T>(pub T);
1010

11-
impl<T> Debug for PushError<T> {
12-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
11+
impl<T> fmt::Debug for PushError<T> {
12+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1313
write!(f, "Not enough capacity")
1414
}
1515
}
@@ -25,8 +25,8 @@ impl<T> From<PushError<T>> for Error {
2525
/// Error type for [`Vec::remove`].
2626
pub struct RemoveError;
2727

28-
impl Debug for RemoveError {
29-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
28+
impl fmt::Debug for RemoveError {
29+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
3030
write!(f, "Index out of bounds")
3131
}
3232
}
@@ -45,8 +45,8 @@ pub enum InsertError<T> {
4545
OutOfCapacity(T),
4646
}
4747

48-
impl<T> Debug for InsertError<T> {
49-
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
48+
impl<T> fmt::Debug for InsertError<T> {
49+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
5050
match self {
5151
InsertError::IndexOutOfBounds(_) => write!(f, "Index out of bounds"),
5252
InsertError::OutOfCapacity(_) => write!(f, "Not enough capacity"),

0 commit comments

Comments
 (0)