-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save formatted map to string #4. Also, apply cargo fmt
#5
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,16 @@ impl OrthogonalMaze { | |
let data = formatter.format(&self.grid); | ||
Saveable::save(&data, path) | ||
} | ||
|
||
// Saves a maze into a file to a given path using a given formatter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be changed to match the |
||
pub fn format<F, T>(&self, formatter: F) -> String | ||
where | ||
F: Formatter<T>, | ||
T: Saveable, | ||
{ | ||
let data = formatter.format(&self.grid); | ||
Saveable::format(&data) | ||
} | ||
Comment on lines
+46
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm concerned that this PR could potentially decrease the overall code coverage percentage, leading to CI check failures. I'd appreciate it if you add some integration tests to |
||
} | ||
|
||
impl fmt::Display for OrthogonalMaze { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
format
method inImageWrapper
seems like a workaround. In the context of images, the string formatter doesn't make much sense, does it? And documenting this behavior complicates the library API.Consider letting Rust handle this more idiomatically at compile time. To achieve this, we only need
StringWrapper
to implement another trait (e.g. customDisplay
orMazeDisplay
), like this:This approach also eliminates the confusion caused by the
Saveable
trait being aware of theformat
method.