Remove unnecessary code
This commit removes some unnecessary code, such as an extra `String` clone, unnecessary `return` statements, and an inherent `to_string` function for the `Regex` wrapper. A double-quote character considered as a string literal by the compiler was also changed to a single-quote character, this time considered as a character by the compiler, for some optimization. Also a newline is added in order to improve code readablitiy.
This commit is contained in:
@@ -95,7 +95,7 @@ impl Rule {
|
||||
|
||||
impl From<String> for Rule {
|
||||
fn from(source: String) -> Self {
|
||||
let components: Vec<&str> = source.split_terminator(">").collect();
|
||||
let components: Vec<&str> = source.split_terminator('>').collect();
|
||||
Self {
|
||||
from: Regex::new(components[0]),
|
||||
to: String::from(components[1]),
|
||||
|
||||
@@ -11,10 +11,6 @@ impl Regex {
|
||||
pub fn as_str(&self) -> &str {
|
||||
self.0.as_str()
|
||||
}
|
||||
|
||||
pub fn to_string(&self) -> String {
|
||||
self.0.to_string()
|
||||
}
|
||||
}
|
||||
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
Reference in New Issue
Block a user