Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty/default contexts, put chrono/regex behind features #97

Merged
merged 5 commits into from
Oct 17, 2024

Conversation

clarkmcc
Copy link
Owner

Closes #90

@clarkmcc clarkmcc mentioned this pull request Oct 16, 2024
Copy link
Contributor

@Caellian Caellian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Nitpick

You could remove guards on (and guarded) use satatements and use absolute paths for structs that are used in feature gated functions.

For instance:

#[cfg(feature = "regex")]
pub fn matches(
    ftx: &FunctionContext,
    This(this): This<Arc<String>>,
    regex: Arc<String>,
) -> Result<bool> {
    match regex::Regex::new(&regex) {
        Ok(re) => Ok(re.is_match(&this)),
        Err(err) => Err(ftx.error(format!("'{regex}' not a valid regex:\n{err}"))),
    }
}
// Allows you to remove:
#[cfg(feature = "chrono")]
use regex::Regex;

That's mostly a stylistic choice though - functionally, this is what I had in mind with #90.

@clarkmcc
Copy link
Owner Author

@Caellian love it, thanks for the feedback

@clarkmcc clarkmcc merged commit 5ca6931 into master Oct 17, 2024
1 check passed
@clarkmcc clarkmcc deleted the 90-empty-context branch October 17, 2024 16:10
@github-actions github-actions bot mentioned this pull request Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Context::new
2 participants