-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed
Description
Because Sid is an opaque type, it is impossible to std::mem::replace it. Example test:
/// Ensures that std::mem::replace works properly with Sid
#[test]
fn mem_replace() {
let mut sid1 = crate::Sid::well_known_sid(winapi::um::winnt::WinWorldSid).unwrap();
let mut sid2 = crate::Sid::well_known_sid(winapi::um::winnt::WinNtAuthoritySid).unwrap();
assert_eq!(sid1.id_authority(), &[0, 0, 0, 0, 0, 1]);
assert_eq!(sid2.id_authority(), &[0, 0, 0, 0, 0, 5]);
std::mem::swap(&mut *sid1, &mut *sid2);
assert_eq!(sid1.id_authority(), &[0, 0, 0, 0, 0, 5]);
assert_eq!(sid2.id_authority(), &[0, 0, 0, 0, 0, 1]);
}
Fixing this is, erm, complicated. I suppose the ideal solution would be to make Sid an unsized type ([u8]) instead of an opaque type. This would cause mem::replace to become a compile time error, I believe, but would turn pointers to Sid into fat pointers.
EDIT: I think what we'd need is rust-lang/rust#43467. If Sid was an Opaque Type, it'd be !Sized, and thus mem::replace wouldn't work, but a reference to it would still be only a single pointer.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinghelp wantedExtra attention is neededExtra attention is needed