1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

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)
This commit is contained in:
Christian Duerr 2018-03-04 22:40:15 +00:00 committed by GitHub
parent 475ebecfc4
commit 7f2b398ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 119 additions and 124 deletions

34
Cargo.lock generated
View file

@ -10,7 +10,7 @@ dependencies = [
name = "alacritty" name = "alacritty"
version = "0.1.0" version = "0.1.0"
dependencies = [ 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)", "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)", "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)", "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]] [[package]]
name = "arraydeque" name = "arraydeque"
version = "0.4.1" version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -131,7 +131,7 @@ dependencies = [
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.4" version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -207,7 +207,7 @@ name = "cmake"
version = "0.1.29" version = "0.1.29"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ 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]] [[package]]
@ -294,7 +294,7 @@ version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"atty 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "termcolor 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
@ -312,7 +312,7 @@ dependencies = [
[[package]] [[package]]
name = "euclid" name = "euclid"
version = "0.17.0" version = "0.17.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)", "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-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-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)", "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)", "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)", "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)", "libc 0.2.37 (registry+https://github.com/rust-lang/crates.io-index)",
@ -470,7 +470,7 @@ dependencies = [
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "1.1.0" version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "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" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ 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)", "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)", "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)", "vcpkg 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -735,12 +735,12 @@ name = "num-traits"
version = "0.1.43" version = "0.1.43"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ 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]] [[package]]
name = "num-traits" name = "num-traits"
version = "0.2.0" version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
@ -946,7 +946,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [ dependencies = [
"dtoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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 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 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 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 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 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" "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 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 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 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 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 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" "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 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 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 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 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 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" "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 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 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 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 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 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" "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 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 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.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 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-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" "checksum objc_id 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e4730aa1c64d722db45f7ccc4113a3e2c465d018de6db4d3e7dfe031e8c8a297"

View file

@ -65,7 +65,7 @@ fn parse_rgb_color(color: &[u8]) -> Option<Rgb> {
if next!() != Some('/') { return None; } if next!() != Some('/') { return None; }
let b = parse_hex!(); let b = parse_hex!();
Some(Rgb { r: r, g: g, b: b}) Some(Rgb { r, g, b })
} }
Some('#') => { Some('#') => {
Some(Rgb { Some(Rgb {
@ -128,8 +128,8 @@ impl<'a, H: Handler + TermInfo + 'a, W: io::Write> Performer<'a, H, W> {
) -> Performer<'b, H, W> { ) -> Performer<'b, H, W> {
Performer { Performer {
_state: state, _state: state,
handler: handler, handler,
writer: writer, writer,
} }
} }
} }

View file

@ -214,7 +214,7 @@ impl<'a> Shell<'a> {
{ {
Shell { Shell {
program: program.into(), program: program.into(),
args: args args,
} }
} }
@ -678,9 +678,9 @@ struct RawBinding {
impl RawBinding { impl RawBinding {
fn into_mouse_binding(self) -> ::std::result::Result<MouseBinding, Self> { fn into_mouse_binding(self) -> ::std::result::Result<MouseBinding, Self> {
if self.mouse.is_some() { if let Some(mouse) = self.mouse {
Ok(Binding { Ok(Binding {
trigger: self.mouse.unwrap(), trigger: mouse,
mods: self.mods, mods: self.mods,
action: self.action, action: self.action,
mode: self.mode, mode: self.mode,
@ -692,9 +692,9 @@ impl RawBinding {
} }
fn into_key_binding(self) -> ::std::result::Result<KeyBinding, Self> { fn into_key_binding(self) -> ::std::result::Result<KeyBinding, Self> {
if self.key.is_some() { if let Some(key) = self.key {
Ok(KeyBinding { Ok(KeyBinding {
trigger: self.key.unwrap(), trigger: key,
mods: self.mods, mods: self.mods,
action: self.action, action: self.action,
mode: self.mode, mode: self.mode,
@ -865,12 +865,12 @@ impl<'a> de::Deserialize<'a> for RawBinding {
} }
Ok(RawBinding { Ok(RawBinding {
mode: mode, mode,
notmode: not_mode, notmode: not_mode,
action: action, action,
key: key, key,
mouse: mouse, mouse,
mods: mods, mods,
}) })
} }
} }
@ -977,8 +977,8 @@ impl CursorOrPrimaryColors {
fn into_cursor_colors(self) -> CursorColors { fn into_cursor_colors(self) -> CursorColors {
match self { match self {
CursorOrPrimaryColors::Cursor { text, cursor } => CursorColors { CursorOrPrimaryColors::Cursor { text, cursor } => CursorColors {
text: text, text,
cursor: cursor cursor,
}, },
CursorOrPrimaryColors::Primary { foreground, background } => { CursorOrPrimaryColors::Primary { foreground, background } => {
// Must print in config since logger isn't setup yet. // Must print in config since logger isn't setup yet.
@ -1124,12 +1124,12 @@ impl FromStr for Rgb {
macro_rules! component { macro_rules! component {
($($c:ident),*) => { ($($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, Some(val) => rgb.$c = (val as u8) << 4,
None => return Err(()) 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, Some(val) => rgb.$c |= val as u8,
None => return Err(()) None => return Err(())
} }
@ -1137,9 +1137,9 @@ impl FromStr for Rgb {
} }
} }
match chars.next().unwrap() { match chars.next() {
'0' => if chars.next().unwrap() != 'x' { return Err(()); }, Some('0') => if chars.next() != Some('x') { return Err(()); },
'#' => (), Some('#') => (),
_ => return Err(()), _ => return Err(()),
} }
@ -1429,8 +1429,8 @@ impl Default for Dimensions {
impl Dimensions { impl Dimensions {
pub fn new(columns: Column, lines: Line) -> Self { pub fn new(columns: Column, lines: Line) -> Self {
Dimensions { Dimensions {
columns: columns, columns,
lines: lines lines,
} }
} }
@ -1668,7 +1668,8 @@ impl Monitor {
_thread: ::util::thread::spawn_named("config watcher", move || { _thread: ::util::thread::spawn_named("config watcher", move || {
let (tx, rx) = mpsc::channel(); let (tx, rx) = mpsc::channel();
// The Duration argument is a debouncing period. // 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) let config_path = ::std::fs::canonicalize(path)
.expect("canonicalize config path"); .expect("canonicalize config path");
@ -1742,7 +1743,6 @@ enum Key {
Key8, Key8,
Key9, Key9,
Key0, Key0,
A, A,
B, B,
C, C,
@ -1769,9 +1769,7 @@ enum Key {
X, X,
Y, Y,
Z, Z,
Escape, Escape,
F1, F1,
F2, F2,
F3, F3,
@ -1787,7 +1785,6 @@ enum Key {
F13, F13,
F14, F14,
F15, F15,
Snapshot, Snapshot,
Scroll, Scroll,
Pause, Pause,
@ -1797,7 +1794,6 @@ enum Key {
End, End,
PageDown, PageDown,
PageUp, PageUp,
Left, Left,
Up, Up,
Right, Right,
@ -1817,7 +1813,6 @@ enum Key {
Numpad7, Numpad7,
Numpad8, Numpad8,
Numpad9, Numpad9,
AbntC1, AbntC1,
AbntC2, AbntC2,
Add, Add,

View file

@ -198,15 +198,15 @@ impl Display {
}); });
Ok(Display { Ok(Display {
window: window, window,
renderer: renderer, renderer,
glyph_cache: glyph_cache, glyph_cache,
render_timer: render_timer, render_timer,
tx: tx, tx,
rx: rx, rx,
meter: Meter::new(), meter: Meter::new(),
font_size: font::Size::new(0.), font_size: font::Size::new(0.),
size_info: size_info, size_info,
last_background_color: background_color, last_background_color: background_color,
}) })
} }

View file

@ -227,12 +227,12 @@ impl<N: Notify> Processor<N> {
mouse_config: config.mouse().to_owned(), mouse_config: config.mouse().to_owned(),
print_events: options.print_events, print_events: options.print_events,
wait_for_event: true, wait_for_event: true,
notifier: notifier, notifier,
resize_tx: resize_tx, resize_tx,
ref_test: ref_test, ref_test,
mouse: Default::default(), mouse: Default::default(),
selection: None, selection: None,
size_info: size_info, size_info,
hide_cursor_when_typing: config.hide_cursor_when_typing(), hide_cursor_when_typing: config.hide_cursor_when_typing(),
hide_cursor: false, hide_cursor: false,
received_count: 0, received_count: 0,

View file

@ -179,12 +179,12 @@ impl<Io> EventLoop<Io>
let (tx, rx) = channel::channel(); let (tx, rx) = channel::channel();
EventLoop { EventLoop {
poll: mio::Poll::new().expect("create mio Poll"), poll: mio::Poll::new().expect("create mio Poll"),
pty: pty, pty,
tx: tx, tx,
rx: rx, rx,
terminal: terminal, terminal,
display: display, display,
ref_test: ref_test, ref_test,
} }
} }

View file

@ -82,9 +82,9 @@ impl<T: Clone> Grid<T> {
} }
Grid { Grid {
raw: raw, raw,
cols: cols, cols,
lines: lines, lines,
} }
} }

View file

@ -35,7 +35,7 @@ pub struct Point {
impl Point { impl Point {
pub fn new(line: Line, col: Column) -> Point { pub fn new(line: Line, col: Column) -> Point {
Point { line: line, col: col } Point { line, col }
} }
} }

View file

@ -32,7 +32,7 @@ impl<T: Send + io::Write> Logger<T> {
#[cfg_attr(feature = "clippy", allow(new_ret_no_self))] #[cfg_attr(feature = "clippy", allow(new_ret_no_self))]
pub fn new(output: T, level: log::LevelFilter) -> Logger<io::LineWriter<T>> { pub fn new(output: T, level: log::LevelFilter) -> Logger<io::LineWriter<T>> {
Logger { Logger {
level: level, level,
output: sync::Mutex::new(io::LineWriter::new(output)) output: sync::Mutex::new(io::LineWriter::new(output))
} }
} }

View file

@ -62,7 +62,7 @@ pub struct Sampler<'a> {
impl<'a> Sampler<'a> { impl<'a> Sampler<'a> {
fn new(meter: &'a mut Meter) -> Sampler<'a> { fn new(meter: &'a mut Meter) -> Sampler<'a> {
Sampler { Sampler {
meter: meter, meter,
created_at: Instant::now(), created_at: Instant::now(),
} }
} }

View file

@ -188,13 +188,13 @@ impl GlyphCache {
let mut cache = GlyphCache { let mut cache = GlyphCache {
cache: HashMap::default(), cache: HashMap::default(),
rasterizer: rasterizer, rasterizer,
font_size: font.size(), font_size: font.size(),
font_key: regular, font_key: regular,
bold_key: bold, bold_key: bold,
italic_key: italic, italic_key: italic,
glyph_offset: *font.glyph_offset(), glyph_offset: *font.glyph_offset(),
metrics: metrics metrics,
}; };
cache.load_glyphs_for_font(regular, loader); cache.load_glyphs_for_font(regular, loader);
@ -214,7 +214,7 @@ impl GlyphCache {
self.get(&GlyphKey { self.get(&GlyphKey {
font_key: font, font_key: font,
c: i as char, c: i as char,
size: size size,
}, loader); }, loader);
} }
} }
@ -262,7 +262,7 @@ impl GlyphCache {
let style = if let Some(ref spec) = desc.style { let style = if let Some(ref spec) = desc.style {
font::Style::Specific(spec.to_owned()) font::Style::Specific(spec.to_owned())
} else { } else {
font::Style::Description {slant:slant, weight:weight} font::Style::Description { slant, weight }
}; };
FontDesc::new(&desc.family[..], style) FontDesc::new(&desc.family[..], style)
} }
@ -606,11 +606,11 @@ impl QuadRenderer {
} }
let mut renderer = QuadRenderer { let mut renderer = QuadRenderer {
program: program, program,
vao: vao, vao,
vbo: vbo, vbo,
ebo: ebo, ebo,
vbo_instance: vbo_instance, vbo_instance,
atlas: Vec::new(), atlas: Vec::new(),
current_atlas: 0, current_atlas: 0,
active_tex: 0, active_tex: 0,
@ -662,7 +662,7 @@ impl QuadRenderer {
current_atlas: &mut self.current_atlas, current_atlas: &mut self.current_atlas,
program: &mut self.program, program: &mut self.program,
visual_bell_intensity: visual_bell_intensity as _, visual_bell_intensity: visual_bell_intensity as _,
config: config, config,
}); });
unsafe { unsafe {
@ -789,9 +789,9 @@ impl<'a> RenderApi<'a> {
let cells = string.chars() let cells = string.chars()
.enumerate() .enumerate()
.map(|(i, c)| RenderableCell { .map(|(i, c)| RenderableCell {
line: line, line,
column: col + i, column: col + i,
c: c, c,
bg: color, bg: color,
fg: Rgb { r: 0, g: 0, b: 0 }, fg: Rgb { r: 0, g: 0, b: 0 },
flags: cell::Flags::empty(), flags: cell::Flags::empty(),
@ -835,7 +835,7 @@ impl<'a> RenderApi<'a> {
} }
let glyph_key = GlyphKey { let glyph_key = GlyphKey {
font_key: font_key, font_key,
size: glyph_cache.font_size, size: glyph_cache.font_size,
c: cell.c c: cell.c
}; };
@ -851,7 +851,7 @@ impl<'a> RenderApi<'a> {
// easy, clean hack. // easy, clean hack.
if cell.flags.contains(cell::Flags::UNDERLINE) { if cell.flags.contains(cell::Flags::UNDERLINE) {
let glyph_key = GlyphKey { let glyph_key = GlyphKey {
font_key: font_key, font_key,
size: glyph_cache.font_size, size: glyph_cache.font_size,
c: '_' c: '_'
}; };
@ -1332,7 +1332,7 @@ impl Atlas {
} }
Atlas { Atlas {
id: id, id,
width: size, width: size,
height: size, height: size,
row_extent: 0, row_extent: 0,
@ -1424,10 +1424,10 @@ impl Atlas {
width: width as f32, width: width as f32,
height: height as f32, height: height as f32,
left: glyph.left as f32, left: glyph.left as f32,
uv_bot: uv_bot, uv_bot,
uv_left: uv_left, uv_left,
uv_width: uv_width, uv_width,
uv_height: uv_height, uv_height,
} }
} }

View file

@ -75,7 +75,7 @@ pub struct Anchor {
impl Anchor { impl Anchor {
fn new(point: Point, side: Side) -> Anchor { fn new(point: Point, side: Side) -> Anchor {
Anchor { point: point, side: side } Anchor { point, side }
} }
} }
@ -114,8 +114,8 @@ impl Selection {
end: point, end: point,
}, },
initial_expansion: Region { initial_expansion: Region {
start: start, start,
end: end end,
} }
} }
} }
@ -248,10 +248,10 @@ impl Selection {
return None; return None;
} else { } else {
return Some(Span { return Some(Span {
cols: cols, cols,
ty: SpanType::Inclusive, ty: SpanType::Inclusive,
front: front, front,
tail: tail tail,
}); });
} }
} }
@ -266,30 +266,30 @@ impl Selection {
Some(match (front_side, tail_side) { Some(match (front_side, tail_side) {
// [FX][XX][XT] // [FX][XX][XT]
(Side::Left, Side::Right) => Span { (Side::Left, Side::Right) => Span {
cols: cols, cols,
front: front, front,
tail: tail, tail,
ty: SpanType::Inclusive ty: SpanType::Inclusive
}, },
// [ F][XX][T ] // [ F][XX][T ]
(Side::Right, Side::Left) => Span { (Side::Right, Side::Left) => Span {
cols: cols, cols,
front: front, front,
tail: tail, tail,
ty: SpanType::Exclusive ty: SpanType::Exclusive
}, },
// [FX][XX][T ] // [FX][XX][T ]
(Side::Left, Side::Left) => Span { (Side::Left, Side::Left) => Span {
cols: cols, cols,
front: front, front,
tail: tail, tail,
ty: SpanType::ExcludeTail ty: SpanType::ExcludeTail
}, },
// [ F][XX][XT] // [ F][XX][XT]
(Side::Right, Side::Right) => Span { (Side::Right, Side::Right) => Span {
cols: cols, cols,
front: front, front,
tail: tail, tail,
ty: SpanType::ExcludeFront ty: SpanType::ExcludeFront
}, },
}) })

View file

@ -92,9 +92,9 @@ impl Cell {
pub fn new(c: char, fg: Color, bg: Color) -> Cell { pub fn new(c: char, fg: Color, bg: Color) -> Cell {
Cell { Cell {
c: c, c,
bg: bg, bg,
fg: fg, fg,
flags: Flags::empty(), flags: Flags::empty(),
} }
} }

View file

@ -123,15 +123,15 @@ impl<'a> RenderableCellsIter<'a> {
let cursor_index = Linear(cursor.line.0 * grid.num_cols().0 + cursor.col.0); let cursor_index = Linear(cursor.line.0 * grid.num_cols().0 + cursor.col.0);
RenderableCellsIter { RenderableCellsIter {
grid: grid, grid,
cursor: cursor, cursor,
cursor_index: cursor_index, cursor_index,
mode: mode, mode,
line: Line(0), line: Line(0),
column: Column(0), column: Column(0),
selection: selection, selection,
config: config, config,
colors: colors, colors,
cursor_cells: ArrayDeque::new(), cursor_cells: ArrayDeque::new(),
}.initialize(cursor_style) }.initialize(cursor_style)
} }
@ -396,13 +396,13 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
} }
return Some(RenderableCell { return Some(RenderableCell {
line: line, line,
column: column, column,
flags: cell.flags, flags: cell.flags,
c: cell.c, c: cell.c,
fg: fg_rgb, fg: fg_rgb,
bg: bg_rgb, bg: bg_rgb,
bg_alpha: bg_alpha, bg_alpha,
}) })
} }
@ -816,7 +816,7 @@ impl Term {
visual_bell: VisualBell::new(config), visual_bell: VisualBell::new(config),
next_is_urgent: None, next_is_urgent: None,
input_needs_wrap: false, input_needs_wrap: false,
grid: grid, grid,
alt_grid: alt, alt_grid: alt,
alt: false, alt: false,
font_size: config.font().size(), font_size: config.font().size(),
@ -825,9 +825,9 @@ impl Term {
cursor: Default::default(), cursor: Default::default(),
cursor_save: Default::default(), cursor_save: Default::default(),
cursor_save_alt: Default::default(), cursor_save_alt: Default::default(),
tabs: tabs, tabs,
mode: Default::default(), mode: Default::default(),
scroll_region: scroll_region, scroll_region,
size_info: size, size_info: size,
colors: color::List::from(config.colors()), colors: color::List::from(config.colors()),
color_modified: [false; color::COUNT], color_modified: [false; color::COUNT],

View file

@ -216,8 +216,8 @@ impl Window {
} }
let window = Window { let window = Window {
event_loop: event_loop, event_loop,
window: window, window,
cursor_visible: true, cursor_visible: true,
is_focused: true, is_focused: true,
}; };