File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -400,9 +400,13 @@ pub enum ErrorKind {
400
400
}
401
401
402
402
impl Error {
403
- #[ cfg( feature = "alloc" ) ]
404
- pub fn extra ( & mut self , message : String ) {
405
- self . extra = message;
403
+ /// Writes to the `extra` field. Does nothing if the "alloc" feature is not enabled.
404
+ pub fn write_fmt ( & mut self , fmt : core:: fmt:: Arguments < ' _ > ) {
405
+ #[ cfg( feature = "alloc" ) ]
406
+ {
407
+ use core:: fmt:: Write ;
408
+ let _ = self . extra . write_fmt ( fmt) ;
409
+ }
406
410
}
407
411
408
412
#[ cfg( feature = "alloc" ) ]
Original file line number Diff line number Diff line change 1
1
//! Convenience wrappers of the datatypes defined in schema.capnp.
2
2
3
- #[ cfg( feature = "alloc" ) ]
4
- use alloc:: string:: ToString ;
5
-
6
3
use crate :: dynamic_value;
7
4
use crate :: introspect:: { self , RawBrandedStructSchema , RawEnumSchema } ;
8
5
use crate :: private:: layout;
@@ -76,8 +73,7 @@ impl StructSchema {
76
73
// error needs to be mutable only when the alloc feature is enabled
77
74
#[ allow( unused_mut) ]
78
75
let mut error = crate :: Error :: from_kind ( crate :: ErrorKind :: FieldNotFound ) ;
79
- #[ cfg( feature = "alloc" ) ]
80
- error. extra ( name. to_string ( ) ) ;
76
+ write ! ( error, "{}" , name) ;
81
77
Err ( error)
82
78
}
83
79
}
You can’t perform that action at this time.
0 commit comments