msrd0 / rlottie-rs

Rust bindings to rlottie and file conversion library and tools
MIT License
17 stars 4 forks source link

Add Debug trait implementation to struct Animation. #6

Closed cireu closed 2 years ago

msrd0 commented 2 years ago

Why do you need this? I'd assume printing a pointer isn't necessarily helpful for debugging.

cireu commented 2 years ago

If we don't have this, struct contains Animation cannot use #[derive(Debug)]

msrd0 commented 2 years ago

Do you think a more abstract implementation like this one would be sufficient for your use case? https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9af39eac8f9e0d0445c25a83470ca3d5

cireu commented 2 years ago

Hmm, Animation { .. } is OK, but IMO a extra pointer address information is not bad. Could you please tell me your concern on printing the pointer address? Thanks.

msrd0 commented 2 years ago

From an API perspective, I want no way of anyone to obtain that adress so I don't have to worry about them using it to make the API unsound. For example, an application could extract the adress from the debug string and call the rlottie's destructor, making all further calls to Animation, including its Drop impl, unsound.

In short, giving the adress to anyone makes it impossible to uphold safety prerequisites which are necessary for the unsafe codeblocks used in the crate.

cireu commented 2 years ago

OK :) I'd glad to see your code example above being merged

msrd0 commented 2 years ago

I just released it in 0.3.1