Debian Codegraph @

debian/rust-vendor/icu_plurals/src/raw_operands.rs

raw
1 // This file is part of ICU4X. For terms of use, please see the file
2 // called LICENSE at the top level of the ICU4X source tree
3 // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5 //! 🚧 \[Unstable\] Data Structures and conversions for directly constructing the plural rule
6 //! operands of a number
7 //!
8 //! <div class="stab unstable">
9 //! 🚧 This code is unstable; it may change at any time, in breaking or non-breaking ways,
10 //! including in SemVer minor releases. Use with caution.
11 //! <a href="https://github.com/unicode-org/icu4x/issues/1091">#1091</a>
12 //! </div>
13
14 use crate::PluralOperands;
15
16 /// 🚧 \[Unstable\] A struct for low-level users who want to construct a [`PluralOperands`]
17 /// directly based on the LDML Plural Operand definitions.
18 ///
19 /// This may be useful
20 /// for people with unstable rules parsing.
21 ///
22 /// This struct is not intended for supported API use, and it is subject to breaking
23 /// changes (ex: a new Plural Operand needs to be supported).
24 ///
25 /// Most users with numerical data inputs for places where [`PluralOperands`] is
26 /// accepted, like [`PluralRules::category_for`](super::PluralRules::category_for), should convert to [`PluralOperands`].
27 /// See [`PluralOperands`] for details.
28 ///
29 /// <div class="stab unstable">
30 /// 🚧 This code is unstable; it may change at any time, in breaking or non-breaking ways,
31 /// including in SemVer minor releases. Use with caution.
32 /// <a href="https://github.com/unicode-org/icu4x/issues/1091">#1091</a>
33 /// </div>
34 #[cfg(feature = "unstable")]
35 #[allow(clippy::exhaustive_structs)] // unstable
36 #[derive(Debug)]
37 pub struct RawPluralOperands {
38 /// Integer value of input
39 pub i: u64,
40 /// Number of visible fraction digits with trailing zeros
41 pub v: usize,
42 /// Number of visible fraction digits without trailing zeros
43 pub w: usize,
44 /// Visible fraction digits with trailing zeros
45 pub f: u64,
46 /// Visible fraction digits without trailing zeros
47 pub t: u64,
48 /// Exponent of the power of 10 used in compact decimal formatting
49 pub c: usize,
50 }
51
52 impl From<RawPluralOperands> for PluralOperands {
53 fn from(rpo: RawPluralOperands) -> PluralOperands {
54 Self {
55 i: rpo.i,
56 v: rpo.v,
57 w: rpo.w,
58 f: rpo.f,
59 t: rpo.t,
60 c: rpo.c,
61 }
62 }
63 }
64
65 impl From<PluralOperands> for RawPluralOperands {
66 fn from(po: PluralOperands) -> RawPluralOperands {
67 Self {
68 i: po.i,
69 v: po.v,
70 w: po.w,
71 f: po.f,
72 t: po.t,
73 c: po.c,
74 }
75 }
76 }