Commit d6530865 authored by Sag0Sag0's avatar Sag0Sag0

Simplify closure type

parent d883b147
......@@ -71,7 +71,7 @@ impl Context {
pub fn read_line<P: Into<String>>(
&mut self,
prompt: P,
f: Box<for<'r> Fn(&'r str) -> Cow<'_, str>>,
f:Box<Fn(&str) -> Cow<str>>,
mut handler: &mut EventHandler<RawTerminal<Stdout>>,
) -> io::Result<String> {
self.read_line_with_init_buffer(prompt, handler, f, Buffer::new())
......@@ -92,7 +92,7 @@ impl Context {
&mut self,
prompt: P,
mut handler: &mut EventHandler<RawTerminal<Stdout>>,
f: Box<for<'r> Fn(&'r str) -> Cow<'_, str>>,
f:Box<Fn(&str) -> Cow<str>>,
buffer: B,
) -> io::Result<String> {
let res = {
......
......@@ -63,7 +63,7 @@ pub struct Editor<'a, W: Write> {
// A closure that is evaluated just before we write to out.
// This allows us to do custom syntax highlighting and other fun stuff.
closure: Box<for<'r> Fn(&'r str) -> Cow<'_, str>>,
closure: Box<Fn(&str) -> Cow<str>>,
// The location of the cursor. Note that the cursor does not lie on a char, but between chars.
// So, if `cursor == 0` then the cursor is before the first char,
......@@ -114,7 +114,7 @@ impl<'a, W: Write> Editor<'a, W> {
pub fn new<P: Into<String>>(
out: W,
prompt: P,
f: Box<for<'r> Fn(&'r str) -> Cow<'_, str>>,
f:Box<Fn(&str) -> Cow<str>>,
context: &'a mut Context
) -> io::Result<Self> {
Editor::new_with_init_buffer(out, prompt, f, context, Buffer::new())
......@@ -123,7 +123,7 @@ impl<'a, W: Write> Editor<'a, W> {
pub fn new_with_init_buffer<P: Into<String>, B: Into<Buffer>>(
out: W,
prompt: P,
f: Box<for<'r> Fn(&'r str) -> Cow<'_, str>>,
f: Box<Fn(&str) -> Cow<str>>,
context: &'a mut Context,
buffer: B,
) -> io::Result<Self> {
......
......@@ -11,7 +11,7 @@ use liner::{Context, CursorPosition, Event, EventKind, FilenameCompleter};
use termion::color;
use regex::Regex;
fn highlight_dodo<'r>(s: &'r str) -> Cow<'_, str> {
fn highlight_dodo(s: &str) -> Cow<str> {
let reg_exp = Regex::new("(?P<k>dodo)").unwrap();
let format = format!("{}$k{}", color::Fg(color::Red), color::Fg(color::Reset));
reg_exp.replace_all(s, format.as_str()).into()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment