Is the rustified API actually rusty? #4125
Replies: 4 comments 8 replies
-
|
consumers like rubyfmt have to sometimes even redefine their own Node type because the API is afraid of owning anything that's returned from C for some reason. |
Beta Was this translation helpful? Give feedback.
-
|
prism/rust/ruby-prism/src/node.rs Line 134 in 2b87feb seems to also panic instead of gracefully returning a Result? |
Beta Was this translation helpful? Give feedback.
-
|
Arguably ParseResult should be owned because the parser is (assumedly) passing the responsibility of managing its memory onto the caller? |
Beta Was this translation helpful? Give feedback.
-
|
ah the build.rs file autogenerates the bindings.rs library which is why so much strangeness is going around @kddnewton would it be alright if I took a look and maybe changed a bunch of stuff there to make more sense? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
whilst trying to use this library in a project of mine I've come across an interesting question, is the rustified API actually rusty?
generally what seems to have happened is a lot of specific 'C' semantics sneaked their way into the crate, for example the Node type has a lot of 'as' functions which not only conflict with rusts
asoperator but also are equivalent to an if let statement when checking for a specific node type.the parse function seems to just return a generic Node, even though as far as I'm aware it can only be a specific type of node?
the API will panic if the 'c parser fails to initialize', however that decision should be left up to the caller and an error should be passed instead with the Result union type.
Beta Was this translation helpful? Give feedback.
All reactions