@@ -717,8 +717,7 @@ impl Limits {
717717 ///
718718 /// This function is not for clamping requests for values beyond the
719719 /// supported limits. For that purpose the desired function would be
720- /// `or_worse_values_from` (which doesn't exist, but could be added if
721- /// needed).
720+ /// `or_worse_values_from`.
722721 #[ must_use]
723722 pub fn or_better_values_from ( mut self , other : & Self ) -> Self {
724723 macro_rules! or_better_value_from {
@@ -737,6 +736,30 @@ impl Limits {
737736
738737 self
739738 }
739+
740+ /// For each limit in `other` that is worse than the value in `self`,
741+ /// replace the value in `self` with the value from `other`.
742+ ///
743+ /// This function is for clamping requests for values beyond the
744+ /// supported limits.
745+ #[ must_use]
746+ pub fn or_worse_values_from ( mut self , other : & Self ) -> Self {
747+ macro_rules! or_worse_value_from {
748+ ( $name: ident, $ordering: expr) => {
749+ match $ordering {
750+ // Limits that are maximum values (most of them)
751+ Ordering :: Less => self . $name = self . $name. min( other. $name) ,
752+ // Limits that are minimum values
753+ Ordering :: Greater => self . $name = self . $name. max( other. $name) ,
754+ Ordering :: Equal => unreachable!( ) ,
755+ }
756+ } ;
757+ }
758+
759+ with_limits ! ( or_worse_value_from) ;
760+
761+ self
762+ }
740763}
741764
742765/// Represents the sets of additional limits on an adapter,
0 commit comments