MCPcopy Create free account
hub / github.com/apache/arrow-rs / from_str

Method from_str

arrow-cast/src/parse.rs:1121–1143  ·  view source on GitHub ↗
(s: &str)

Source from the content-addressed store, hash-verified

1119 type Err = ArrowError;
1120
1121 fn from_str(s: &str) -> Result<Self, ArrowError> {
1122 match s.to_lowercase().as_str() {
1123 "c" | "cent" | "cents" | "century" | "centuries" => Ok(Self::Century),
1124 "dec" | "decs" | "decade" | "decades" => Ok(Self::Decade),
1125 "y" | "yr" | "yrs" | "year" | "years" => Ok(Self::Year),
1126 "mon" | "mons" | "month" | "months" => Ok(Self::Month),
1127 "w" | "week" | "weeks" => Ok(Self::Week),
1128 "d" | "day" | "days" => Ok(Self::Day),
1129 "h" | "hr" | "hrs" | "hour" | "hours" => Ok(Self::Hour),
1130 "m" | "min" | "mins" | "minute" | "minutes" => Ok(Self::Minute),
1131 "s" | "sec" | "secs" | "second" | "seconds" => Ok(Self::Second),
1132 "ms" | "msec" | "msecs" | "msecond" | "mseconds" | "millisecond" | "milliseconds" => {
1133 Ok(Self::Millisecond)
1134 }
1135 "us" | "usec" | "usecs" | "usecond" | "useconds" | "microsecond" | "microseconds" => {
1136 Ok(Self::Microsecond)
1137 }
1138 "nanosecond" | "nanoseconds" => Ok(Self::Nanosecond),
1139 _ => Err(ArrowError::InvalidArgumentError(format!(
1140 "Unknown interval type: {s}"
1141 ))),
1142 }
1143 }
1144}
1145
1146impl IntervalUnit {

Callers

nothing calls this directly

Calls 3

as_strMethod · 0.45
lenMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected