comrak icon indicating copy to clipboard operation
comrak copied to clipboard

Implementing PartialEq for Ast

Open begleynk opened this issue 2 years ago • 1 comments

I'm writing a program that needs to translate the comrak AST into a different AST, that a WYSIWYG editor (prosemirror) understands, and back again. I was about to write some tests for this translation, but I found that the Ast struct doesn't implement PartialEq:

error[E0369]: binary operation `==` cannot be applied to type `Ast`
   --> src/prosemirror.rs:105:9
    |
105 |         assert_eq!(*expected_comrak.data.borrow(), *actual_comrak.data.borrow());
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |         |
    |         Ast
    |         Ast
    |
    = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)

Maybe there is there a reason for this that I'm missing? If not, would you consider a pull request that adds this? Would be happy to contribute the change.

I did notice there is a same_node function on Node but it seems this is for checking if two nodes point to literally the same data.

PS. Thanks for maintaining this library!

begleynk avatar May 02 '22 08:05 begleynk

I'd be totally happy to accept such a PR!

kivikakk avatar May 02 '22 23:05 kivikakk