Use Path/PathBuf for fs paths#179
Conversation
|
I think we should use I created a commit to this effect here. Otherwise LGTM. |
|
This pattern may become less ergonomic than it seems. Your proposed code change makes the code generic on a single type: pub fn generate_live<P: AsRef<Path>>(
client: &mut Client,
queries_path: P,
destination: Option<P>,
settings: CodegenSettings,
)This means that I can't use a pub fn generate_live(
client: &mut Client,
queries_path: impl AsRef<Path>,
destination: Option<impl AsRef<Path>>,
settings: CodegenSettings,
)Then, if I don't want to provide a Since this code should only be called once in a build script, I'm not too picky about usability, and prefer to be explicit in this case. If you still think that being generic on a single type is enough, I will accept your proposal. |
|
I agree that it's not the most important place for ergonomics. As long as the function accepts all valid OS paths then I give my thumbs up. |
Yeah you're right.
If we use My goal was to keep allowing users to provide paths as I'll leave it up to you, its not a big deal either way since as you mentioned this is only for a handful of paths specified once. |
503b1a7 to
7ac1025
Compare
LouisGariepy
left a comment
There was a problem hiding this comment.
Otherwise looks good.
Not related to the goal of this PR, but I appreciate the small changes you've made to avoid passing around large structs by value, or cloning potentially big strings etc. Always appreciated :)
|
@Virgiel I'm curious why you prefer a separate path generic for schema paths? <P: AsRef<Path>, F: AsRef<Path>>I doubt this is necessary in practice, but perhaps I'm missing something? The PR is ready to be merged in any case, I'm just wondering. |
|
@LouisGariepy |
|
I think you're referring to our CLI, for example, where we have generate_managed(
queries_path, // PathBuf
&schema_files, // Slice of PathBuf
Some(destination), // PathBuf
<...>
)So P = PathBuf and we don't need another generic. |
144c411 to
6e4f334
Compare
You are right we can simply pass |
|
💯 Ready to merge |
Fix #177 (comment)