-
Notifications
You must be signed in to change notification settings - Fork 24
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
v0.9 API #26
Comments
Ok, fair enough. I'm still on the fence about it, but I guess newtype vs smart pointers is not really a black vs white issue, it's more nuanced than that. And I like the renaming. |
Yeah, I'd agree.
That was the intention, glad it worked out. Also considered |
Something I realized: The |
Is it implemented? Cuz
this one shows up. |
Yeah, |
|
You're looking at the alpha docs right? |
Oooh, I'm blind, it's there https://docs.rs/syn-rsx/0.9.0-alpha.1/syn_rsx/struct.NodeValueExpr.html#impl-TryFrom%3C%26NodeValueExpr%3E-for-String, right. Then it's fine :D |
Released
|
I know the issue is closed, but just wanted to chime in on this and say thanks for the new API -- having just reimplemented our view macro using it and I can say it's much nicer to have the type safe enum variants than the constant .name_as_string().unwrap() and whatnot before. Great update! |
Follow-up from #23, also see v0.9.0-alpha.1 release notes
Issue for general API discussion of the upcoming v0.9 release, which will have a rather large breaking change upcoming:
Node
will be converted to anenum
, and the node tree leafs areNode
enums as well. This will come with additional type safety, but makes the nodes a bit harder to access in terms of API. Feel free to voice concerns or ideas.Should
NodeValueExpr
implementDeref
? Is it a newtype or a smart pointer?After reading up a bit on what the book says about newtypes and smart pointers (here, here and here), I'm leaning towards
NodeValueExpr
being a smart pointer. Reason being: While it doesn't hold extra metadata, its main purpose is granting access to the type it is encapsulating and adding extra capabilities via a multitude of traits. Furthermore consumers mainly want work with the encapsulated type, so having to do explicit method calls just to get theExpr
instead of being able to leverage reference coercion seems like the wrong move.My understanding regarding the newtype patterns is that the main use cases are additional abstraction over encapsulated types – up to the point that it should protect internal type state from undesired modifications –, making APIs type safe through wrappers or specifically to work around the orphan rule. None if which is what
NodeValueExpr
is primarily doing/providing.The text was updated successfully, but these errors were encountered: