Add extension support and first extension, unwrap_newtypes#72
Conversation
| ParseError::ExpectedArray => "Expected array", | ||
| ParseError::ExpectedArrayEnd => "Expected end of array", | ||
| ParseError::ExpectedAttribute => "Expected an enable attribute", | ||
| ParseError::ExpectedAttributeEnd => "Expected a closing `]` after the attribute", |
There was a problem hiding this comment.
Ah, this could also fail if ) is missing. The error message should reflect that.
| ) -> Result<V::Value> | ||
| where V: Visitor<'de> | ||
| { | ||
| if Extension::unwrap_newtypes(self.bytes.exts) { |
There was a problem hiding this comment.
if the set of extensions is known at compile time, any reason we don't do something like if self.extensions.contains(Extension::UNWRAP_NEWTYPES) {..}?
|
I don't see which contains method you want me to use? The extensions are
stored in a usize.
|
|
bors try |
tryBuild succeeded |
| scope: source.ron | ||
| contexts: | ||
| main: | ||
| # extensions |
There was a problem hiding this comment.
This could be done better, but I think it's sufficient. Could you try it out with your editor?
There was a problem hiding this comment.
I tested it. Seems to work fine.
|
r? @kvark Please also check the syntax file, I didn't check it! |
| fn multiple_attributes() { | ||
| #[derive(Debug, Deserialize, PartialEq)] | ||
| struct New(String); | ||
| let de: Result<New> = from_str("#![enable(unwrap_newtypes)] #![enable(unwrap_newtypes)] \"Hello\""); |
There was a problem hiding this comment.
this is not supported by the syntax highlighter, I think
Can we require the features to always come as a list in a single pragma? e.g. #![enable(feature1, feature2)]
There was a problem hiding this comment.
I think it is supported? It should match against the same pattern twice.
| .map(|elem| { | ||
| if self.consume(elem) { | ||
| self.skip_ws(); | ||
|
|
There was a problem hiding this comment.
Personal style, I always make a newline before the return value.
|
|
Canceled |
|
Just noticed two nits and fixed them. bors r=kvark |
Build succeeded |
|
@torkleyy The syntax highlighting in Sublime is messed up as soon as I add attributes: |
|
Could you file that on https://github.com/ron-rs/sublime-ron please? |
|
Done: ron-rs/sublime-ron#6 |

TODO
docs for extensions(postponed)Fixes
Fixes #69