Created
          March 18, 2019 22:22 
        
      - 
      
- 
        Save TethysSvensson/2615a8a1aff7f243fda78c3c1e1ced51 to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | use flatbuffers::{Vector, Follow}; | |
| fn first<'a, T: Follow<'a> + 'a>(v: Vector<'a, T>) -> Option<T::Inner> { | |
| if v.len() > 0 { | |
| Some(v.get(0)) | |
| } else { | |
| None | |
| } | |
| } | |
| fn first2<'a, T: Follow<'a> + 'a>(v: Vector<'a, T>) -> Option<T::Inner> { | |
| for x in v.iter() { | |
| return Some(x); | |
| } | |
| None | |
| } | |
| fn first3<'a, 'b, T: Follow<'a> + 'a>(v: &'b Vector<'a, T>) -> Option<T::Inner> { | |
| for x in v.iter() { | |
| return Some(x); | |
| } | |
| None | |
| } | |
| fn first4<'a, T: Follow<'a> + 'a>(v: &'a Vector<'a, T>) -> Option<T::Inner> { | |
| for x in v.iter() { | |
| return Some(x); | |
| } | |
| None | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment