diff options
author | Andrew Gallant <jamslam@gmail.com> | 2019-06-26 16:47:33 -0400 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2019-06-26 16:47:33 -0400 |
commit | b93762ea7a397b54e9ccf589a45a2c6ad91bc390 (patch) | |
tree | 54152ae9fb21c14f95ceefcb35e2d5b2f86295b1 /grep-printer | |
parent | 34677d262246462ce3027ee57be1869a9dc7730a (diff) |
bstr: update everything to bstr 0.2
Diffstat (limited to 'grep-printer')
-rw-r--r-- | grep-printer/Cargo.toml | 2 | ||||
-rw-r--r-- | grep-printer/src/standard.rs | 8 | ||||
-rw-r--r-- | grep-printer/src/util.rs | 10 |
3 files changed, 10 insertions, 10 deletions
diff --git a/grep-printer/Cargo.toml b/grep-printer/Cargo.toml index cc6dc8d7..79177bbd 100644 --- a/grep-printer/Cargo.toml +++ b/grep-printer/Cargo.toml @@ -19,7 +19,7 @@ serde1 = ["base64", "serde", "serde_derive", "serde_json"] [dependencies] base64 = { version = "0.10.0", optional = true } -bstr = "0.1.2" +bstr = "0.2.0" grep-matcher = { version = "0.1.2", path = "../grep-matcher" } grep-searcher = { version = "0.1.4", path = "../grep-searcher" } termcolor = "1.0.4" diff --git a/grep-printer/src/standard.rs b/grep-printer/src/standard.rs index 92fae5ca..89f44ad4 100644 --- a/grep-printer/src/standard.rs +++ b/grep-printer/src/standard.rs @@ -5,7 +5,7 @@ use std::path::Path; use std::sync::Arc; use std::time::Instant; -use bstr::BStr; +use bstr::ByteSlice; use grep_matcher::{Match, Matcher}; use grep_searcher::{ LineStep, Searcher, @@ -1274,7 +1274,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> { ) -> io::Result<()> { if self.config().max_columns_preview { let original = line; - let end = BStr::new(&bytes[line]) + let end = bytes[line] .grapheme_indices() .map(|(_, end, _)| end) .take(self.config().max_columns.unwrap_or(0) as usize) @@ -1396,7 +1396,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> { } let remainder = format!( "after match (found {:?} byte around offset {})\n", - BStr::new(&[byte]), offset, + [byte].as_bstr(), offset, ); self.write(remainder.as_bytes())?; } else if let Some(byte) = bin.convert_byte() { @@ -1407,7 +1407,7 @@ impl<'a, M: Matcher, W: WriteColor> StandardImpl<'a, M, W> { } let remainder = format!( "matches (found {:?} byte around offset {})\n", - BStr::new(&[byte]), offset, + [byte].as_bstr(), offset, ); self.write(remainder.as_bytes())?; } diff --git a/grep-printer/src/util.rs b/grep-printer/src/util.rs index 7a20f3b7..d4a19eb7 100644 --- a/grep-printer/src/util.rs +++ b/grep-printer/src/util.rs @@ -4,7 +4,7 @@ use std::io; use std::path::Path; use std::time; -use bstr::{BStr, BString}; +use bstr::{ByteSlice, ByteVec}; use grep_matcher::{Captures, LineTerminator, Match, Matcher}; use grep_searcher::{ LineIter, @@ -263,12 +263,12 @@ impl<'a> Sunk<'a> { /// portability with a small cost: on Windows, paths that are not valid UTF-16 /// will not roundtrip correctly. #[derive(Clone, Debug)] -pub struct PrinterPath<'a>(Cow<'a, BStr>); +pub struct PrinterPath<'a>(Cow<'a, [u8]>); impl<'a> PrinterPath<'a> { /// Create a new path suitable for printing. pub fn new(path: &'a Path) -> PrinterPath<'a> { - PrinterPath(BString::from_path_lossy(path)) + PrinterPath(Vec::from_path_lossy(path)) } /// Create a new printer path from the given path which can be efficiently @@ -289,7 +289,7 @@ impl<'a> PrinterPath<'a> { /// path separators that are both replaced by `new_sep`. In all other /// environments, only `/` is treated as a path separator. fn replace_separator(&mut self, new_sep: u8) { - let transformed_path: BString = self.0.bytes().map(|b| { + let transformed_path: Vec<u8> = self.0.bytes().map(|b| { if b == b'/' || (cfg!(windows) && b == b'\\') { new_sep } else { @@ -301,7 +301,7 @@ impl<'a> PrinterPath<'a> { /// Return the raw bytes for this path. pub fn as_bytes(&self) -> &[u8] { - self.0.as_bytes() + &self.0 } } |