Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Extend clone macro #534

Merged
merged 8 commits into from
Nov 16, 2019
Merged

Conversation

GuillaumeGomez
Copy link
Member

Fixes #532.
Fixes #533.

cc @sdroege @EPashkin @antoyo

@sdroege
Copy link
Member

sdroege commented Nov 15, 2019

You might also want to add another branch to the macro after the $variable:ident case for $variable:expr, which then maps to compile_error! for giving a better error message for things like x.y as variable.

Did you test that all the other parts are working? The syntax looks fine to me in any case. Maybe we can add some tests for this (and fix the existing tests)? :)

@GuillaumeGomez
Copy link
Member Author

cargo test is running fine on my computer?

@GuillaumeGomez
Copy link
Member Author

Oh you meant the examples maybe? Well, the PR is already open, just not up to date.

@GuillaumeGomez
Copy link
Member Author

I also added a check for the keyword (better than having a macro error. :) )

@sdroege
Copy link
Member

sdroege commented Nov 16, 2019

@GuillaumeGomez Improved the error handling a bit and also fixed a bug. This should be good to go I guess :)

let $variable = $variable.clone();
);
(@weak $variable:ident) => (
let $variable = $crate::clone::Downgrade::downgrade(&$variable);
);
(@ $keyword:ident $variable:ident) => (
compile_error!("Unknown keyword, only `weak` and `strong` are allowed");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stringify!(keyword) wasn't working?

@sdroege
Copy link
Member

sdroege commented Nov 16, 2019 via email

@GuillaumeGomez
Copy link
Member Author

Na, not worth it. Looks good to me now. Once merged, I'll update my examples PR.

@sdroege sdroege merged commit 37afcec into gtk-rs:master Nov 16, 2019
@sdroege
Copy link
Member

sdroege commented Nov 16, 2019

Merged, please fix the examples then :) Thanks!

@GuillaumeGomez GuillaumeGomez deleted the extend-clone-macro branch November 16, 2019 13:59
@GuillaumeGomez
Copy link
Member Author

Will do before the end of the day!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic as clone return value? Default behavior of the clone macro
3 participants