How to implement Default with a function?
Closed this issue · 2 comments
winston0410 commented
Hi, is it possible to set default that is more complex when using this library? For example, I have a struct that implement default like this:
impl Default for RsCantoneseConfig {
fn default() -> Self {
let mut model_path = std::env::temp_dir();
model_path.push(constant::MODEL_PATH);
RsCantoneseConfig {
model_path,
}
}
}
idanarye commented
#[derive(typed_builder::TypedBuilder)]
struct RsCantoneseConfig {
#[builder(default = {
let mut model_path = std::env::temp_dir();
model_path.push(constant::MODEL_PATH);
model_path
})]
model_path: PathBuf,
}
winston0410 commented
Perfect thanks!