@@ -28,7 +28,7 @@ use serde::{Deserialize, Serialize};
2828#[ cfg_attr( feature = "serde" , derive( Deserialize , Serialize ) ) ]
2929pub struct Backtrace {
3030 // Frames here are listed from top-to-bottom of the stack
31- frames : Vec < BacktraceFrame > ,
31+ frames : Box < [ BacktraceFrame ] > ,
3232}
3333
3434#[ derive( Clone , Copy ) ]
@@ -143,7 +143,7 @@ fn _assert_send_sync() {
143143#[ derive( Clone ) ]
144144pub struct BacktraceFrame {
145145 frame : Frame ,
146- symbols : Option < Vec < BacktraceSymbol > > ,
146+ symbols : Option < Box < [ BacktraceSymbol ] > > ,
147147}
148148
149149#[ derive( Clone ) ]
@@ -186,11 +186,11 @@ impl Frame {
186186 }
187187
188188 /// Resolve all addresses in the frame to their symbolic names.
189- fn resolve_symbols ( & self ) -> Vec < BacktraceSymbol > {
189+ fn resolve_symbols ( & self ) -> Box < [ BacktraceSymbol ] > {
190190 let mut symbols = Vec :: new ( ) ;
191191 let sym = |symbol : & Symbol | {
192192 symbols. push ( BacktraceSymbol {
193- name : symbol. name ( ) . map ( |m| m. as_bytes ( ) . to_vec ( ) ) ,
193+ name : symbol. name ( ) . map ( |m| m. as_bytes ( ) . into ( ) ) ,
194194 addr : symbol. addr ( ) . map ( TracePtr ) ,
195195 filename : symbol. filename ( ) . map ( |m| m. to_owned ( ) ) ,
196196 lineno : symbol. lineno ( ) ,
@@ -204,7 +204,7 @@ impl Frame {
204204 resolve ( ip. into_void ( ) , sym) ;
205205 }
206206 }
207- symbols
207+ symbols. into_boxed_slice ( )
208208 }
209209}
210210
@@ -220,7 +220,7 @@ impl Frame {
220220#[ derive( Clone ) ]
221221#[ cfg_attr( feature = "serde" , derive( Deserialize , Serialize ) ) ]
222222pub struct BacktraceSymbol {
223- name : Option < Vec < u8 > > ,
223+ name : Option < Box < [ u8 ] > > ,
224224 addr : Option < TracePtr > ,
225225 filename : Option < PathBuf > ,
226226 lineno : Option < u32 > ,
@@ -306,7 +306,9 @@ impl Backtrace {
306306 } ) ;
307307 frames. shrink_to_fit ( ) ;
308308
309- Backtrace { frames }
309+ Backtrace {
310+ frames : frames. into_boxed_slice ( ) ,
311+ }
310312 }
311313
312314 /// Returns the frames from when this backtrace was captured.
@@ -320,7 +322,7 @@ impl Backtrace {
320322 /// This function requires the `std` feature of the `backtrace` crate to be
321323 /// enabled, and the `std` feature is enabled by default.
322324 pub fn frames ( & self ) -> & [ BacktraceFrame ] {
323- self . frames . as_slice ( )
325+ self . frames . as_ref ( )
324326 }
325327
326328 /// If this backtrace was created from `new_unresolved` then this function
@@ -340,7 +342,9 @@ impl Backtrace {
340342
341343impl From < Vec < BacktraceFrame > > for Backtrace {
342344 fn from ( frames : Vec < BacktraceFrame > ) -> Self {
343- Backtrace { frames }
345+ Backtrace {
346+ frames : frames. into_boxed_slice ( ) ,
347+ }
344348 }
345349}
346350
@@ -358,7 +362,7 @@ impl From<crate::Frame> for BacktraceFrame {
358362// more information on https://github.com/rust-lang/backtrace-rs/pull/526
359363impl Into < Vec < BacktraceFrame > > for Backtrace {
360364 fn into ( self ) -> Vec < BacktraceFrame > {
361- self . frames
365+ self . frames . into_vec ( )
362366 }
363367}
364368
@@ -553,7 +557,7 @@ mod serde_impls {
553557 ip : usize ,
554558 symbol_address : usize ,
555559 module_base_address : Option < usize > ,
556- symbols : Option < Vec < BacktraceSymbol > > ,
560+ symbols : Option < Box < [ BacktraceSymbol ] > > ,
557561 }
558562
559563 impl Serialize for BacktraceFrame {
0 commit comments