mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-24 01:46:31 +00:00
Merge pull request #155 from KlossPeter/clippy
fix some clippy warnings
This commit is contained in:
commit
b84ab9e621
@ -78,7 +78,7 @@ fn phase_2(s: &mut Cursive) {
|
|||||||
let speeds: Vec<_> =
|
let speeds: Vec<_> =
|
||||||
(0..n_bars).map(|_| rand::thread_rng().gen_range(50, 150)).collect();
|
(0..n_bars).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 cb = s.cb_sink().clone();
|
||||||
|
|
||||||
// Let's prepare the progress bars...
|
// Let's prepare the progress bars...
|
||||||
|
@ -31,11 +31,11 @@ fn find_closest(color: &Color) -> i16 {
|
|||||||
Color::Light(BaseColor::Cyan) => 14,
|
Color::Light(BaseColor::Cyan) => 14,
|
||||||
Color::Light(BaseColor::White) => 15,
|
Color::Light(BaseColor::White) => 15,
|
||||||
Color::Rgb(r, g, b) => {
|
Color::Rgb(r, g, b) => {
|
||||||
let r = 6 * r as u16 / 256;
|
let r = 6 * u16::from(r) / 256;
|
||||||
let g = 6 * g as u16 / 256;
|
let g = 6 * u16::from(g) / 256;
|
||||||
let b = 6 * b as u16 / 256;
|
let b = 6 * u16::from(b) / 256;
|
||||||
(16 + 36 * r + 6 * g + b) as i16
|
(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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ impl Concrete {
|
|||||||
-> i16 {
|
-> i16 {
|
||||||
|
|
||||||
let n = 1 + pairs.len() as 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.
|
// We still have plenty of space for everyone.
|
||||||
n
|
n
|
||||||
} else {
|
} else {
|
||||||
|
@ -25,7 +25,7 @@ pub fn read_char<F>(first: u8, next: F) -> Result<char, String>
|
|||||||
let mut res = 0u32;
|
let mut res = 0u32;
|
||||||
|
|
||||||
// First, get the data - only the few last bits
|
// 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.
|
// We already have one byte, now read the others.
|
||||||
for _ in 1..n_bytes {
|
for _ in 1..n_bytes {
|
||||||
@ -39,7 +39,7 @@ pub fn read_char<F>(first: u8, next: F) -> Result<char, String>
|
|||||||
// We have 6 fresh new bits to read, make room.
|
// We have 6 fresh new bits to read, make room.
|
||||||
res <<= 6;
|
res <<= 6;
|
||||||
// 0x3F is 00111111, so we keep the last 6 bits
|
// 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.
|
// from_u32 could return an error if we gave it invalid utf-8.
|
||||||
|
@ -13,6 +13,13 @@ use utils::simple_suffix;
|
|||||||
use vec::Vec2;
|
use vec::Vec2;
|
||||||
use view::View;
|
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.
|
/// Input box where the user can enter and edit text.
|
||||||
///
|
///
|
||||||
@ -75,10 +82,10 @@ pub struct EditView {
|
|||||||
/// Callback when the content is modified.
|
/// Callback when the content is modified.
|
||||||
///
|
///
|
||||||
/// Will be called with the current content and the cursor position.
|
/// Will be called with the current content and the cursor position.
|
||||||
on_edit: Option<Rc<Fn(&mut Cursive, &str, usize)>>,
|
on_edit: Option<Rc<OnEdit>>,
|
||||||
|
|
||||||
/// Callback when <Enter> is pressed.
|
/// Callback when <Enter> is pressed.
|
||||||
on_submit: Option<Rc<Fn(&mut Cursive, &str)>>,
|
on_submit: Option<Rc<OnSubmit>>,
|
||||||
|
|
||||||
/// When `true`, only print `*` instead of the true content.
|
/// When `true`, only print `*` instead of the true content.
|
||||||
secret: bool,
|
secret: bool,
|
||||||
|
Loading…
Reference in New Issue
Block a user