Skip to content

Commit 2bbb725

Browse files
committed
Make debug impl a display impl
1 parent 81a5356 commit 2bbb725

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use std::fmt;
66
use Dimension;
77

88
/// A multi-dimensional array.
9-
#[derive(PartialEq, Eq, Clone)]
9+
#[derive(Debug, PartialEq, Eq, Clone)]
1010
pub struct Array<T> {
1111
dims: Vec<Dimension>,
1212
data: Vec<T>,
1313
}
1414

15-
impl<T: fmt::Debug> fmt::Debug for Array<T> {
15+
impl<T: fmt::Display> fmt::Display for Array<T> {
1616
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
1717
if self.dims.iter().any(|dim| dim.lower_bound != 1) {
1818
for dim in &self.dims {
@@ -30,9 +30,9 @@ fn fmt_helper<'a, T, I>(depth: usize,
3030
mut data: &mut I,
3131
fmt: &mut fmt::Formatter)
3232
-> fmt::Result
33-
where I: Iterator<Item=&'a T>, T: 'a+fmt::Debug {
33+
where I: Iterator<Item=&'a T>, T: 'a + fmt::Display {
3434
if depth == dims.len() {
35-
return write!(fmt, "{:?}", data.next().unwrap());
35+
return write!(fmt, "{}", data.next().unwrap());
3636
}
3737

3838
try!(write!(fmt, "{{"));

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ mod tests {
120120
}
121121

122122
#[test]
123-
fn test_debug() {
123+
fn test_display() {
124124
let a = Array::from_vec(vec![0i32, 1, 2, 3, 4], 1);
125-
assert_eq!("{0,1,2,3,4}", &format!("{:?}", a));
125+
assert_eq!("{0,1,2,3,4}", &format!("{}", a));
126126

127127
let a = Array::from_vec(vec![0i32, 1, 2, 3, 4], -3);
128-
assert_eq!("[-3:1]={0,1,2,3,4}", &format!("{:?}", a));
128+
assert_eq!("[-3:1]={0,1,2,3,4}", &format!("{}", a));
129129

130130
let mut a = Array::from_vec(vec![1i32, 2, 3], 3);
131131
a.wrap(-2);
132132
a.push(Array::from_vec(vec![4, 5, 6], 3));
133133
a.wrap(1);
134-
assert_eq!("[1:1][-2:-1][3:5]={{{1,2,3},{4,5,6}}}", &format!("{:?}", a));
134+
assert_eq!("[1:1][-2:-1][3:5]={{{1,2,3},{4,5,6}}}", &format!("{}", a));
135135
}
136136
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy