From ce05187dac55c8f3ed93cb28e0195c00b3f004f0 Mon Sep 17 00:00:00 2001 From: Michael Gehring Date: Fri, 16 May 2014 10:34:32 +0200 Subject: [PATCH] base64: simplify ignore_garbage --- base64/base64.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/base64/base64.rs b/base64/base64.rs index d2edf32e6..55ee21b50 100644 --- a/base64/base64.rs +++ b/base64/base64.rs @@ -17,7 +17,6 @@ extern crate getopts; extern crate libc; #[phase(syntax, link)] extern crate log; -use std::char; use std::io::{println, File, stdin, stdout}; use std::os; use std::str; @@ -101,13 +100,9 @@ fn decode(input: &mut Reader, ignore_garbage: bool) { to_decode = str::replace(to_decode, "\n", ""); if ignore_garbage { - let standard_chars: ~[char] = - bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ", - "abcdefghijklmnopqrstuvwxyz", - "0123456789+/").iter().map(|b| char::from_u32(*b as u32).unwrap()).collect(); - + let standard_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; to_decode = to_decode - .trim_chars(|c| !standard_chars.contains(&c)) + .trim_chars(|c| !standard_chars.contains_char(c)) .to_owned(); }