Skip to main content

NumberFormat

Struct NumberFormat 

Source
pub struct NumberFormat { /* private fields */ }
Expand description

A declared number-format code without dense allocation from its numeric ID.

Implementations§

Source§

impl NumberFormat

Source

pub fn new(id: u32, code: impl Into<Box<str>>) -> NumberFormat

Retain the literal code and its allocation-free canonical classification.

Source

pub fn id(&self) -> u32

Source identity, including custom declarations overriding built-ins.

Source

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}
Source

pub fn date_kind(&self) -> Option<DateKind>

Cached date/duration classification of the literal code.

Source

pub fn set_code(&mut self, code: impl Into<Box<str>>)

Replace the code while keeping its classification consistent.

Trait Implementations§

Source§

impl Clone for NumberFormat

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Debug for NumberFormat

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for NumberFormat

Source§

impl PartialEq for NumberFormat

Source§

fn eq(&self, other: &NumberFormat) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for NumberFormat

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.