diff --git a/examples/progress.rs b/examples/progress.rs index 39395c0..6a8b46f 100644 --- a/examples/progress.rs +++ b/examples/progress.rs @@ -83,7 +83,7 @@ fn phase_2(s: &mut Cursive) { .map(|_| rand::thread_rng().gen_range(50, 150)) .collect(); - let n_max = 100000; + let n_max = 100_000; let cb = s.cb_sink().clone(); // Let's prepare the progress bars... diff --git a/src/backend/curses/mod.rs b/src/backend/curses/mod.rs index 1fa5260..0c1264c 100644 --- a/src/backend/curses/mod.rs +++ b/src/backend/curses/mod.rs @@ -31,11 +31,11 @@ fn find_closest(color: &Color) -> i16 { Color::Light(BaseColor::Cyan) => 14, Color::Light(BaseColor::White) => 15, Color::Rgb(r, g, b) => { - let r = 6 * r as u16 / 256; - let g = 6 * g as u16 / 256; - let b = 6 * b as u16 / 256; + let r = 6 * u16::from(r) / 256; + let g = 6 * u16::from(g) / 256; + let b = 6 * u16::from(b) / 256; (16 + 36 * r + 6 * g + b) as i16 } - Color::RgbLowRes(r, g, b) => (16 + 36 * r + 6 * g + b) as i16, + Color::RgbLowRes(r, g, b) => i16::from(16 + 36 * r + 6 * g + b), } } diff --git a/src/backend/curses/n.rs b/src/backend/curses/n.rs index af789c2..fdf47d6 100644 --- a/src/backend/curses/n.rs +++ b/src/backend/curses/n.rs @@ -24,7 +24,7 @@ impl Concrete { &self, pairs: &mut HashMap, pair: ColorPair ) -> i16 { let n = 1 + pairs.len() as i16; - let target = if ncurses::COLOR_PAIRS() > n as i32 { + let target = if ncurses::COLOR_PAIRS() > i32::from(n) { // We still have plenty of space for everyone. n } else { diff --git a/src/utf8.rs b/src/utf8.rs index ce58860..cd7cd16 100644 --- a/src/utf8.rs +++ b/src/utf8.rs @@ -26,7 +26,7 @@ where let mut res = 0u32; // First, get the data - only the few last bits - res |= (first & make_mask(7 - n_bytes)) as u32; + res |= u32::from(first & make_mask(7 - n_bytes)); // We already have one byte, now read the others. for _ in 1..n_bytes { @@ -42,7 +42,7 @@ where // We have 6 fresh new bits to read, make room. res <<= 6; // 0x3F is 00111111, so we keep the last 6 bits - res |= (byte & 0x3F) as u32; + res |= u32::from(byte & 0x3F); } // from_u32 could return an error if we gave it invalid utf-8. diff --git a/src/views/edit_view.rs b/src/views/edit_view.rs index dd9a113..fd8f6d8 100644 --- a/src/views/edit_view.rs +++ b/src/views/edit_view.rs @@ -12,6 +12,13 @@ use utils::{simple_prefix, simple_suffix}; use vec::Vec2; use view::View; +/// closure type for callbacks when the content is modified. Arguments are the +/// `Cursive`, current content of the input and cursor position +pub type OnEdit = Fn(&mut Cursive, &str, usize); + +/// closure type for callbacks when Enter is pressed. Arguments are the `Cursive` +/// and the content of the input. +pub type OnSubmit = Fn(&mut Cursive, &str); /// Input box where the user can enter and edit text. /// @@ -74,10 +81,10 @@ pub struct EditView { /// Callback when the content is modified. /// /// Will be called with the current content and the cursor position. - on_edit: Option>, + on_edit: Option>, /// Callback when is pressed. - on_submit: Option>, + on_submit: Option>, /// When `true`, only print `*` instead of the true content. secret: bool,