Add option.map_move and result.map_move #8294
                
     Closed
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
According to #7887, we've decided to use the syntax of
fn map<U>(f: &fn(&T) -> U) -> U, which passes a reference to the closure, and tofn map_move<U>(f: &fn(T) -> U) -> Uwhich moves the value into the closure. This PR adds these.map_move()functions toOptionandResult.In addition, it has these other minor features:
option.get(),result.get(), andresult.get_err()withoption.unwrap(),result.unwrap(), andresult.unwrap_err(). (See Updated std::Option, std::Either and std::Result #8268 and Alternative Updated std::Option, std::Either and std::Result #8288 for a more thorough adaptation of this functionality.option.take_map()andoption.take_map_default(). These two functions can be easily written as.take().map_move(...).result.unwrap()andresult.unwrap_err().