Closed kawogi closed 3 years ago
Hi,
that seems to be a good idea.
I wonder though if it would be better to just make the fields pub, or if I should add some accessor functions to abstract from the structs internal representation.
On Tue, 12 Oct 2021, 08:35 Kai Giebeler, @.***> wrote:
I have a use case where I want to use the crate mainly for parsing an expression in order to store the resulting tree (and maybe manipulate it). At the moment there seems to be no way to access the operator and the children of a Node. I don't know if this has been a design decision but I think there's no harm in exposing those fields.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ISibboI/evalexpr/issues/92, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASATXWTVTEN2VL2LROCVEDUGPCJPANCNFSM5FZWCIYA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
Actually, probably exposing both via methods is easiest. There are already private methods for immutable access which can just be made public, and mutable access can be added as well.
One might want to add some validation (e.g. unary must have a single operand), so getter/setter seems more appropriate.
I implemented them as functions now (d2f3d415dfb0760f2f919e858cf3875b9e89e08e). However without immediate validation. The validation is done when the operator tree is evaluated. Does this work for you?
Yes, that's perfect. Thanks a lot! Code quality of this crate is on an awesome level, btw.
Thanks :)
I have a use case where I want to use the crate mainly for parsing an expression in order to store the resulting tree (and maybe manipulate it). At the moment there seems to be no way to access the operator and the children of a
Node
. I don't know if this has been a design decision but I think there's no harm in exposing those fields.