-
Notifications
You must be signed in to change notification settings - Fork 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
Improving vocabulary module #67
Improving vocabulary module #67
Conversation
…adds preliminary documentation.
…::vocab_lookup() to use iterators.
…Top and OWL::Nothing.
Since your vocab IRIs are all hardcoded somehow, you could implement r.build.class(OWL::Thing).into() which I think from an API perspective is nicer than having to call |
And as another remark I wonder if the |
* Adds Deref<Target = IRI<String>> * Adds TryFrom<&str> and TryFrom<&[u8]> (a lot of boilerplate). * Deprecates most methods in WithIRI trait. * Renames few methods in vocab to reflect their purpose. * Moves model::Facet to vocab::Facet
For now I implemented |
Agreed. I almost entirely could replace the behavior of |
The issue is with |
I tried to go for that. |
src/vocab.rs
Outdated
@@ -83,13 +137,53 @@ pub enum RDF { | |||
Type, | |||
} | |||
|
|||
impl TryFrom<&str> for RDF { |
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.
I think you should just delegate to the TryFrom<[u8]>
implementation here:
impl TryFrom<&str> for Namespace {
type Error = HornedError;
fn try_from(value: &str) -> Result<Self, Self::Error> {
Self::try_from(value.as_bytes())
}
}
And also you could implement FromStr
if you're gonna implement TryFrom<&str>
.
I think this could be all wrapped in a macro that takes care of both the |
…ve macros. * Substantial refactoring of vocab.rs. * Now, strings associated to variants are generated by vocabulary_type. * lazy_meta! is called from vocabulary_type. * vocab::is_thing and vocab::is_nothing moved to model::Class. * tests to check behaviour of new macros added.
Done, see
|
I think that this looks good. The complexity of macros added in vocab.rs is more than made up for by the regularity and use of standard traits in the rest of the code. Do we need to deprecate WithIRI? Or do we just delete it? |
You're in |
By the way I am compiling a list of things to improve regarding Rust conventions (capitalization in some identifiers is not standard, some methods could be renamed to a more standard name like |
Alright, I updated the code to remove all that was deprecated. |
Added one minor review issue. I also wonder about the tests -- they are getting fairly long now, and I wonder whether we should use a "test" module at the end. The reason I worry is that tests tend to churn more rapidly than "real" code and that can make the diffs harder to read. WDYT? |
Addressed in commit |
If there is no objection or further improvement in this direction I would merge this onto |
Good for me |
Addresses #60 and solves all the issues mentioned there, plus additional refactoring or renaming of some methods. Originally was #61, but having messed up with the git history there, I created a fresh branch and cherry-picked the right commits on top of
devel
.It could already be merged. What do you think @althonos @phillord ?