File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
crates/compilers/src/compilers Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ use semver::VersionReq;
88/// Abstraction over set of restrictions for given [`crate::Compiler::Settings`].
99pub trait CompilerSettingsRestrictions : Copy + Debug + Sync + Send + Clone + Default {
1010 /// Combines this restriction with another one. Returns `None` if restrictions are incompatible.
11+ #[ must_use]
1112 fn merge ( self , other : Self ) -> Option < Self > ;
1213}
1314
@@ -20,15 +21,18 @@ pub struct RestrictionsWithVersion<T> {
2021}
2122
2223impl < T : CompilerSettingsRestrictions > RestrictionsWithVersion < T > {
23- pub fn merge ( & mut self , other : Self ) {
24+ /// Tries to merge the given restrictions with the other [`RestrictionsWithVersion`]. Returns
25+ /// `None` if restrictions are incompatible.
26+ pub fn merge ( mut self , other : Self ) -> Option < Self > {
2427 if let Some ( version) = other. version {
2528 if let Some ( self_version) = self . version . as_mut ( ) {
2629 self_version. comparators . extend ( version. comparators ) ;
2730 } else {
2831 self . version = Some ( version. clone ( ) ) ;
2932 }
3033 }
31- self . restrictions . merge ( other. restrictions ) ;
34+ self . restrictions = self . restrictions . merge ( other. restrictions ) ?;
35+ Some ( self )
3236 }
3337}
3438
You can’t perform that action at this time.
0 commit comments