Skip to content

Commit

Permalink
Switch to using Arc::as_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Sep 5, 2022
1 parent 6fa5060 commit 1b45695
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions minijinja/src/value/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,8 @@ impl Value {
if let ValueRepr::Dynamic(ref obj) = self.0 {
if (**obj).type_id() == TypeId::of::<T>() {
unsafe {
// newer versions of Rust have RcType::as_ptr but we support
// rust versions down to 1.41.0 so we need to use a workaround here.
let count = Arc::strong_count(obj);
let clone = obj.clone();
let raw: *const (dyn Object) = Arc::into_raw(clone);
let rv = (raw as *const u8 as *const T).as_ref();
Arc::from_raw(raw);
debug_assert_eq!(count, Arc::strong_count(obj));
return rv;
let raw: *const (dyn Object) = Arc::as_ptr(obj);
return (raw as *const u8 as *const T).as_ref();
}
}
}
Expand Down

0 comments on commit 1b45695

Please sign in to comment.