Skip to content

Commit

Permalink
refactor(rust): chrono's ParseErrorKind is now public (#17201)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanIsCoding authored Jun 26, 2024
1 parent b8ac923 commit cbd194e
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions crates/polars-time/src/chunkedarray/string/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod infer;
use chrono::DateTime;
mod patterns;
mod strptime;
use chrono::format::ParseErrorKind;
use chrono::ParseError;
pub use patterns::Pattern;
#[cfg(feature = "dtype-time")]
Expand Down Expand Up @@ -52,24 +53,10 @@ struct ParseErrorByteCopy(ParseErrorKind);

impl From<ParseError> for ParseErrorByteCopy {
fn from(e: ParseError) -> Self {
// We need to do this until chrono ParseErrorKind is public
// blocked by https://github.com/chronotope/chrono/pull/588.
unsafe { std::mem::transmute(e) }
ParseErrorByteCopy(e.kind())
}
}

#[allow(dead_code)]
enum ParseErrorKind {
OutOfRange,
Impossible,
NotEnough,
Invalid,
/// The input string has been prematurely ended.
TooShort,
TooLong,
BadFormat,
}

fn get_first_val(ca: &StringChunked) -> PolarsResult<&str> {
let idx = ca.first_non_null().ok_or_else(|| {
polars_err!(ComputeError:
Expand Down

0 comments on commit cbd194e

Please sign in to comment.