-
Notifications
You must be signed in to change notification settings - Fork 741
Feedback on using a generic iterator for clang.rs (Not for merge) #189
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
This allow each implmentation to panic if called with incorrect values, assuming the trait function is called with the acutal result from fetch_item_num
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 looks pretty neat! I'd probably simplify the trait removing ItemNum
and returning Option<usize>
directly.
Apart from that, I'm not sure IndexCallable
is a great name, but I can't think of any better either so... :)
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 is heading in a good direction!
Holler when you think this is ready to land and @emilio or I can do a proper review of the PR.
} | ||
} | ||
|
||
struct TestIndexCallableProvider { |
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.
All the testing stuff should be contained in a sub-module at the bottom of this file, like this:
#[cfg(test)]
mod tests {
// testing stuff here...
}
@@ -1170,6 +1170,157 @@ impl UnsavedFile { | |||
} | |||
} | |||
|
|||
/// Provide index results. | |||
pub trait IndexCallable { |
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.
FfiIndexable
? FfiIterable
?
Hi,
In the issues I fixed before I've added 3 iterators in clang.rs which are mostly duplicate code.
It seems there is room to have many of such iterators in this file, and maybe we want to avoid the overhead of having these duplicated, so we can use them in all the places where it makes sense.
They also had the issue that the
clang_*_getNum
andclang_*_get*
calls where far apart.The first commit added generic code and tests.
The last 3 commits replace our existing iterator implementation.
This is just a proof of concept, and If this is something we want, I'll think I could use some guidance to make it in a changeset we want to merge.
Kind Regards,
Jean-Philippe.
Some questions that came up:
Context:
Coming from C++ I thought template, and I gave my best attempt at this idea getting inspiration from the iterator trait.
My goals where:
clang_*_getNum
andclang_*_get*
should be close together for readability