File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -678,6 +678,29 @@ pub enum Bound<T> {
678678 Unbounded ,
679679}
680680
681+ #[ unstable( feature = "bound_as_ref" , issue = "80996" ) ]
682+ impl < T > Bound < T > {
683+ /// Converts from `&Bound<T>` to `Bound<&T>`.
684+ #[ inline]
685+ pub fn as_ref ( & self ) -> Bound < & T > {
686+ match * self {
687+ Included ( ref x) => Included ( x) ,
688+ Excluded ( ref x) => Excluded ( x) ,
689+ Unbounded => Unbounded ,
690+ }
691+ }
692+
693+ /// Converts from `&mut Bound<T>` to `Bound<&T>`.
694+ #[ inline]
695+ pub fn as_mut ( & mut self ) -> Bound < & mut T > {
696+ match * self {
697+ Included ( ref mut x) => Included ( x) ,
698+ Excluded ( ref mut x) => Excluded ( x) ,
699+ Unbounded => Unbounded ,
700+ }
701+ }
702+ }
703+
681704impl < T : Clone > Bound < & T > {
682705 /// Map a `Bound<&T>` to a `Bound<T>` by cloning the contents of the bound.
683706 ///
You can’t perform that action at this time.
0 commit comments