extern crate collections;
+use std::ascii::{AsciiExt, OwnedAsciiExt};
use std::collections::HashMap;
use std::mem::replace;
use std::num::Float;
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
// 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; }
#![feature(slicing_syntax)]
+use std::ascii::OwnedAsciiExt;
use std::string::String;
use std::slice;
use std::sync::{Arc, Future};
{
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() {