- 
        Couldn't load subscription status. 
- Fork 23
Add ManagedMap::range. #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| Hmm, I'm having an issue with Rust versions. I have to do  Any idea on how to solve this? | 
56be1ed    to
    4ca776e      
    Compare
  
    | Got it! | 
        
          
                src/map.rs
              
                Outdated
          
        
      | } | ||
| } | ||
|  | ||
| pub enum Range<'a, 'b, K: 'a, V: 'a> where 'a: 'b { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, is there a reason the lifetimes have to be like this? Why not K: 'b, V: 'b?
        
          
                src/map.rs
              
                Outdated
          
        
      | /// Owned variant, only available with the `std` or `alloc` feature enabled. | ||
| #[cfg(any(feature = "std", feature = "alloc"))] | ||
| Owned(BTreeRange<'b, K, V>), | ||
| _Phantom(&'a K), | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should, at least, be #[doc(hidden)], and I usually go with __Phantom (two underscores).
        
          
                src/map.rs
              
                Outdated
          
        
      | break; | ||
| } | ||
| } | ||
| assert_eq!(left, right); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this assertion fail?
        
          
                src/map.rs
              
                Outdated
          
        
      | break; | ||
| } | ||
| } | ||
| assert_eq!(left, right); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this assertion fail?
        
          
                src/map.rs
              
                Outdated
          
        
      | let middle = left + (right-left)/2; | ||
| if key!(slice[middle]) < Some(key_begin) { | ||
| left = middle+1; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: } else here and elsewhere.
        
          
                src/map.rs
              
                Outdated
          
        
      | } | ||
|  | ||
| pub fn range<'b, 'c, Q>(&'c self, key_begin: &Q, key_end: &Q) -> Range<'a, 'b, K, V> | ||
| where K: Borrow<Q>, Q: Ord + ?Sized, 'a: 'b, 'c: 'a | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is 'c really necessary here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the ManagedMap has to outlive the Range's references.
        
          
                src/map.rs
              
                Outdated
          
        
      | break; | ||
| } | ||
| } | ||
| assert_eq!(left, right); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this really was a question. Will this assertion fail if the entries are out of order or something like that? Then it should stay. See the other assertions in this file that panic with "invariant violated".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it can't fail. I used it while debugging
| Thanks. What do you think about removing rustc version detection entirely? I was thinking about using impl Trait in smoltcp and that would imply 1.26. I don't think we care very much about 1.25 or earlier. | 
| Okay. I currently have only rust 1.25 on my computer, but I can fix that. | 
5b7dfe7    to
    7849e64      
    Compare
  
    | I wonder if I should add "shortcuts", to skip a dichotomy if  smoltcp-rs/smoltcp#209 would be one use case, because we'll use  | 
| I just improved my implementation to have an interface similar to  It uses the nightly feature "collections_range", but it is going to be stabilized soon; and  | 
| Thanks. | 
As mentioned here: smoltcp-rs/smoltcp#209 (comment)