Last active
July 23, 2017 16:16
-
-
Save wldevries/6d1b3824b26914e114cf257f0a55b963 to your computer and use it in GitHub Desktop.
Lifetime issues with non-copyable owned values when trying to use them after passing them to a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum NonCopyable { | |
| Node ( Box<NonCopyable> ), | |
| Leaf | |
| } | |
| fn do_stuff() -> NonCopyable { | |
| let x = NonCopyable::Leaf; | |
| match try_wrap(x) { | |
| (val, true) => val, | |
| (val, false) => val, | |
| } | |
| } | |
| fn try_wrap(x: NonCopyable) -> (NonCopyable, bool) { | |
| match true { | |
| true => (NonCopyable::Node(Box::new(x)), true), | |
| false => (x, false) | |
| } | |
| } | |
| fn main() {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment