(refactor) Use ptr::read and ptr::write.