Skip to content

Receive this in Copy/Move Constructible/Assignable - #688

Closed
lucic71 wants to merge 9 commits into
Cpp2Rust:masterfrom
lucic71:move-copy
Closed

lucic71 wants to merge 9 commits into
Cpp2Rust:masterfrom
lucic71:move-copy

Conversation

@lucic71

@lucic71 lucic71 commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@lucic71 lucic71 mentioned this pull request Nov 30, 2026
nunoplopes pushed a commit that referenced this pull request Dec 1, 2026
Depends on #688 

Add the swappable trait and delete the cpp_swap macro. `swap_by_move` is
a new libcc2rs function with the necessary traits:

```rs
pub fn swap_by_move<T>(this: &Ptr<T>, other: Ptr<T>)
where
  T: MoveConstructible + MoveAssignable + Destructible + ZeroInitialization
```

The standard explicitely requires MoveConstructible and MoveAssignable,
and implicitly requires Destructible. ZeroInitialization is an artefact
of refcount which needs storage to build objects into it.
ZeroInitialization has no side-effects so it's ok to have the trait
attached.

---

I also had to change Destructible to be implemented by records with
empty destruction, otherwise records with empty Destructible could not
call swap_by_move.
@nunoplopes

Copy link
Copy Markdown
Contributor

(conflict)

@lucic71

lucic71 commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Everything here is already included in #689 which was already merged

@lucic71 lucic71 closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants