@@ -674,10 +674,10 @@ pub enum Bound<T> {
674674 Unbounded ,
675675}
676676
677- #[ unstable( feature = "bound_as_ref" , issue = "80996" ) ]
678677impl < T > Bound < T > {
679678 /// Converts from `&Bound<T>` to `Bound<&T>`.
680679 #[ inline]
680+ #[ unstable( feature = "bound_as_ref" , issue = "80996" ) ]
681681 pub fn as_ref ( & self ) -> Bound < & T > {
682682 match * self {
683683 Included ( ref x) => Included ( x) ,
@@ -688,13 +688,47 @@ impl<T> Bound<T> {
688688
689689 /// Converts from `&mut Bound<T>` to `Bound<&T>`.
690690 #[ inline]
691+ #[ unstable( feature = "bound_as_ref" , issue = "80996" ) ]
691692 pub fn as_mut ( & mut self ) -> Bound < & mut T > {
692693 match * self {
693694 Included ( ref mut x) => Included ( x) ,
694695 Excluded ( ref mut x) => Excluded ( x) ,
695696 Unbounded => Unbounded ,
696697 }
697698 }
699+
700+ /// Maps a `Bound<T>` to a `Bound<U>` by applying a function to the contained value (including
701+ /// both `Included` and `Excluded`), returning a `Bound` of the same kind.
702+ ///
703+ /// # Examples
704+ ///
705+ /// ```
706+ /// #![feature(bound_map)]
707+ /// use std::ops::Bound::*;
708+ ///
709+ /// let bound_string = Included("Hello, World!");
710+ ///
711+ /// assert_eq!(bound_string.map(|s| s.len()), Included(13));
712+ /// ```
713+ ///
714+ /// ```
715+ /// #![feature(bound_map)]
716+ /// use std::ops::Bound;
717+ /// use Bound::*;
718+ ///
719+ /// let unbounded_string: Bound<String> = Unbounded;
720+ ///
721+ /// assert_eq!(unbounded_string.map(|s| s.len()), Unbounded);
722+ /// ```
723+ #[ inline]
724+ #[ unstable( feature = "bound_map" , issue = "86026" ) ]
725+ pub fn map < U , F : FnOnce ( T ) -> U > ( self , f : F ) -> Bound < U > {
726+ match self {
727+ Unbounded => Unbounded ,
728+ Included ( x) => Included ( f ( x) ) ,
729+ Excluded ( x) => Excluded ( f ( x) ) ,
730+ }
731+ }
698732}
699733
700734impl < T : Clone > Bound < & T > {
0 commit comments