about summary refs log tree commit diff
path: root/src/libgetopts/lib.rs
diff options
context:
space:
mode:
authorAndre Bogus <bogusandre@gmail.com>2015-09-08 00:36:29 +0200
committerAndre Bogus <bogusandre@gmail.com>2015-09-08 00:36:29 +0200
commit9cca96545faf2cfc972cc67b83deae2a78935c43 (patch)
treeef675da82a1ce1b23173921957f6a6a167ad8db8 /src/libgetopts/lib.rs
parent7bf626a68045be1d1a4fac9a635113bb7775b6bb (diff)
downloadrust-9cca96545faf2cfc972cc67b83deae2a78935c43.tar.gz
rust-9cca96545faf2cfc972cc67b83deae2a78935c43.zip
some more clippy-based improvements
Diffstat (limited to 'src/libgetopts/lib.rs')
-rw-r--r--src/libgetopts/lib.rs76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs
index ef63f85bb13..ab34f2e48ca 100644
--- a/src/libgetopts/lib.rs
+++ b/src/libgetopts/lib.rs
@@ -229,14 +229,14 @@ impl Name {
         if nm.len() == 1 {
             Short(nm.char_at(0))
         } else {
-            Long(nm.to_string())
+            Long(nm.to_owned())
         }
     }
 
     fn to_string(&self) -> String {
         match *self {
             Short(ch) => ch.to_string(),
-            Long(ref s) => s.to_string()
+            Long(ref s) => s.to_owned()
         }
     }
 }
@@ -375,7 +375,7 @@ impl Matches {
         } else {
             match vals[0] {
                 Val(ref s) => Some((*s).clone()),
-                _ => Some(def.to_string())
+                _ => Some(def.to_owned())
             }
         }
     }
@@ -414,10 +414,10 @@ pub fn reqopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: hint.to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: hint.to_owned(),
+        desc: desc.to_owned(),
         hasarg: Yes,
         occur: Req
     }
@@ -434,10 +434,10 @@ pub fn optopt(short_name: &str, long_name: &str, desc: &str, hint: &str) -> OptG
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: hint.to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: hint.to_owned(),
+        desc: desc.to_owned(),
         hasarg: Yes,
         occur: Optional
     }
@@ -452,10 +452,10 @@ pub fn optflag(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: "".to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: "".to_owned(),
+        desc: desc.to_owned(),
         hasarg: No,
         occur: Optional
     }
@@ -471,10 +471,10 @@ pub fn optflagmulti(short_name: &str, long_name: &str, desc: &str) -> OptGroup {
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: "".to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: "".to_owned(),
+        desc: desc.to_owned(),
         hasarg: No,
         occur: Multi
     }
@@ -491,10 +491,10 @@ pub fn optflagopt(short_name: &str, long_name: &str, desc: &str, hint: &str) ->
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: hint.to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: hint.to_owned(),
+        desc: desc.to_owned(),
         hasarg: Maybe,
         occur: Optional
     }
@@ -512,10 +512,10 @@ pub fn optmulti(short_name: &str, long_name: &str, desc: &str, hint: &str) -> Op
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: hint.to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: hint.to_owned(),
+        desc: desc.to_owned(),
         hasarg: Yes,
         occur: Multi
     }
@@ -531,10 +531,10 @@ pub fn opt(short_name: &str,
     let len = short_name.len();
     assert!(len == 1 || len == 0);
     OptGroup {
-        short_name: short_name.to_string(),
-        long_name: long_name.to_string(),
-        hint: hint.to_string(),
-        desc: desc.to_string(),
+        short_name: short_name.to_owned(),
+        long_name: long_name.to_owned(),
+        hint: hint.to_owned(),
+        desc: desc.to_owned(),
         hasarg: hasarg,
         occur: occur
     }
@@ -574,7 +574,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
     let opts: Vec<Opt> = optgrps.iter().map(|x| x.long_to_short()).collect();
     let n_opts = opts.len();
 
-    fn f(_x: usize) -> Vec<Optval> { return Vec::new(); }
+    fn f(_x: usize) -> Vec<Optval> { Vec::new() }
 
     let mut vals: Vec<_> = (0..n_opts).map(f).collect();
     let mut free: Vec<String> = Vec::new();
@@ -596,11 +596,11 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                 let tail = &cur[2..curlen];
                 let tail_eq: Vec<&str> = tail.split('=').collect();
                 if tail_eq.len() <= 1 {
-                    names = vec!(Long(tail.to_string()));
+                    names = vec!(Long(tail.to_owned()));
                 } else {
                     names =
-                        vec!(Long(tail_eq[0].to_string()));
-                    i_arg = Some(tail_eq[1].to_string());
+                        vec!(Long(tail_eq[0].to_owned()));
+                    i_arg = Some(tail_eq[1].to_owned());
                 }
             } else {
                 let mut j = 1;
@@ -630,7 +630,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
 
                     let next = j + ch.len_utf8();
                     if arg_follows && next < curlen {
-                        i_arg = Some((&cur[next..curlen]).to_string());
+                        i_arg = Some((&cur[next..curlen]).to_owned());
                         break;
                     }
 
@@ -769,7 +769,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
         // FIXME: #5516 should be graphemes not codepoints
         let mut desc_rows = Vec::new();
         each_split_within(&desc_normalized_whitespace[..], 54, |substr| {
-            desc_rows.push(substr.to_string());
+            desc_rows.push(substr.to_owned());
             true
         });
 
@@ -936,7 +936,7 @@ fn each_split_within<F>(ss: &str, lim: usize, mut it: F) -> bool where
         machine(&mut cont, (fake_i, ' '));
         fake_i += 1;
     }
-    return cont;
+    cont
 }
 
 #[test]