Fix formatting and clippy warnings

This commit is contained in:
Adrian Wozniak 2019-12-20 20:49:40 +01:00
parent 42820c52f5
commit 7cf3e9de18
5 changed files with 15 additions and 19 deletions

View File

@ -101,7 +101,7 @@ impl Config {
impl Config { impl Config {
pub fn load_theme(&self, theme_name: String) -> Theme { pub fn load_theme(&self, theme_name: String) -> Theme {
let home_dir = dirs::config_dir().unwrap(); let home_dir = dirs::config_dir().unwrap();
let mut config_dir = home_dir.clone(); let mut config_dir = home_dir;
config_dir.push("rider"); config_dir.push("rider");
fs::create_dir_all(&config_dir) fs::create_dir_all(&config_dir)
.unwrap_or_else(|_| panic!("Cannot create config directory")); .unwrap_or_else(|_| panic!("Cannot create config directory"));
@ -238,5 +238,4 @@ mod test_getters {
expected.sort(); expected.sort();
assert_eq!(result, expected); assert_eq!(result, expected);
} }
} }

View File

@ -74,7 +74,7 @@ pub fn project_dir() -> PathBuf {
#[cfg_attr(tarpaulin, skip)] #[cfg_attr(tarpaulin, skip)]
pub fn binaries_directory() -> Result<PathBuf, String> { pub fn binaries_directory() -> Result<PathBuf, String> {
let mut exec_dir = PathBuf::new(); let mut exec_dir = PathBuf::new();
exec_dir.push(dirs::executable_dir().unwrap().clone()); exec_dir.push(dirs::executable_dir().unwrap());
let mut rider_editor = exec_dir.clone(); let mut rider_editor = exec_dir.clone();
rider_editor.push("rider-editor"); rider_editor.push("rider-editor");
if rider_editor.exists() { if rider_editor.exists() {

View File

@ -29,7 +29,7 @@ fn init_logger(directories: &Directories) {
let mut log_file_path = directories.log_dir.clone(); let mut log_file_path = directories.log_dir.clone();
log_file_path.push("rider.log"); log_file_path.push("rider.log");
let mut outputs: Vec<Box<SharedLogger>> = vec![WriteLogger::new( let mut outputs: Vec<Box<dyn SharedLogger>> = vec![WriteLogger::new(
LevelFilter::Info, LevelFilter::Info,
Config::default(), Config::default(),
File::create(log_file_path).unwrap(), File::create(log_file_path).unwrap(),

View File

@ -1,7 +1,7 @@
use crate::app::UpdateResult as UR; use crate::app::UpdateResult as UR;
use crate::renderer::renderer::Renderer; use crate::renderer::renderer::Renderer;
use crate::ui::RenderContext as RC;
use crate::ui::*; use crate::ui::*;
use crate::ui::{RenderContext as RC, UpdateContext as UC};
use rider_config::ConfigAccess; use rider_config::ConfigAccess;
use rider_config::ConfigHolder; use rider_config::ConfigHolder;
use sdl2::pixels::Color; use sdl2::pixels::Color;
@ -53,8 +53,8 @@ impl Settings {
font_value: Label::new(c.editor_config().font_path().clone(), config.clone()), font_value: Label::new(c.editor_config().font_path().clone(), config.clone()),
character_size_label: Label::new("Character size".into(), config.clone()), character_size_label: Label::new("Character size".into(), config.clone()),
character_size_value: Label::new( character_size_value: Label::new(
format!("{}", c.editor_config().character_size()).to_owned(), format!("{}", c.editor_config().character_size()).to_owned(),
config.clone() config.clone(),
), ),
config: config.clone(), config: config.clone(),
} }
@ -127,10 +127,7 @@ impl Settings {
renderer, renderer,
&RC::ParentPosition( &RC::ParentPosition(
self.render_start_point() self.render_start_point()
+ Point::new( + Point::new(CONTENT_MARGIN_LEFT + LABEL_WIDTH, CONTENT_MARGIN_TOP)
CONTENT_MARGIN_LEFT + LABEL_WIDTH,
CONTENT_MARGIN_TOP,
)
+ self.scroll(), + self.scroll(),
), ),
); );
@ -142,9 +139,9 @@ impl Settings {
&RC::ParentPosition( &RC::ParentPosition(
self.render_start_point() self.render_start_point()
+ Point::new( + Point::new(
CONTENT_MARGIN_LEFT, CONTENT_MARGIN_LEFT,
CONTENT_MARGIN_TOP + self.font_label.dest().height() as i32 CONTENT_MARGIN_TOP + self.font_label.dest().height() as i32,
) )
+ self.scroll(), + self.scroll(),
), ),
); );
@ -154,8 +151,8 @@ impl Settings {
&RC::ParentPosition( &RC::ParentPosition(
self.render_start_point() self.render_start_point()
+ Point::new( + Point::new(
CONTENT_MARGIN_LEFT + LABEL_WIDTH, CONTENT_MARGIN_LEFT + LABEL_WIDTH,
CONTENT_MARGIN_TOP + self.font_label.dest().height() as i32, CONTENT_MARGIN_TOP + self.font_label.dest().height() as i32,
) )
+ self.scroll(), + self.scroll(),
), ),
@ -181,12 +178,12 @@ impl Settings {
impl ClickHandler for Settings { impl ClickHandler for Settings {
#[inline] #[inline]
fn on_left_click(&mut self, _point: &Point, context: &UpdateContext) -> UR { fn on_left_click(&mut self, _point: &Point, _context: &UpdateContext) -> UR {
UR::NoOp UR::NoOp
} }
#[inline] #[inline]
fn is_left_click_target(&self, _point: &Point, context: &UpdateContext) -> bool { fn is_left_click_target(&self, _point: &Point, _context: &UpdateContext) -> bool {
false false
} }
} }

View File

@ -17,7 +17,7 @@ fn write_theme(theme: &Theme, directories: &Directories) -> std::io::Result<()>
theme_path.push(directories.themes_dir.clone()); theme_path.push(directories.themes_dir.clone());
theme_path.push(format!("{}.json", theme.name())); theme_path.push(format!("{}.json", theme.name()));
let contents = serde_json::to_string_pretty(&theme).unwrap(); let contents = serde_json::to_string_pretty(&theme).unwrap();
fs::write(&theme_path, contents.clone())?; fs::write(&theme_path, contents)?;
Ok(()) Ok(())
} }