• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zbraniecki / icu4x / 6815798908

09 Nov 2023 05:17PM UTC coverage: 72.607% (-2.4%) from 75.01%
6815798908

push

github

web-flow
Implement `Any/BufferProvider` for some smart pointers (#4255)

Allows storing them as a `Box<dyn Any/BufferProvider>` without using a
wrapper type that implements the trait.

44281 of 60987 relevant lines covered (72.61%)

201375.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

25.81
/components/datetime/src/skeleton/error.rs
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
use crate::fields;
6
use displaydoc::Display;
7

8
/// These strings follow the recommendations for the serde::de::Unexpected::Other type.
9
/// <https://docs.serde.rs/serde/de/enum.Unexpected.html#variant.Other>
10
///
11
/// Serde will generate an error such as:
12
/// "invalid value: unclosed literal in pattern, expected a valid UTS 35 pattern string at line 1 column 12"
13
#[derive(Display, Debug, Copy, Clone, PartialEq)]
1✔
14
#[non_exhaustive]
15
pub enum SkeletonError {
16
    #[displaydoc("field too long in skeleton")]
17
    InvalidFieldLength,
18
    #[displaydoc("duplicate field in skeleton")]
19
    DuplicateField,
20
    #[displaydoc("symbol unknown {0} in skeleton")]
×
21
    SymbolUnknown(char),
×
22
    #[displaydoc("symbol invalid {0} in skeleton")]
×
23
    SymbolInvalid(u8),
×
24
    #[displaydoc("symbol unimplemented {0} in skeleton")]
×
25
    SymbolUnimplemented(char),
15✔
26
    #[displaydoc("unimplemented field {0} in skeleton")]
×
27
    UnimplementedField(char),
×
28
    #[displaydoc("skeleton has a variant subtag")]
29
    SkeletonHasVariant,
30
    #[displaydoc("{0}")]
×
31
    Fields(fields::Error),
×
32
}
33

34
#[cfg(feature = "std")]
35
impl std::error::Error for SkeletonError {}
36

37
#[cfg(feature = "experimental")]
38
impl From<SkeletonError> for crate::DateTimeError {
39
    fn from(e: SkeletonError) -> Self {
×
40
        crate::DateTimeError::Skeleton(e)
×
41
    }
×
42
}
43

44
impl From<fields::Error> for SkeletonError {
45
    fn from(e: fields::Error) -> Self {
×
46
        SkeletonError::Fields(e)
×
47
    }
×
48
}
49

50
impl From<fields::LengthError> for SkeletonError {
51
    fn from(_: fields::LengthError) -> Self {
×
52
        Self::InvalidFieldLength
×
53
    }
×
54
}
55

56
impl From<fields::SymbolError> for SkeletonError {
57
    fn from(symbol_error: fields::SymbolError) -> Self {
15✔
58
        match symbol_error {
15✔
59
            fields::SymbolError::Invalid(ch) => match ch {
×
60
                b'-' => Self::SkeletonHasVariant,
×
61
                _ => Self::SymbolInvalid(ch),
×
62
            },
63
            fields::SymbolError::InvalidIndex(_) => unimplemented!(),
×
64
            fields::SymbolError::Unknown(ch) => {
15✔
65
                // NOTE: If you remove a symbol due to it now being supported,
66
                //       make sure to regenerate data: cargo make bakeddata components/datetime.
67
                match ch {
15✔
68
                    // TODO(#487) - Flexible day periods
69
                    'B'
70
                    // TODO(#501) - Quarters
71
                    | 'Q'
72
                    => Self::SymbolUnimplemented(ch),
15✔
73
                    _ => Self::SymbolUnknown(ch),
×
74
                }
75
            }
76
        }
77
    }
15✔
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc