From 7f2b398ad2084bdaaa266e8da770a213f0a9a2eb Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 4 Mar 2018 22:40:15 +0000 Subject: [PATCH] Remove all instances of unwrap() from config Unwrapping inside the config file parsing can lead to some issues that prevent us from falling back to a default configuration file. One instance of that issue was mentioned in #1135. Now all instances of `unwrap()` have been removed and replaced with proper error handling. This will make the config more robust and prevents live reload from silently breaking while alacritty is running. This also fixes a few currently existing clippy issues. Clippy added an additonal lint which complains about `MyStruct { field: field }`. These issues have been fixed, except for some false-positives and issues in external macros which will probably be fixed with future updates (rust-lang-nursery/bitflags#149) --- Cargo.lock | 34 ++++++++++++++++---------------- src/ansi.rs | 6 +++--- src/config.rs | 47 ++++++++++++++++++++------------------------- src/display.rs | 14 +++++++------- src/event.rs | 8 ++++---- src/event_loop.rs | 12 ++++++------ src/grid.rs | 6 +++--- src/index.rs | 2 +- src/logging.rs | 2 +- src/meter.rs | 2 +- src/renderer/mod.rs | 38 ++++++++++++++++++------------------ src/selection.rs | 36 +++++++++++++++++----------------- src/term/cell.rs | 6 +++--- src/term/mod.rs | 26 ++++++++++++------------- src/window.rs | 4 ++-- 15 files changed, 119 insertions(+), 124 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ab5af105..a4ae26d2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,7 +10,7 @@ dependencies = [ name = "alacritty" version = "0.1.0" dependencies = [ - "arraydeque 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "arraydeque 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "cgmath 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -57,7 +57,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "arraydeque" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -131,7 +131,7 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -207,7 +207,7 @@ name = "cmake" version = "0.1.29" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -294,7 +294,7 @@ version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "humantime 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", @@ -312,7 +312,7 @@ dependencies = [ [[package]] name = "euclid" -version = "0.17.0" +version = "0.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", @@ -350,7 +350,7 @@ dependencies = [ "core-foundation-sys 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "core-graphics 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 9.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "euclid 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)", + "euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)", "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "freetype-rs 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -470,7 +470,7 @@ dependencies = [ [[package]] name = "humantime" -version = "1.1.0" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -570,7 +570,7 @@ name = "libz-sys" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)", "pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -735,12 +735,12 @@ name = "num-traits" version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "num-traits" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -946,7 +946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1351,7 +1351,7 @@ dependencies = [ "checksum android_glue 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "000444226fcff248f2bc4c7625be32c63caccfecc2723a2b9f78a7487a49c407" "checksum ansi_term 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6b3568b48b7cefa6b8ce125f9bb4989e52fbcc29ebea88df04cc7c5f12f70455" "checksum approx 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "08abcc3b4e9339e33a3d0a5ed15d84a687350c05689d825e0f6655eef9e76a94" -"checksum arraydeque 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e086e04591633197d09ce022aef751d0d050923b9426654d615005516a57fb8d" +"checksum arraydeque 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bc059aa8598b9f4fb1dd532a061edc8e4efe0ccc55ba05358aba2a80b7b01f11" "checksum atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8352656fd42c30a0c3c89d26dea01e3b77c0ab2af18230835c15e2e13cd51859" "checksum base64 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "229d032f1a99302697f10b27167ae6d03d49d032e6a8e2550e8d3fc13356d2b4" "checksum bitflags 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dead7461c1127cf637931a1e50934eb6eee8bff2f74433ac7909e9afcee04a3" @@ -1363,7 +1363,7 @@ dependencies = [ "checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" "checksum bytes 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c129aff112dcc562970abb69e2508b40850dd24c274761bb50fb8a0067ba6c27" "checksum cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "be1057b8462184f634c3a208ee35b0f935cfd94b694b26deadccd98732088d7b" -"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" +"checksum cc 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9be26b24e988625409b19736d130f0c7d224f01d06454b5f81d8d23d6c1a618f" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum cgl 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "86765cb42c2a2c497e142af72517c1b4d7ae5bb2f25dfa77a5c69642f2342d89" "checksum cgmath 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6f3f4e27f2647652606e9faab058dd8686513a23b276fcd16e85eb0927838ddc" @@ -1381,7 +1381,7 @@ dependencies = [ "checksum either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "740178ddf48b1a9e878e6d6509a1442a2d42fd2928aae8e7a6f8a36fb01981b3" "checksum env_logger 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "f3cc21490995c841d68e00276eba02071ebb269ec24011d5728bd00eabd39e31" "checksum errno 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b2c858c42ac0b88532f48fca88b0ed947cad4f1f64d904bcd6c9f138f7b95d70" -"checksum euclid 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b2744c002882c67d0f6d6e8cfdf16eae729dc27744d312745132e62218b7de5c" +"checksum euclid 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5069a1354a7eecfdedc97e8e931b1fc455c4d06f5910380a3a049327ca7a0d0a" "checksum expat-sys 2.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "c470ccb972f2088549b023db8029ed9da9426f5affbf9b62efff7009ab8ed5b1" "checksum filetime 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "714653f3e34871534de23771ac7b26e999651a0a228f47beb324dfdf1dd4b10f" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" @@ -1397,7 +1397,7 @@ dependencies = [ "checksum gl_generator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a795170cbd85b5a7baa58d6d7525cae6a03e486859860c220f7ebbbdd379d0a" "checksum gleam 0.4.23 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a7f5351837630a7dd0cd6d7976de547929f9fabd381b9d5ac35f82e90be2" "checksum glutin 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba95f3bb8c3809d3a4ca3d988d35d33248116594eeaaa6fa3be68ab68d0862cb" -"checksum humantime 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5369e01a05e3404c421b5d6dcfea6ecf7d5e65eba8a275948151358cd8282042" +"checksum humantime 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0484fda3e7007f2a4a0d9c3a703ca38c71c54c55602ce4660c419fd32e188c9e" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" "checksum inotify 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887fcc180136e77a85e6a6128579a719027b1bab9b1c38ea4444244fe262c20c" @@ -1428,7 +1428,7 @@ dependencies = [ "checksum nix 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bfb3ddedaa14746434a02041940495bf11325c22f6d36125d3bdd56090d50a79" "checksum notify 4.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "5c3812da3098f210a0bb440f9c008471a031aa4c1de07a264fdd75456c95a4eb" "checksum num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)" = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" -"checksum num-traits 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e7de20f146db9d920c45ee8ed8f71681fd9ade71909b48c3acbd766aa504cf10" +"checksum num-traits 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b3c2bd9b9d21e48e956b763c9f37134dc62d9e95da6edb3f672cacb6caf3cd3" "checksum objc 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "877f30f37acef6749b1841cceab289707f211aecfc756553cd63976190e6cc2e" "checksum objc-foundation 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9" "checksum objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4730aa1c64d722db45f7ccc4113a3e2c465d018de6db4d3e7dfe031e8c8a297" diff --git a/src/ansi.rs b/src/ansi.rs index 3bcfff88..b59959f5 100644 --- a/src/ansi.rs +++ b/src/ansi.rs @@ -65,7 +65,7 @@ fn parse_rgb_color(color: &[u8]) -> Option { if next!() != Some('/') { return None; } let b = parse_hex!(); - Some(Rgb { r: r, g: g, b: b}) + Some(Rgb { r, g, b }) } Some('#') => { Some(Rgb { @@ -128,8 +128,8 @@ impl<'a, H: Handler + TermInfo + 'a, W: io::Write> Performer<'a, H, W> { ) -> Performer<'b, H, W> { Performer { _state: state, - handler: handler, - writer: writer, + handler, + writer, } } } diff --git a/src/config.rs b/src/config.rs index be967150..eb7f0f72 100644 --- a/src/config.rs +++ b/src/config.rs @@ -214,7 +214,7 @@ impl<'a> Shell<'a> { { Shell { program: program.into(), - args: args + args, } } @@ -678,9 +678,9 @@ struct RawBinding { impl RawBinding { fn into_mouse_binding(self) -> ::std::result::Result { - if self.mouse.is_some() { + if let Some(mouse) = self.mouse { Ok(Binding { - trigger: self.mouse.unwrap(), + trigger: mouse, mods: self.mods, action: self.action, mode: self.mode, @@ -692,9 +692,9 @@ impl RawBinding { } fn into_key_binding(self) -> ::std::result::Result { - if self.key.is_some() { + if let Some(key) = self.key { Ok(KeyBinding { - trigger: self.key.unwrap(), + trigger: key, mods: self.mods, action: self.action, mode: self.mode, @@ -865,12 +865,12 @@ impl<'a> de::Deserialize<'a> for RawBinding { } Ok(RawBinding { - mode: mode, + mode, notmode: not_mode, - action: action, - key: key, - mouse: mouse, - mods: mods, + action, + key, + mouse, + mods, }) } } @@ -977,8 +977,8 @@ impl CursorOrPrimaryColors { fn into_cursor_colors(self) -> CursorColors { match self { CursorOrPrimaryColors::Cursor { text, cursor } => CursorColors { - text: text, - cursor: cursor + text, + cursor, }, CursorOrPrimaryColors::Primary { foreground, background } => { // Must print in config since logger isn't setup yet. @@ -1124,12 +1124,12 @@ impl FromStr for Rgb { macro_rules! component { ($($c:ident),*) => { $( - match chars.next().unwrap().to_digit(16) { + match chars.next().and_then(|c| c.to_digit(16)) { Some(val) => rgb.$c = (val as u8) << 4, None => return Err(()) } - match chars.next().unwrap().to_digit(16) { + match chars.next().and_then(|c| c.to_digit(16)) { Some(val) => rgb.$c |= val as u8, None => return Err(()) } @@ -1137,9 +1137,9 @@ impl FromStr for Rgb { } } - match chars.next().unwrap() { - '0' => if chars.next().unwrap() != 'x' { return Err(()); }, - '#' => (), + match chars.next() { + Some('0') => if chars.next() != Some('x') { return Err(()); }, + Some('#') => (), _ => return Err(()), } @@ -1429,8 +1429,8 @@ impl Default for Dimensions { impl Dimensions { pub fn new(columns: Column, lines: Line) -> Self { Dimensions { - columns: columns, - lines: lines + columns, + lines, } } @@ -1668,7 +1668,8 @@ impl Monitor { _thread: ::util::thread::spawn_named("config watcher", move || { let (tx, rx) = mpsc::channel(); // The Duration argument is a debouncing period. - let mut watcher = watcher(tx, Duration::from_millis(10)).unwrap(); + let mut watcher = watcher(tx, Duration::from_millis(10)) + .expect("Unable to spawn file watcher"); let config_path = ::std::fs::canonicalize(path) .expect("canonicalize config path"); @@ -1742,7 +1743,6 @@ enum Key { Key8, Key9, Key0, - A, B, C, @@ -1769,9 +1769,7 @@ enum Key { X, Y, Z, - Escape, - F1, F2, F3, @@ -1787,7 +1785,6 @@ enum Key { F13, F14, F15, - Snapshot, Scroll, Pause, @@ -1797,7 +1794,6 @@ enum Key { End, PageDown, PageUp, - Left, Up, Right, @@ -1817,7 +1813,6 @@ enum Key { Numpad7, Numpad8, Numpad9, - AbntC1, AbntC2, Add, diff --git a/src/display.rs b/src/display.rs index 9227037e..418f616e 100644 --- a/src/display.rs +++ b/src/display.rs @@ -198,15 +198,15 @@ impl Display { }); Ok(Display { - window: window, - renderer: renderer, - glyph_cache: glyph_cache, - render_timer: render_timer, - tx: tx, - rx: rx, + window, + renderer, + glyph_cache, + render_timer, + tx, + rx, meter: Meter::new(), font_size: font::Size::new(0.), - size_info: size_info, + size_info, last_background_color: background_color, }) } diff --git a/src/event.rs b/src/event.rs index b133f8fa..8c4107ca 100644 --- a/src/event.rs +++ b/src/event.rs @@ -227,12 +227,12 @@ impl Processor { mouse_config: config.mouse().to_owned(), print_events: options.print_events, wait_for_event: true, - notifier: notifier, - resize_tx: resize_tx, - ref_test: ref_test, + notifier, + resize_tx, + ref_test, mouse: Default::default(), selection: None, - size_info: size_info, + size_info, hide_cursor_when_typing: config.hide_cursor_when_typing(), hide_cursor: false, received_count: 0, diff --git a/src/event_loop.rs b/src/event_loop.rs index 30732e2a..ce034ff0 100644 --- a/src/event_loop.rs +++ b/src/event_loop.rs @@ -179,12 +179,12 @@ impl EventLoop let (tx, rx) = channel::channel(); EventLoop { poll: mio::Poll::new().expect("create mio Poll"), - pty: pty, - tx: tx, - rx: rx, - terminal: terminal, - display: display, - ref_test: ref_test, + pty, + tx, + rx, + terminal, + display, + ref_test, } } diff --git a/src/grid.rs b/src/grid.rs index ed7efdb4..f40ceec9 100644 --- a/src/grid.rs +++ b/src/grid.rs @@ -82,9 +82,9 @@ impl Grid { } Grid { - raw: raw, - cols: cols, - lines: lines, + raw, + cols, + lines, } } diff --git a/src/index.rs b/src/index.rs index 7fb591f4..418faff2 100644 --- a/src/index.rs +++ b/src/index.rs @@ -35,7 +35,7 @@ pub struct Point { impl Point { pub fn new(line: Line, col: Column) -> Point { - Point { line: line, col: col } + Point { line, col } } } diff --git a/src/logging.rs b/src/logging.rs index ff2a7735..421223e8 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -32,7 +32,7 @@ impl Logger { #[cfg_attr(feature = "clippy", allow(new_ret_no_self))] pub fn new(output: T, level: log::LevelFilter) -> Logger> { Logger { - level: level, + level, output: sync::Mutex::new(io::LineWriter::new(output)) } } diff --git a/src/meter.rs b/src/meter.rs index 51e68c34..1b6003db 100644 --- a/src/meter.rs +++ b/src/meter.rs @@ -62,7 +62,7 @@ pub struct Sampler<'a> { impl<'a> Sampler<'a> { fn new(meter: &'a mut Meter) -> Sampler<'a> { Sampler { - meter: meter, + meter, created_at: Instant::now(), } } diff --git a/src/renderer/mod.rs b/src/renderer/mod.rs index c0e4a9f3..5b53e70f 100644 --- a/src/renderer/mod.rs +++ b/src/renderer/mod.rs @@ -188,13 +188,13 @@ impl GlyphCache { let mut cache = GlyphCache { cache: HashMap::default(), - rasterizer: rasterizer, + rasterizer, font_size: font.size(), font_key: regular, bold_key: bold, italic_key: italic, glyph_offset: *font.glyph_offset(), - metrics: metrics + metrics, }; cache.load_glyphs_for_font(regular, loader); @@ -214,7 +214,7 @@ impl GlyphCache { self.get(&GlyphKey { font_key: font, c: i as char, - size: size + size, }, loader); } } @@ -262,7 +262,7 @@ impl GlyphCache { let style = if let Some(ref spec) = desc.style { font::Style::Specific(spec.to_owned()) } else { - font::Style::Description {slant:slant, weight:weight} + font::Style::Description { slant, weight } }; FontDesc::new(&desc.family[..], style) } @@ -606,11 +606,11 @@ impl QuadRenderer { } let mut renderer = QuadRenderer { - program: program, - vao: vao, - vbo: vbo, - ebo: ebo, - vbo_instance: vbo_instance, + program, + vao, + vbo, + ebo, + vbo_instance, atlas: Vec::new(), current_atlas: 0, active_tex: 0, @@ -662,7 +662,7 @@ impl QuadRenderer { current_atlas: &mut self.current_atlas, program: &mut self.program, visual_bell_intensity: visual_bell_intensity as _, - config: config, + config, }); unsafe { @@ -789,9 +789,9 @@ impl<'a> RenderApi<'a> { let cells = string.chars() .enumerate() .map(|(i, c)| RenderableCell { - line: line, + line, column: col + i, - c: c, + c, bg: color, fg: Rgb { r: 0, g: 0, b: 0 }, flags: cell::Flags::empty(), @@ -835,7 +835,7 @@ impl<'a> RenderApi<'a> { } let glyph_key = GlyphKey { - font_key: font_key, + font_key, size: glyph_cache.font_size, c: cell.c }; @@ -851,7 +851,7 @@ impl<'a> RenderApi<'a> { // easy, clean hack. if cell.flags.contains(cell::Flags::UNDERLINE) { let glyph_key = GlyphKey { - font_key: font_key, + font_key, size: glyph_cache.font_size, c: '_' }; @@ -1332,7 +1332,7 @@ impl Atlas { } Atlas { - id: id, + id, width: size, height: size, row_extent: 0, @@ -1424,10 +1424,10 @@ impl Atlas { width: width as f32, height: height as f32, left: glyph.left as f32, - uv_bot: uv_bot, - uv_left: uv_left, - uv_width: uv_width, - uv_height: uv_height, + uv_bot, + uv_left, + uv_width, + uv_height, } } diff --git a/src/selection.rs b/src/selection.rs index 92410104..cd905164 100644 --- a/src/selection.rs +++ b/src/selection.rs @@ -75,7 +75,7 @@ pub struct Anchor { impl Anchor { fn new(point: Point, side: Side) -> Anchor { - Anchor { point: point, side: side } + Anchor { point, side } } } @@ -114,8 +114,8 @@ impl Selection { end: point, }, initial_expansion: Region { - start: start, - end: end + start, + end, } } } @@ -248,10 +248,10 @@ impl Selection { return None; } else { return Some(Span { - cols: cols, + cols, ty: SpanType::Inclusive, - front: front, - tail: tail + front, + tail, }); } } @@ -266,30 +266,30 @@ impl Selection { Some(match (front_side, tail_side) { // [FX][XX][XT] (Side::Left, Side::Right) => Span { - cols: cols, - front: front, - tail: tail, + cols, + front, + tail, ty: SpanType::Inclusive }, // [ F][XX][T ] (Side::Right, Side::Left) => Span { - cols: cols, - front: front, - tail: tail, + cols, + front, + tail, ty: SpanType::Exclusive }, // [FX][XX][T ] (Side::Left, Side::Left) => Span { - cols: cols, - front: front, - tail: tail, + cols, + front, + tail, ty: SpanType::ExcludeTail }, // [ F][XX][XT] (Side::Right, Side::Right) => Span { - cols: cols, - front: front, - tail: tail, + cols, + front, + tail, ty: SpanType::ExcludeFront }, }) diff --git a/src/term/cell.rs b/src/term/cell.rs index 16e08cba..a04eb8e1 100644 --- a/src/term/cell.rs +++ b/src/term/cell.rs @@ -92,9 +92,9 @@ impl Cell { pub fn new(c: char, fg: Color, bg: Color) -> Cell { Cell { - c: c, - bg: bg, - fg: fg, + c, + bg, + fg, flags: Flags::empty(), } } diff --git a/src/term/mod.rs b/src/term/mod.rs index b11733f6..00244c8a 100644 --- a/src/term/mod.rs +++ b/src/term/mod.rs @@ -123,15 +123,15 @@ impl<'a> RenderableCellsIter<'a> { let cursor_index = Linear(cursor.line.0 * grid.num_cols().0 + cursor.col.0); RenderableCellsIter { - grid: grid, - cursor: cursor, - cursor_index: cursor_index, - mode: mode, + grid, + cursor, + cursor_index, + mode, line: Line(0), column: Column(0), - selection: selection, - config: config, - colors: colors, + selection, + config, + colors, cursor_cells: ArrayDeque::new(), }.initialize(cursor_style) } @@ -396,13 +396,13 @@ impl<'a> Iterator for RenderableCellsIter<'a> { } return Some(RenderableCell { - line: line, - column: column, + line, + column, flags: cell.flags, c: cell.c, fg: fg_rgb, bg: bg_rgb, - bg_alpha: bg_alpha, + bg_alpha, }) } @@ -816,7 +816,7 @@ impl Term { visual_bell: VisualBell::new(config), next_is_urgent: None, input_needs_wrap: false, - grid: grid, + grid, alt_grid: alt, alt: false, font_size: config.font().size(), @@ -825,9 +825,9 @@ impl Term { cursor: Default::default(), cursor_save: Default::default(), cursor_save_alt: Default::default(), - tabs: tabs, + tabs, mode: Default::default(), - scroll_region: scroll_region, + scroll_region, size_info: size, colors: color::List::from(config.colors()), color_modified: [false; color::COUNT], diff --git a/src/window.rs b/src/window.rs index 55b7cd55..9644cd42 100644 --- a/src/window.rs +++ b/src/window.rs @@ -216,8 +216,8 @@ impl Window { } let window = Window { - event_loop: event_loop, - window: window, + event_loop, + window, cursor_visible: true, is_focused: true, };