-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Minor refactor and cleanup #716
Conversation
use sqlx::{query, SqliteExecutor}; | ||
|
||
use crate::errors::MbtResult; |
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.
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.
@upsicleclown do you mean why it has been moved to a separate line separated by a blank line? We have a few config options already set - https://github.com/maplibre/martin/blob/main/rustfmt.toml - but I don't want to enable it "by default" because the stable rustfmt throws an error if rustfmt has some settings it does not support. So keeping it commented out.
Note that reorder_imports_in_group
seem to have been removed - try adding it to rustfmt and running cargo +nightly fmt
- and it will complain.
I added a fmt2
just target to do it from CLI
This will simplify some planned work
martin/src/file_config.rs
Outdated
pub fn extract_file_config(&mut self) -> FileConfig { | ||
match self { | ||
FileConfigEnum::Path(path) => FileConfig { | ||
paths: Some(OneOrMany::One(mem::take(path))), |
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.
nit: This looked cleaner when One
and Many
were imported directly
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.
fixed. This one is kinda tricky because often when you see One
, it might not give enough context - so i have seen a lot of things like io::Result
when things are not extra clear.
|
||
impl Sources { | ||
pub fn insert(&mut self, id: String, source: Box<dyn Source>) { | ||
self.0.insert(id, source); |
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.
nit: It might be worth giving the HashMap
in Sources
a name, so that the accesses are clearer
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.
this is a fairly common pattern - esp when there is only one value wrapped. I would rather not change it to a named struct
IdResolver
to a separate filejust fmt2
build target to format code using nightly modeData<AppState>
into individual state objects, e.g.Data<Sources>
(allows other source types, separate fromSources
type)Sources
struct (a simple wrapper over a HashMap)