/rust/registry/src/index.crates.io-1949cf8c6b5b557f/ndarray-0.17.2/src/layout/layoutfmt.rs
Line | Count | Source |
1 | | // Copyright 2017 bluss and ndarray developers. |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
4 | | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
5 | | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
6 | | // option. This file may not be copied, modified, or distributed |
7 | | // except according to those terms. |
8 | | |
9 | | use super::Layout; |
10 | | |
11 | | const LAYOUT_NAMES: &[&str] = &["C", "F", "c", "f"]; |
12 | | |
13 | | use std::fmt; |
14 | | |
15 | | impl fmt::Debug for Layout |
16 | | { |
17 | 0 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result |
18 | | { |
19 | 0 | if self.0 == 0 { |
20 | 0 | write!(f, "Custom")? |
21 | | } else { |
22 | 0 | (0..32).filter(|&i| self.is(1 << i)).try_fold((), |_, i| { |
23 | 0 | if let Some(name) = LAYOUT_NAMES.get(i) { |
24 | 0 | write!(f, "{}", name) |
25 | | } else { |
26 | 0 | write!(f, "{:#x}", i) |
27 | | } |
28 | 0 | })?; |
29 | | }; |
30 | 0 | write!(f, " ({:#x})", self.0) |
31 | 0 | } |
32 | | } |