You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code reports an error about the value being moved:
use std::marker::PhantomData;
trait Foo {}
struct Bar {}
impl Foo for Bar {}
#[derive(Copy, Clone)]
union U<T>
where T: Foo
{
value1: u32,
value2: *const (),
phantom: PhantomData<*const T>
}
fn test()
{
let a: U<Bar> = U { value1: 5 };
let b = a;
let c = a;
}
While the following code works as expected:
use std::marker::PhantomData;
trait Foo {}
struct Bar {}
impl Foo for Bar {}
union U<T>
where T: Foo
{
value1: u32,
value2: *const (),
phantom: PhantomData<*const T>
}
impl<T> Copy for U<T> where T: Foo {}
impl<T> Clone for U<T> where T: Foo
{
fn clone(&self) -> Self
{
*self
}
}
fn test()
{
let a: U<Bar> = U { value1: 5 };
let b = a;
let c = a;
}
The text was updated successfully, but these errors were encountered:
The following code reports an error about the value being moved:
While the following code works as expected:
The text was updated successfully, but these errors were encountered: