Skip to content

Commit

Permalink
fix(rust) Avoid using the regex dependency when the regex feature is …
Browse files Browse the repository at this point in the history
…not used (#17206)
  • Loading branch information
datapythonista authored Jun 26, 2024
1 parent fcd4dbb commit df989de
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions crates/polars-plan/src/dsl/function_expr/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ use polars_core::chunked_array::temporal::validate_time_zone;
use polars_core::utils::handle_casting_failures;
#[cfg(feature = "dtype-struct")]
use polars_utils::format_smartstring;
#[cfg(feature = "regex")]
use regex::{escape, Regex};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

use super::*;
use crate::{map, map_as_slice};

#[cfg(feature = "timezones")]
#[cfg(all(feature = "regex", feature = "timezones"))]
static TZ_AWARE_RE: Lazy<Regex> =
Lazy::new(|| Regex::new(r"(%z)|(%:z)|(%::z)|(%:::z)|(%#z)|(^%\+$)").unwrap());

Expand Down Expand Up @@ -648,7 +649,7 @@ fn to_datetime(
let datetime_strings = &s[0].str()?;
let ambiguous = &s[1].str()?;
let tz_aware = match &options.format {
#[cfg(feature = "timezones")]
#[cfg(all(feature = "regex", feature = "timezones"))]
Some(format) => TZ_AWARE_RE.is_match(format),
_ => false,
};
Expand Down

0 comments on commit df989de

Please sign in to comment.