[Question] to merge borrowing
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.2k
- Forks
- 265
- Avg merge
- 2h 42m
- Merged PRs (30d)
- 4
Description
Hi,
ist there a way to do optional merging without cloning?
If the merge fails, it should stay at the settings before the try to merge.
Because File::from... seems to be something which can not panic, the panic needs to occur in merge, is this correct?
At least there is nothing I can check the Result or Option from File::from....
So the only way I've found to get this to work is cloning before the merge, and sadly, I've to clone also the Result, because merge borrows in the result...
let mut settings = Config::default();
settings.set_default(...).unwrap();
[...]
let default_settings = settings.clone();
let cfgfile = "default.cfg";
let src = File::from_str(cfgfile, FileFormat::Ini);
let merge_res = settings.merge(src);
match merge_res {
Err(err) => {
default_settings
}
Ok(s) => s.clone(),
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the File::from_str and Config::merge entry points mentioned in the question, then inspect any related tests or API documentation in the repository. The issue does not define an accepted API or behavior; it would need a maintainer decision on optional merging and failure-state preservation before implementation can be considered done.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100