-
Notifications
You must be signed in to change notification settings - Fork 40
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
Simplify Regex
type and rename it to PreventSyncPattern
#9049
Conversation
d3f86d3
to
424bd3e
Compare
#[derive(Error, Debug)] | ||
pub enum PreventSyncPatternError { | ||
#[error("Regex parsing error: {err}")] | ||
BadRegex { err: regex::Error }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use tuple style for error since it only has one value.
That simplify errors handling since we can do
.map_error(PreventSyncPattern::BadRegex)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a very good point ! thx
16794e0
to
ac89683
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@@ -13,7 +13,7 @@ pub enum ApplyPreventSyncPatternError { | |||
pub(super) async fn ensure_prevent_sync_pattern_applied_to_wksp( | |||
storage: &mut WorkspaceStorage, | |||
device: Arc<LocalDevice>, | |||
pattern: &Regex, | |||
pattern: &PreventSyncPattern, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: rename to prevent_sync_pattern for consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
self.0.iter().any(|r| r.is_match(string)) | ||
} | ||
|
||
/// Create an empty regex, that regex will never match anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Create an empty regex, that regex will never match anything | |
/// Create an empty PreventSyncPattern, that PreventSyncPattern will never match anything |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 done.
…s/unit/local_folder_manifest.rs`
…rs` -> `prevent_sync_pattern.rs` in libparsec_types
…start` for extra clarity
…sult}` -> `PreventSyncPattern{Error|Result}`
- Remove useless $ escape code (already handled by `fnmatch_regex`) - Fix panic in libparsec bindings when config contains invalid pattern - Remove parsing from file to simplify API - More consistent naming in methods - Add more tests \o/
ac89683
to
c9ffbe4
Compare
No description provided.