Skip to content

Commit a96840a

Browse files
committed
Add missing trait impls for SafeRcMakeMut
1 parent 45f17ab commit a96840a

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

vm/src/saferc.rs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::mem::ManuallyDrop;
22
use std::rc::Rc;
3+
use std::sync::Arc;
34

45
use everscale_types::error::Error;
56
use everscale_types::prelude::*;
@@ -60,6 +61,11 @@ impl<T: SafeDelete + ?Sized> SafeRc<T> {
6061
pub fn ptr_eq(lhs: &Self, rhs: &Self) -> bool {
6162
Rc::<T>::ptr_eq(&*lhs.0, &*rhs.0)
6263
}
64+
65+
#[inline]
66+
pub fn as_ptr(&self) -> *const T {
67+
Rc::as_ptr(&*self.0)
68+
}
6369
}
6470

6571
impl<T: SafeDelete + Clone> SafeRc<T> {
@@ -212,6 +218,48 @@ impl<T: SafeRcMakeMut + ?Sized> SafeRc<T> {
212218
}
213219
}
214220

221+
impl SafeRcMakeMut for () {
222+
#[inline]
223+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
224+
Rc::make_mut(rc)
225+
}
226+
}
227+
228+
impl<T: Clone + 'static> SafeRcMakeMut for Box<T> {
229+
#[inline]
230+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
231+
Rc::make_mut(rc)
232+
}
233+
}
234+
235+
impl<T: ?Sized + 'static> SafeRcMakeMut for Rc<T> {
236+
#[inline]
237+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
238+
Rc::make_mut(rc)
239+
}
240+
}
241+
242+
impl<T: ?Sized + 'static> SafeRcMakeMut for Arc<T> {
243+
#[inline]
244+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
245+
Rc::make_mut(rc)
246+
}
247+
}
248+
249+
impl<T: Clone + 'static> SafeRcMakeMut for Vec<T> {
250+
#[inline]
251+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
252+
Rc::make_mut(rc)
253+
}
254+
}
255+
256+
impl SafeRcMakeMut for String {
257+
#[inline]
258+
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
259+
Rc::make_mut(rc)
260+
}
261+
}
262+
215263
// === Cell traits impl ===
216264

217265
impl<'a, T: Load<'a> + SafeDelete> Load<'a> for SafeRc<T> {

vm/src/stack.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,6 @@ impl StackValue for () {
783783
}
784784
}
785785

786-
impl SafeRcMakeMut for () {
787-
#[inline]
788-
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
789-
Rc::make_mut(rc)
790-
}
791-
}
792-
793786
// === Int (NaN) ===
794787

795788
/// Invalid integer stack value.
@@ -1303,13 +1296,6 @@ impl StaticStackValue for Tuple {
13031296
}
13041297
}
13051298

1306-
impl SafeRcMakeMut for Tuple {
1307-
#[inline]
1308-
fn rc_make_mut(rc: &mut Rc<Self>) -> &mut Self {
1309-
Rc::make_mut(rc)
1310-
}
1311-
}
1312-
13131299
// === Store/Load ===
13141300

13151301
/// ```text

0 commit comments

Comments
 (0)