1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-06-25 14:22:54 +02:00

docs and small polish

This commit is contained in:
Andrew Gallant
2016-08-24 18:33:35 -04:00
parent 61f49ba716
commit 957f90c898
2 changed files with 35 additions and 75 deletions

View File

@ -1,10 +1,15 @@
#![deny(missing_docs)]
/*!
A fast line oriented regex searcher.
*/
extern crate memchr;
extern crate regex;
extern crate regex_syntax as syntax;
use std::error;
use std::fmt;
use std::io;
use std::result;
pub use search::{Grep, GrepBuilder};
@ -27,11 +32,6 @@ pub enum Error {
/// pattern. For example, if the line terminator is `\n` and the regex
/// pattern is `\w+\n\w+`, then the presence of `\n` will cause this error.
LiteralNotAllowed(char),
/// This errors occurs when a line exceeds the buffer size. The buffer
/// size is given.
LineTooLong(usize),
/// An IO error occurred while searching.
Io(io::Error),
/// An unused enum variant that indicates this enum may be expanded in
/// the future and therefore should not be exhaustively matched.
#[doc(hidden)]
@ -43,8 +43,6 @@ impl error::Error for Error {
match *self {
Error::Regex(ref err) => err.description(),
Error::LiteralNotAllowed(_) => "use of forbidden literal",
Error::LineTooLong(_) => "line exceeds buffer size",
Error::Io(ref err) => err.description(),
Error::__Nonexhaustive => unreachable!(),
}
}
@ -52,7 +50,6 @@ impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::Regex(ref err) => err.cause(),
Error::Io(ref err) => err.cause(),
_ => None,
}
}
@ -65,11 +62,6 @@ impl fmt::Display for Error {
Error::LiteralNotAllowed(chr) => {
write!(f, "Literal '{}' not allowed.", chr)
}
Error::LineTooLong(limit) => {
write!(f, "Line exceeded buffer size of {} bytes, try \
searching with memory maps instead.", limit)
}
Error::Io(ref err) => err.fmt(f),
Error::__Nonexhaustive => unreachable!(),
}
}
@ -86,9 +78,3 @@ impl From<syntax::Error> for Error {
Error::Regex(regex::Error::Syntax(err))
}
}
impl From<io::Error> for Error {
fn from(err: io::Error) -> Error {
Error::Io(err)
}
}