config: sort

This commit is contained in:
Harsh Shandilya 2021-11-28 15:16:43 +05:30
parent 3fadd9467b
commit 3599fccf4e
No known key found for this signature in database
GPG key ID: 366D7BBAD1031E80

View file

@ -17,14 +17,6 @@ pub struct Substitutor {
pub action: Action,
}
pub trait Match {
fn check_match(self, string: &str) -> bool;
}
pub trait Act {
fn apply_action(self, input: String) -> String;
}
#[derive(Clone, Debug, Deserialize)]
pub enum Matcher {
#[serde(rename = "starts_with")]
@ -37,6 +29,24 @@ pub enum Matcher {
Regex { pattern: String },
}
#[derive(Clone, Debug, Deserialize)]
pub enum Action {
#[serde(rename = "replace")]
Replace { from: String, to: String },
#[serde(rename = "prefix")]
Prefix { prefix: String },
#[serde(rename = "suffix")]
Suffix { suffix: String },
}
pub trait Match {
fn check_match(self, string: &str) -> bool;
}
pub trait Act {
fn apply_action(self, input: String) -> String;
}
impl Match for Matcher {
fn check_match(self, string: &str) -> bool {
match self {
@ -51,16 +61,6 @@ impl Match for Matcher {
}
}
#[derive(Clone, Debug, Deserialize)]
pub enum Action {
#[serde(rename = "replace")]
Replace { from: String, to: String },
#[serde(rename = "prefix")]
Prefix { prefix: String },
#[serde(rename = "suffix")]
Suffix { suffix: String },
}
impl Act for Action {
fn apply_action(self, input: String) -> String {
return match self {