@@ -22,6 +22,7 @@ type Metagrid = Grid<Grid>;
22
22
pub struct GridFmtParams {
23
23
pub boxed : bool ,
24
24
pub label : bool ,
25
+ pub depth : usize ,
25
26
}
26
27
27
28
pub trait GridFmt {
@@ -165,6 +166,9 @@ impl GridFmt for Complex {
165
166
166
167
impl GridFmt for Value {
167
168
fn fmt_grid ( & self , params : GridFmtParams ) -> Grid {
169
+ if params. depth > 100 {
170
+ return vec ! [ "…" . to_string( ) . chars( ) . collect( ) ] ;
171
+ }
168
172
if self . meta ( ) . flags . contains ( ArrayFlags :: SEED ) && self . rank ( ) == 0 {
169
173
if let Value :: Num ( arr) = self {
170
174
let seed = arr. data [ 0 ] . to_bits ( ) ;
@@ -186,6 +190,7 @@ impl GridFmt for Value {
186
190
for Boxed ( val) in & b. data {
187
191
let grid = val. fmt_grid ( GridFmtParams {
188
192
boxed : false ,
193
+ depth : params. depth + 1 ,
189
194
..params
190
195
} ) ;
191
196
if grid. len ( ) == 1 {
@@ -214,8 +219,11 @@ impl GridFmt for Value {
214
219
Value :: Num ( n) => n. fmt_grid ( params) ,
215
220
Value :: Byte ( b) => b. fmt_grid ( params) ,
216
221
Value :: Complex ( c) => c. fmt_grid ( params) ,
217
- Value :: Box ( v) => v. fmt_grid ( params) ,
218
222
Value :: Char ( c) => c. fmt_grid ( params) ,
223
+ Value :: Box ( v) => v. fmt_grid ( GridFmtParams {
224
+ depth : params. depth + 1 ,
225
+ ..params
226
+ } ) ,
219
227
}
220
228
}
221
229
}
0 commit comments