From 54b3e9eb10bebb33de799bc14616a0d72165583a Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Fri, 7 Sep 2018 11:57:07 -0400 Subject: [PATCH] grep-printer: delete unused code --- grep-printer/src/jsont.rs | 66 --------------------------------------- grep-searcher/src/lib.rs | 3 -- 2 files changed, 69 deletions(-) diff --git a/grep-printer/src/jsont.rs b/grep-printer/src/jsont.rs index 5028349a..f98dabbb 100644 --- a/grep-printer/src/jsont.rs +++ b/grep-printer/src/jsont.rs @@ -114,39 +114,6 @@ impl<'a> Data<'a> { // so we do the easy thing for now. Data::Text { text: path.to_string_lossy() } } - - // Unused deserialization routines. - - /* - fn into_bytes(self) -> Vec { - match self { - Data::Text { text } => text.into_bytes(), - Data::Bytes { bytes } => bytes, - } - } - - #[cfg(unix)] - fn into_path_buf(&self) -> PathBuf { - use std::os::unix::ffi::OsStrExt; - - match self { - Data::Text { text } => PathBuf::from(text), - Data::Bytes { bytes } => { - PathBuf::from(OsStr::from_bytes(bytes)) - } - } - } - - #[cfg(not(unix))] - fn into_path_buf(&self) -> PathBuf { - match self { - Data::Text { text } => PathBuf::from(text), - Data::Bytes { bytes } => { - PathBuf::from(String::from_utf8_lossy(&bytes).into_owned()) - } - } - } - */ } fn to_base64( @@ -178,36 +145,3 @@ where P: AsRef, { path.as_ref().map(|p| Data::from_path(p.as_ref())).serialize(ser) } - -// The following are some deserialization helpers, in case we decide to support -// deserialization of the above types. - -/* -fn from_base64<'de, D>( - de: D, -) -> Result, D::Error> -where D: Deserializer<'de> -{ - let encoded = String::deserialize(de)?; - let decoded = base64::decode(encoded.as_bytes()) - .map_err(D::Error::custom)?; - Ok(decoded) -} - -fn deser_bytes<'de, D>( - de: D, -) -> Result, D::Error> -where D: Deserializer<'de> -{ - Data::deserialize(de).map(|datum| datum.into_bytes()) -} - -fn deser_path<'de, D>( - de: D, -) -> Result, D::Error> -where D: Deserializer<'de> -{ - Option::::deserialize(de) - .map(|opt| opt.map(|datum| datum.into_path_buf())) -} -*/ diff --git a/grep-searcher/src/lib.rs b/grep-searcher/src/lib.rs index 4874b996..f3ec02f2 100644 --- a/grep-searcher/src/lib.rs +++ b/grep-searcher/src/lib.rs @@ -74,14 +74,11 @@ fn example() -> Result<(), Box> { let mut matches: Vec<(u64, String)> = vec![]; Searcher::new().search_slice(&matcher, SHERLOCK, UTF8(|lnum, line| { // We are guaranteed to find a match, so the unwrap is OK. - eprintln!("LINE: {:?}", line); let mymatch = matcher.find(line.as_bytes())?.unwrap(); matches.push((lnum, line[mymatch].to_string())); Ok(true) }))?; - eprintln!("MATCHES: {:?}", matches); - assert_eq!(matches.len(), 2); assert_eq!( matches[0],