this post was submitted on 21 Oct 2024
201 points (99.0% liked)

Programming

17511 readers
172 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] FizzyOrange@programming.dev 2 points 1 month ago (1 children)

The biggest issue is move constructors. Explanation here: https://cxx.rs/binding/cxxstring.html#restrictions

Probably seems like a little thing but I found it quite annoying in practice, and there are other things like not being able to combine serde-derive and cxx FFI on the same struct.

[โ€“] Ephera@lemmy.ml 3 points 1 month ago

Sounds like you'll always have to do this little dance for any string you want to pass through, so I can definitely see how that could become quite annoying.

For not being able to combine serde-derive and cxx FFI on the same struct, there's a simple trick that can be used for many such situations:

struct CxxThingamabob { ... }

#[derive(Serialize, Deserialize)]
#[serde(transparent)]
struct SerializableCxxThingamabob(CxxThingamabob);

That just moves the Serde implementation to a different struct, so that you can choose which one you want by either wrapping or unwrapping it.