pub struct NumberFormat { /* private fields */ }Expand description
A declared number-format code without dense allocation from its numeric ID.
Implementations§
Source§impl NumberFormat
impl NumberFormat
Sourcepub fn new(id: u32, code: impl Into<Box<str>>) -> NumberFormat
pub fn new(id: u32, code: impl Into<Box<str>>) -> NumberFormat
Retain the literal code and its allocation-free canonical classification.
Sourcepub fn code(&self) -> &str
pub fn code(&self) -> &str
Borrow the original format spelling.
Examples found in repository?
examples/style_domain_probe.rs (line 18)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let path = std::env::args().nth(1).ok_or("Missing fixture path")?;
5 let mut book = WorkbookReader::new(std::fs::File::open(path)?)?;
6 let catalog = book.style_catalog()?.ok_or("Missing styles")?;
7 for size in [-1.0, 410.0, 1_000_000.0] {
8 if !catalog.fonts.iter().any(|font| font.size == Some(size)) {
9 return Err("Missing finite font size".into());
10 }
11 }
12 if !catalog.fills.iter().any(|fill| matches!(fill, Fill::Gradient(g) if g.edges[0] == Some(-1.0) && g.edges[1] == Some(2.0))) {
13 return Err("Missing gradient edges".into());
14 }
15 if !catalog
16 .number_formats
17 .iter()
18 .any(|format| format.code().is_empty())
19 {
20 return Err("Missing empty number format".into());
21 }
22 if !catalog.fonts.iter().any(|font| {
23 font.color
24 .as_ref()
25 .is_some_and(|color| color.kind == ColorKind::Indexed(3.into()))
26 }) {
27 return Err("Missing selected indexed color".into());
28 }
29 if let Some(output) = std::env::args().nth(2) {
30 let sheet = book.read_sheet("Sheet")?;
31 let catalog = book.into_style_catalog()?.ok_or("Missing styles")?;
32 let mut writer = WorkbookWriter::from_style_catalog(WriteOptions::default(), catalog)?;
33 writer.start_sheet("Sheet")?;
34 for row in &sheet.rows {
35 writer.write_row(row)?;
36 }
37 writer.finish(std::fs::File::create(output)?)?;
38 }
39 println!("finite-style-domains-ok");
40 Ok(())
41}Trait Implementations§
Source§impl Clone for NumberFormat
impl Clone for NumberFormat
Source§fn clone(&self) -> NumberFormat
fn clone(&self) -> NumberFormat
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NumberFormat
impl Debug for NumberFormat
impl Eq for NumberFormat
Source§impl PartialEq for NumberFormat
impl PartialEq for NumberFormat
impl StructuralPartialEq for NumberFormat
Auto Trait Implementations§
impl Freeze for NumberFormat
impl RefUnwindSafe for NumberFormat
impl Send for NumberFormat
impl Sync for NumberFormat
impl Unpin for NumberFormat
impl UnsafeUnpin for NumberFormat
impl UnwindSafe for NumberFormat
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.