@@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize};
28
28
#[ cfg_attr( feature = "serde" , derive( Deserialize , Serialize ) ) ]
29
29
pub struct Backtrace {
30
30
// Frames here are listed from top-to-bottom of the stack
31
- frames : Vec < BacktraceFrame > ,
31
+ frames : Box < [ BacktraceFrame ] > ,
32
32
}
33
33
34
34
#[ derive( Clone , Copy ) ]
@@ -143,7 +143,7 @@ fn _assert_send_sync() {
143
143
#[ derive( Clone ) ]
144
144
pub struct BacktraceFrame {
145
145
frame : Frame ,
146
- symbols : Option < Vec < BacktraceSymbol > > ,
146
+ symbols : Option < Box < [ BacktraceSymbol ] > > ,
147
147
}
148
148
149
149
#[ derive( Clone ) ]
@@ -186,11 +186,11 @@ impl Frame {
186
186
}
187
187
188
188
/// Resolve all addresses in the frame to their symbolic names.
189
- fn resolve_symbols ( & self ) -> Vec < BacktraceSymbol > {
189
+ fn resolve_symbols ( & self ) -> Box < [ BacktraceSymbol ] > {
190
190
let mut symbols = Vec :: new ( ) ;
191
191
let sym = |symbol : & Symbol | {
192
192
symbols. push ( BacktraceSymbol {
193
- name : symbol. name ( ) . map ( |m| m. as_bytes ( ) . to_vec ( ) ) ,
193
+ name : symbol. name ( ) . map ( |m| m. as_bytes ( ) . into ( ) ) ,
194
194
addr : symbol. addr ( ) . map ( TracePtr ) ,
195
195
filename : symbol. filename ( ) . map ( |m| m. to_owned ( ) ) ,
196
196
lineno : symbol. lineno ( ) ,
@@ -204,7 +204,7 @@ impl Frame {
204
204
resolve ( ip. into_void ( ) , sym) ;
205
205
}
206
206
}
207
- symbols
207
+ symbols. into_boxed_slice ( )
208
208
}
209
209
}
210
210
@@ -220,7 +220,7 @@ impl Frame {
220
220
#[ derive( Clone ) ]
221
221
#[ cfg_attr( feature = "serde" , derive( Deserialize , Serialize ) ) ]
222
222
pub struct BacktraceSymbol {
223
- name : Option < Vec < u8 > > ,
223
+ name : Option < Box < [ u8 ] > > ,
224
224
addr : Option < TracePtr > ,
225
225
filename : Option < PathBuf > ,
226
226
lineno : Option < u32 > ,
@@ -306,7 +306,9 @@ impl Backtrace {
306
306
} ) ;
307
307
frames. shrink_to_fit ( ) ;
308
308
309
- Backtrace { frames }
309
+ Backtrace {
310
+ frames : frames. into_boxed_slice ( ) ,
311
+ }
310
312
}
311
313
312
314
/// Returns the frames from when this backtrace was captured.
@@ -320,7 +322,7 @@ impl Backtrace {
320
322
/// This function requires the `std` feature of the `backtrace` crate to be
321
323
/// enabled, and the `std` feature is enabled by default.
322
324
pub fn frames ( & self ) -> & [ BacktraceFrame ] {
323
- self . frames . as_slice ( )
325
+ self . frames . as_ref ( )
324
326
}
325
327
326
328
/// If this backtrace was created from `new_unresolved` then this function
@@ -340,7 +342,9 @@ impl Backtrace {
340
342
341
343
impl From < Vec < BacktraceFrame > > for Backtrace {
342
344
fn from ( frames : Vec < BacktraceFrame > ) -> Self {
343
- Backtrace { frames }
345
+ Backtrace {
346
+ frames : frames. into_boxed_slice ( ) ,
347
+ }
344
348
}
345
349
}
346
350
@@ -358,7 +362,7 @@ impl From<crate::Frame> for BacktraceFrame {
358
362
// more information on https://github.com/rust-lang/backtrace-rs/pull/526
359
363
impl Into < Vec < BacktraceFrame > > for Backtrace {
360
364
fn into ( self ) -> Vec < BacktraceFrame > {
361
- self . frames
365
+ self . frames . into_vec ( )
362
366
}
363
367
}
364
368
@@ -553,7 +557,7 @@ mod serde_impls {
553
557
ip : usize ,
554
558
symbol_address : usize ,
555
559
module_base_address : Option < usize > ,
556
- symbols : Option < Vec < BacktraceSymbol > > ,
560
+ symbols : Option < Box < [ BacktraceSymbol ] > > ,
557
561
}
558
562
559
563
impl Serialize for BacktraceFrame {
0 commit comments