Debian Codegraph @

src/parser/content_line/start_date_content_line.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#;
2
3 use superrust-analyzer cargo rrule 0.14.0 parser/content_line/::{
4 content_line_partsrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/::ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#, date_content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/::DateParameterrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#,
5 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/parameters/::parse_parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/parameters/parse_parameters().,
6 };
7 use craterust-analyzer cargo rrule 0.14.0 crate/::{
8 corerust-analyzer cargo rrule 0.14.0 core/::Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#,
9 parserrust-analyzer cargo rrule 0.14.0 parser/::{
10 datetimerust-analyzer cargo rrule 0.14.0 parser/datetime/::{datestring_to_daterust-analyzer cargo rrule 0.14.0 parser/datetime/datestring_to_date()., parse_timezonerust-analyzer cargo rrule 0.14.0 parser/datetime/parse_timezone().},
11 ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#,
12 },
13 };
14
15 const UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC.: Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz# = Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#::UTCrust-analyzer cargo rrule 0.14.0 core/timezone/impl#[Tz]UTC.;
16
17 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
18 pub(craterust-analyzer cargo rrule 0.14.0 crate/) struct StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# {
19 pub datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: chronorust-analyzer cargo chrono 0.4.40 crate/::DateTimerust-analyzer cargo chrono 0.4.40 datetime/DateTime#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>,
20 pub timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Tzrust-analyzer cargo rrule 0.14.0 core/timezone/Tz#>,
21 pub valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: &'static str,
22 }
23
24 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#<'_>> for StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# {
25 type Errorrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]Error# = ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#;
26
27 fn try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().(content_line: &ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`], Selfrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#Error#> {
28 let parameters: HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#<DateParameterrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = content_line
29 .parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.
30 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
31 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|p| parse_parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/parameters/parse_parameters().(p))
32 .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
33 .unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().();
34
35 let mut timezone = parameters
36 .getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&DateParameterrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#::Timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#Timezone#)
37 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|tz| parse_timezonerust-analyzer cargo rrule 0.14.0 parser/datetime/parse_timezone().(tz))
38 .transposerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<Result<T, E>>`]transpose().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
39 if timezone.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() && content_line.valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value..to_uppercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_uppercase().().ends_withrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]ends_with().('Z') {
40 timezone = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC.);
41 }
42
43 let value_in_parameter = parameters.getrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get().(&DateParameterrust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#::Valuerust-analyzer cargo rrule 0.14.0 parser/content_line/date_content_line/DateParameter#Value#);
44 let value = if content_line.valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().8 {
45 "DATE-TIME"
46 } else {
47 "DATE"
48 };
49 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(value_in_parameter) = value_in_parameter {
50 if value_in_parameter rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().value {
51 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::ParameterValueMismatchrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch# {
52 parameterrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#parameter.: "VALUE".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
53 parameter_valuerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#parameter_value.: value_in_parameter.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
54 found_valuerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#found_value.: value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
55 });
56 }
57 }
58
59 let datetime = datestring_to_daterust-analyzer cargo rrule 0.14.0 parser/datetime/datestring_to_date().(content_line.valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value., timezone, "DTSTART")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
60
61 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`] {
62 datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.,
63 timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.,
64 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.,
65 })
66 }
67 }
68
69 #[cfg(test)]
70 mod testsrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/tests/ {
71 use chronorust-analyzer cargo chrono 0.4.40 crate/::TimeZonerust-analyzer cargo chrono 0.4.40 offset/TimeZone#;
72
73 use craterust-analyzer cargo rrule 0.14.0 crate/::parserrust-analyzer cargo rrule 0.14.0 parser/::content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/::PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#;
74
75 use superrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/::*;
76
77 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
78 fn parses_dtstart_content_linerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/tests/parses_dtstart_content_line().() {
79 let tests = [
80 (
81 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
82 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
83 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
84 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "19970714T123000Z",
85 },
86 StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# {
87 datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 7, 14, 12, 30, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(),
88 timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC.),
89 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE-TIME",
90 },
91 ),
92 (
93 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
94 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
95 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("VALUE=DATE;TZID=UTC"),
96 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "19970101",
97 },
98 StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# {
99 datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(),
100 timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC.),
101 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE",
102 },
103 ),
104 (
105 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
106 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
107 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("TZID=UTC"),
108 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "19970101",
109 },
110 StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine# {
111 datetimerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#datetime.: UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC..with_ymd_and_hmsrust-analyzer cargo chrono 0.4.40 offset/TimeZone#with_ymd_and_hms().(1997, 1, 1, 0, 0, 0).unwraprust-analyzer cargo chrono 0.4.40 offset/impl#[`LocalResult<T>`]unwrap().(),
112 timezonerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#timezone.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(UTCrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/UTC.),
113 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#value.: "DATE",
114 },
115 ),
116 ];
117
118 for (input, expected_output) in tests {
119 let output = TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().(&input);
120 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(output, Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(expected_output));
121 }
122 }
123
124 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
125 fn rejects_invalid_dtstartrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/tests/rejects_invalid_dtstart().() {
126 let tests = [
127 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
128 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
129 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
130 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "20120201120000Z",
131 },
132 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
133 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
134 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
135 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "2012",
136 },
137 ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
138 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
139 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#,
140 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "",
141 },
142 ];
143
144 for input in tests {
145 let output = StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().(&input);
146 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
147 output,
148 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::InvalidDateTimerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#InvalidDateTime# {
149 valuerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#InvalidDateTime#value.: input.valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
150 propertyrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#InvalidDateTime#property.: "DTSTART".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
151 })
152 );
153 }
154 }
155
156 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
157 fn reject_invalid_timezone_in_start_daterust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/tests/reject_invalid_timezone_in_start_date().() {
158 let content = ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
159 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
160 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("TZID=America/Everywhere"),
161 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "20120251T023000Z",
162 };
163 let res = StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().(&content);
164 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
165 let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
166 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
167 err,
168 ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::InvalidTimezonerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#InvalidTimezone#("America/Everywhere".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().())
169 );
170 }
171
172 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
173 fn reject_value_mismatch_with_parameterrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/tests/reject_value_mismatch_with_parameter().() {
174 let content = ContentLineCapturesrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures# {
175 property_namerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#property_name.: PropertyNamerust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#::DtStartrust-analyzer cargo rrule 0.14.0 parser/content_line/PropertyName#DtStart#,
176 parametersrust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#parameters.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("VALUE=DATE"),
177 valuerust-analyzer cargo rrule 0.14.0 parser/content_line/content_line_parts/ContentLineCaptures#value.: "20120251T023000Z",
178 };
179 let res = StartDateContentLinerust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/StartDateContentLine#::try_fromrust-analyzer cargo rrule 0.14.0 parser/content_line/start_date_content_line/impl#[StartDateContentLine][`TryFrom<&ContentLineCaptures<'_>>`]try_from().(&content);
180 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(res.is_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_err().());
181 let err = res.unwrap_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_err().();
182 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
183 err,
184 ParseErrorrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#::ParameterValueMismatchrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch# {
185 parameterrust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#parameter.: "VALUE".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
186 parameter_valuerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#parameter_value.: "DATE".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
187 found_valuerust-analyzer cargo rrule 0.14.0 parser/error/ParseError#ParameterValueMismatch#found_value.: "DATE-TIME".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()
188 }
189 );
190 }
191 }