Skip to content
Myr

Format with rustfmt 2019-09-08

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by David Tolnay · committed by David Tolnay · parent 4118197 · Browse files · 2 files+13 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−4 removed

  • tests:+4 added−1 removed
  • other:+9 added−3 removed

2 files+13 added−4 removed

modified:src/error.rs+9 added-3 removed
231 unmodified lines
232 {233 if self.is::<E>() {234 let outer = ManuallyDrop::new(self);235 unsafe {236 let error = ptr::read(outer.inner.error() as *const (dyn StdError + Send + Sync) as *const E);236 let error = ptr::read(237 outer.inner.error() as *const (dyn StdError + Send + Sync) as *const E238 );239 let inner = ptr::read(&outer.inner);240 let erased = ManuallyDrop::into_inner(inner);241 (erased.vtable.object_drop_front)(erased);242 Ok(error)
43 unmodified lines
286 where287 E: Display + Debug + Send + Sync + 'static,288 {289 if self.is::<E>() {288 Some(unsafe { &*(self.inner.error() as *const (dyn StdError + Send + Sync) as *const E) })290 Some(unsafe {291 &*(self.inner.error() as *const (dyn StdError + Send + Sync) as *const E)292 })293 } else {294 None295 }296 }
3 unmodified lines
300 where301 E: Display + Debug + Send + Sync + 'static,302 {303 if self.is::<E>() {300 Some(unsafe { &mut *(self.inner.error_mut() as *mut (dyn StdError + Send + Sync) as *mut E) })304 Some(unsafe {305 &mut *(self.inner.error_mut() as *mut (dyn StdError + Send + Sync) as *mut E)306 })307 } else {308 None309 }310 }
296 unmodified lines
modified:tests/test_downcast.rs+4 added-1 removed
92 unmodified lines
9394 impl StdError for LargeAlignedError {}9596 let error = Error::new(LargeAlignedError("oh no!"));97 assert_eq!("oh no!", error.downcast_ref::<LargeAlignedError>().unwrap().0);97 assert_eq!(98 "oh no!",99 error.downcast_ref::<LargeAlignedError>().unwrap().0100 );101}