Skip to content

Commit 00c3056

Browse files
jkosh44benesch
authored andcommitted
Fix display for 0 dimensional arrays
1 parent fd0cac7 commit 00c3056

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎src/array.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ where
3939
I:Iterator<Item = &'aT>,
4040
T:'a + fmt::Display,
4141
{
42+
if dims.len() == 0{
43+
returnwrite!(fmt,"{{}}");
44+
}
45+
4246
if depth == dims.len(){
4347
returnwrite!(fmt,"{}", data.next().unwrap());
4448
}

‎src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,8 @@ mod tests{
146146
a.push(Array::from_vec(vec![4,5,6],3));
147147
a.wrap(1);
148148
assert_eq!("[1:1][-2:-1][3:5]={{{1,2,3},{4,5,6}}}",&format!("{}", a));
149+
150+
let a:Array<String> = Array::from_parts(vec![],vec![]);
151+
assert_eq!("{}",&format!("{}", a));
149152
}
150153
}

0 commit comments

Comments
(0)