Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transmute_copy doc example is too trivial #31094

Closed
tomjakubowski opened this issue Jan 21, 2016 · 2 comments
Closed

transmute_copy doc example is too trivial #31094

tomjakubowski opened this issue Jan 21, 2016 · 2 comments

Comments

@tomjakubowski
Copy link
Contributor

http://doc.rust-lang.org/nightly/std/mem/fn.transmute_copy.html#examples

use std::mem;

let one = unsafe { mem::transmute_copy(&1) };

assert_eq!(1, one);

This transmutes an i32 to... an i32! A more realistic example might be to transmute a byte array to a packed struct.

@steveklabnik
Copy link
Member

part of #29362

@frewsxcv
Copy link
Member

I took a stab at this: #31720

frewsxcv added a commit to frewsxcv/rust that referenced this issue Feb 17, 2016
Prior to this commit, it was a trivial example that did not demonstrate
the effects of using the function.

Fixes rust-lang#31094
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 17, 2016
…mple, r=steveklabnik

Prior to this commit, it was a trivial example that did not demonstrate
the effects of using the function.

Fixes rust-lang#31094
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

No branches or pull requests

3 participants