Created
          June 19, 2014 00:53 
        
      - 
      
- 
        Save reem/e6ceeae1eeeb101730f7 to your computer and use it in GitHub Desktop. 
    Borrowing
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | let isAbsoluteUri = match req.request_uri { | |
| AbsolutePath(_) => true, | |
| _ => false | |
| }; | |
| if isAbsoluteUri { | |
| match req.request_uri { | |
| AbsolutePath(ref mut path) => { | |
| *path = path.as_slice().slice_from(self.route.len()).to_string(); | |
| }, | |
| // Absolutely cannot happen because of our previous check. | |
| _ => fail!() | |
| } // Previous borrow of req ends here. | |
| // So we can borrow it again here. | |
| self.iron.furnace.forge(req, res, Some(alloy)); | |
| // And repair the damage here, for future middleware | |
| match req.request_uri { | |
| AbsolutePath(ref mut path) => { | |
| *path = self.route.clone().append(path.as_slice()); | |
| }, | |
| // Absolutely cannot happen because of our previous check. | |
| _ => fail!() | |
| } // Previous borrow of req ends here. | |
| Unwind | |
| } else { | |
| Continue | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment