8000 Custom dim4 Debug trait impl for simpler output · arrayfire/arrayfire-rust@df79646 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit df79646

Browse files
committed
Custom dim4 Debug trait impl for simpler output
1 parent 0221320 commit df79646

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/core/dim4.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::ops::{Index, IndexMut};
55
use serde::{Deserialize, Serialize};
66

77
/// Dim4 is used to store [Array](./struct.Array.html) dimensions
8-
#[derive(Copy, Clone, PartialEq, Debug)]
8+
#[derive(Copy, Clone, PartialEq)]
99
#[cfg_attr(feature = "afserde", derive(Serialize, Deserialize))]
1010
pub struct Dim4 {
1111
dims: [u64; 4],
@@ -76,6 +76,26 @@ impl fmt::Display for Dim4 {
7676
}
7777
}
7878

79+
/// Debug trait implementation for Dim4 objects
80+
///
81+
/// # Examples
82+
///
83+
/// ```rust
84+
/// use arrayfire::Dim4;
85+
///
86+
/// let dims = Dim4::new(&[4, 4, 2, 1]);
87+
/// println!("Shape is {:?}", dims); // -> {4, 4, 2, 1}
88+
/// ```
89+
impl fmt::Debug for Dim4 {
90+
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
91+
write!(
92+
f,
93+
"[{}, {}, {}, {}]",
94+
self.dims[0], self.dims[1], self.dims[2], self.dims[3]
95+
)
96+
}
97+
}
98+
7999
impl Dim4 {
80100
/// Create Dim4 object
81101
///

0 commit comments

Comments
 (0)
0