pub fn run<W: WriteColor>(
        &mut self,
        printer: &mut Printer<W>,
        work: Work,
    ) -> u64 {
        let result = match work {
            Work::Stdin => {
                let stdin = io::stdin();
                let stdin = stdin.lock();
                self.search(printer, Path::new("<stdin>"), stdin)
            }
            Work::DirEntry(dent) => {
                let mut path = dent.path();
                let file = match File::open(path) {
                    Ok(file) => file,
                    Err(err) => {
                        if !self.opts.no_messages {
                            eprintln!("{}: {}", path.display(), err);
                        }
                        return 0;
                    }
                };
                if let Some(p) = strip_prefix("./", path) {
                    path = p;
                }
                if self.opts.mmap {
                    self.search_mmap(printer, path, &file)
                } else {
                    self.search(printer, path, file)
                }
            }
        };
        match result {
            Ok(count) => {
                count
            }
            Err(err) => {
                if !self.opts.no_messages {
                    eprintln!("{}", err);
                }
                0
            }
        }
    }
/// Execute the worker with the given printer and work item.
///
/// A work item can either be stdin or a file path.
Execute the worker with the given printer and work item.
A work item can either be stdin or a file path.
Execute the worker with the given printer and work item . A work item can either be stdin or a file path .
pub fn run<W: WriteColor>(
        &mut self,
        printer: &mut Printer<W>,
        work: Work,
    ) -> u64 {
        let result = match work {
            Work::Stdin => {
                let stdin = io::stdin();
                let stdin = stdin.lock();
                self.search(printer, Path::new("<stdin>"), stdin)
            }
            Work::DirEntry(dent) => {
                let mut path = dent.path();
                let file = match File::open(path) {
                    Ok(file) => file,
                    Err(err) => {
                        if !self.opts.no_messages {
                            eprintln!("{}: {}", path.display(), err);
                        }
                        return 0;
                    }
                };
                if let Some(p) = strip_prefix("./", path) {
                    path = p;
                }
                if self.opts.mmap {
                    self.search_mmap(printer, path, &file)
                } else {
                    self.search(printer, path, file)
                }
            }
        };
        match result {
            Ok(count) => {
                count
            }
            Err(err) => {
                if !self.opts.no_messages {
                    eprintln!("{}", err);
                }
                0
            }
        }
    }
pub fn run < W : WriteColor > ( & mut self , printer : & mut Printer < W > , work : Work , ) -> u64 { let result = match work { Work :: Stdin => { let stdin = io :: stdin ( ) ; let stdin = stdin . lock ( ) ; self . search ( printer , Path :: new ( " " ) , stdin ) } Work :: DirEntry ( dent ) => { let mut path = dent . path ( ) ; let file = match File :: open ( path ) { Ok ( file ) => file , Err ( err ) => { if ! self . opts . no_messages { eprintln ! ( " " path display ( ) err ) ; } return 0 ; } } ; if let Some ( p ) = strip_prefix ( " " , path ) { path = p ; } if self . opts . mmap { self . search_mmap ( printer , path , & file ) } else { self . search ( printer , path , file ) } } } ; match result { Ok ( count ) => { count } Err ( err ) => { if ! self . opts . no_messages { eprintln ! ( " " err ) ; } 0 } } }
Execute the worker with the given printer and work item.
Execute the worker with the given printer and work item .
&mut self
printer
&mut Printer<W>
work
Work