aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli/cmd/edit.rs8
-rw-r--r--src/cli/cmd/read.rs8
-rw-r--r--src/cli/mod.rs1
-rw-r--r--src/map/data.rs2
4 files changed, 16 insertions, 3 deletions
diff --git a/src/cli/cmd/edit.rs b/src/cli/cmd/edit.rs
index 797edc6..b164332 100644
--- a/src/cli/cmd/edit.rs
+++ b/src/cli/cmd/edit.rs
@@ -6,6 +6,7 @@ use crate::map::MapData;
use crate::Editor;
use std::path::PathBuf;
+/// Command to load a file from the disk and replace the current editor contents with it's info.
pub struct Edit {
file: PathBuf,
}
@@ -26,7 +27,12 @@ impl Command for Edit {
fn process(&self, editor: &mut Editor) -> Result<String, String> {
let data = match MapData::load_from_file(&self.file) {
Ok(data) => data,
- Err(err) => return Err(format!("Unable to read file: {:?}", &self.file)),
+ Err(err) => {
+ return Err(format!(
+ "Unable to read file: {:?}, reason: {:?}",
+ &self.file, err
+ ))
+ }
};
editor.map_mut().set_data(data);
diff --git a/src/cli/cmd/read.rs b/src/cli/cmd/read.rs
index 4ac671c..45cdf99 100644
--- a/src/cli/cmd/read.rs
+++ b/src/cli/cmd/read.rs
@@ -6,6 +6,7 @@ use crate::map::MapData;
use crate::Editor;
use std::path::PathBuf;
+/// Command to read a file from the system
pub struct Read {
file: PathBuf,
}
@@ -26,7 +27,12 @@ impl Command for Read {
fn process(&self, editor: &mut Editor) -> Result<String, String> {
let data = match MapData::load_from_file(&self.file) {
Ok(data) => data,
- Err(err) => return Err(format!("Unable to read file: {:?}", &self.file)),
+ Err(err) => {
+ return Err(format!(
+ "Unable to read file: {:?}, reason: {:?}",
+ &self.file, err
+ ))
+ }
};
editor.map_mut().add_data(data);
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index eda274f..a654e19 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -26,6 +26,7 @@ pub struct CLI {
impl CLI {
/// Create a CLI for this instance
+ #[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {
text: String::new(),
diff --git a/src/map/data.rs b/src/map/data.rs
index f7ec484..0c11d1c 100644
--- a/src/map/data.rs
+++ b/src/map/data.rs
@@ -44,7 +44,7 @@ impl MapData {
rect_rooms: map
.rect_rooms()
.iter()
- .map(|r| (r as &RectRoomData).clone())
+ .map(|r| *(r as &RectRoomData))
.collect(),
polygon_rooms: map
.polygon_rooms()