Skip to content

Commit

Permalink
Merge pull request #11 from apopiak/to_string
Browse files Browse the repository at this point in the history
use `to_owned` instead of the slower `to_string`
  • Loading branch information
apopiak committed Feb 8, 2016
2 parents a1dffab + 688698c commit fc697cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "verex"
version = "0.2.1"
version = "0.2.2"
authors = ["Alexander Popiak <alexander.popiak@gmail.com>"]
description = "This crate provides a Rust implementation of VerbalExpressions in order to build regex strings without knowing the minutiae of regex syntax."
documentation="https://verbalexpressions.github.io/RustVerbalExpressions/verex/"
Expand Down
6 changes: 3 additions & 3 deletions src/verex/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ESCAPE_PAIRS: [(&'static str, &'static str); 14] = [
];

fn escape(string: &str) -> String {
let mut result = string.to_string();
let mut result = string.to_owned();
for pair in ESCAPE_PAIRS.into_iter() {
let regex = Regex::new(pair.0).unwrap();
result = regex.replace_all(result.as_ref(), pair.1);
Expand Down Expand Up @@ -93,7 +93,7 @@ impl Verex {

/// Create a `Verex` object from a `&str`
pub fn from_str(string: &str) -> Verex {
Verex::from_string(string.to_string())
Verex::from_string(string.to_owned())
}

// --------------------------------------------------
Expand Down Expand Up @@ -315,7 +315,7 @@ impl Verex {
/// A range of characters e.g. [A-Z]
/// Usage example: verex.range(vec![('a', 'z'),('A', 'Z')])
pub fn range(&mut self, range: Vec<(char, char)>) -> &mut Verex {
let mut string = r"[".to_string();
let mut string = r"[".to_owned();
for tuple in range {
let from = tuple.0;
let to = tuple.1;
Expand Down
2 changes: 1 addition & 1 deletion src/verex/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn test_constructors() {
let verex1: Verex = Verex::new();
assert_eq!(verex1.source(), r"(?:)");

let verex2: Verex = Verex::from_string(r"a".to_string());
let verex2: Verex = Verex::from_string(r"a".to_owned());
assert_eq!(verex2.source(), A_VEREX_STRING);

let verex3: Verex = Verex::from_str(r"a");
Expand Down

0 comments on commit fc697cd

Please sign in to comment.