refactor(DisplaySettings): use Option
s for default fields #161
No reviewers
Labels
No labels
Compat/Breaking
Kind
Bad merge
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
New language
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: mergiraf/mergiraf#161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ada4a/mergiraf:display_settings_default_fields"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Previously, we needed to specify the default values in multiple places:
default{,_compact}
constructorsdefault_*_name
This commit removes all those and uses
None
s in there, instead adding methods calledDisplaySettings::<field_name>_or_default
that returnSome
values if they exist, or the actual defaults in case ofNone
.There was another approach that came to mind, but was seen as too cumbersome: make a newtype for each such field, and implement
Default
for them -- this'd requier too much boilerplate and could require exposing the newtypes in a lot of places (most importantly, in the binary).Ideally, of course, we'd use default field values, but those aren't stabilzed yet.1
This also gets rid of the TODO in
mergiraf solve
, which was addressed back in #74https://github.com/rust-lang/rust/issues/132162 ↩︎
Option
s for default fields@ -23,1 +48,3 @@
pub fn left_marker(&self) -> String {
/// Uses the default values of `conflict_marker_size` and `left_revision_name` if not set
pub fn left_marker_or_default(&self) -> String {
println!("called left_marker_or_default");
We could remove this
println
:)when you think you've checked everything a hundred times... thanks, fixed!
Option
al #184