-
Notifications
You must be signed in to change notification settings - Fork 700
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace clang.rs iterator with generic boxed Map<Range<>>
Add functions: -ffi_call_index_iterator -> Box<ExactSizeIterator> for foreign function with unsigned length and index -ffi_call_index_iterator_check_positive -> Option<Box<ExactSizeIterator>> for foreign function with signed length and index that can be -1 These function take two closures as parameters. This interface should guide the correct usage of having thin closures arround the actual two relevant ffi functions. The ad hoc iterator where basically implementing (0..clang_getNum()).map( |id| clang_getItem( self.x, id ) ) with some additional complexity if clang_getNum() could be -1. Using these new function greatly improve maintainability since now everything is in the function getting a specific iterator, and all iterators implement ExactSizeIterator consistently. The trade off is we now have dynamic dispatch, but that should not be too problematic since we are calling a foreign function to get the item. Eventually rust will support impl trait (experimental feature conservative_impl_trait which has a very close syntax) at which point the Box can be replaced if needed and appropriate.
- Loading branch information
1 parent
1a8a2ac
commit 833f2a3
Showing
1 changed file
with
70 additions
and
101 deletions.
There are no files selected for viewing
This file contains 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