Guest User

Untitled

a guest
Aug 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. fn func<T: iter::Iterator<Item = char>>(i: T) {
  2. //...
  3. }
  4.  
  5. fn option_iter(input: Option<char>) {
  6. let i: Box<iter::Iterator<Item = char>> =
  7. if let Some(input) = input {
  8. Box::new(iter::once(input))
  9. } else {
  10. Box::new(iter::empty())
  11. };
  12. func(i);
  13. }
  14.  
  15. let i = if let Some(input) = input {
  16. iter::once(input)
  17. } else {
  18. iter::empty()
  19. };
  20. func(i);
Add Comment
Please, Sign In to add comment