]> git.lizzy.rs Git - rust.git/commitdiff
Fix up remaining usage of `to_ascii`.
authorSimon Sapin <simon.sapin@exyr.org>
Fri, 26 Dec 2014 00:17:30 +0000 (01:17 +0100)
committerSimon Sapin <simon.sapin@exyr.org>
Fri, 26 Dec 2014 00:17:30 +0000 (01:17 +0100)
src/test/bench/shootout-k-nucleotide-pipes.rs
src/test/bench/shootout-k-nucleotide.rs

index 8c11c3673d5274ebc4bf2b990fae29a47760c0f0..71b8a08e52665fc08164b38536f98eec3c9d98df 100644 (file)
@@ -17,6 +17,7 @@
 
 extern crate collections;
 
+use std::ascii::{AsciiExt, OwnedAsciiExt};
 use std::collections::HashMap;
 use std::mem::replace;
 use std::num::Float;
@@ -64,10 +65,8 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
    let mut buffer = String::new();
    for &(ref k, v) in pairs_sorted.iter() {
        buffer.push_str(format!("{} {:0.3}\n",
-                               k.as_slice()
-                               .to_ascii()
-                               .to_uppercase()
-                               .into_string(), v).as_slice());
+                               k.to_ascii_uppercase(),
+                               v).as_slice());
    }
 
    return buffer
@@ -75,7 +74,7 @@ fn sortKV(mut orig: Vec<(Vec<u8> ,f64)> ) -> Vec<(Vec<u8> ,f64)> {
 
 // given a map, search for the frequency of a pattern
 fn find(mm: &HashMap<Vec<u8> , uint>, key: String) -> uint {
-   let key = key.into_ascii().as_slice().to_lowercase().into_string();
+   let key = key.into_ascii_lowercase();
    match mm.get(key.as_bytes()) {
       option::Option::None      => { return 0u; }
       option::Option::Some(&num) => { return num; }
index 6aa6b02857fbe3d86646dea5d27e79a8f181a5e2..a0ef392ed3af2d2310e78dfba1984b2b66cc2f66 100644 (file)
@@ -42,6 +42,7 @@
 
 #![feature(slicing_syntax)]
 
+use std::ascii::OwnedAsciiExt;
 use std::string::String;
 use std::slice;
 use std::sync::{Arc, Future};
@@ -286,10 +287,7 @@ fn get_sequence<R: Buffer>(r: &mut R, key: &str) -> Vec<u8> {
     {
         res.push_all(l.as_slice().trim().as_bytes());
     }
-    for b in res.iter_mut() {
-        *b = b.to_ascii().to_uppercase().to_byte();
-    }
-    res
+    res.into_ascii_uppercase()
 }
 
 fn main() {