Skip to content

Commit 57619db

Browse files
committed
wip
1 parent 7517bf7 commit 57619db

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

savefile-test/src/test_introspect.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ pub fn do_test_refcell() {
162162
let test = RefCell::new(32);
163163

164164
let x = (&test).introspect_value();
165-
assert_eq!(x, "RefCell(32 (deep introspect not supported))");
165+
assert_eq!(x, "RefCell(Ref(32))");
166166

167-
assert_eq!(test.introspect_len(), 0);
167+
assert_eq!(test.introspect_len(), 1);
168+
169+
assert_eq!(test.introspect_child(0).unwrap().val().introspect_value(), "Ref(32)");
168170
}
169171
#[test]
170172
pub fn do_test_rc() {

savefile/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,11 +3012,15 @@ impl<'a, T: Introspect> IntrospectItem<'a> for IntrospectItemRwLock<'a, T> {
30123012

30133013
impl<'a,T:Introspect> Introspect for std::cell::Ref<'a,T> {
30143014
fn introspect_value(&self) -> String {
3015-
"Ref".to_string()
3015+
let sub_value = (**self).introspect_value();
3016+
format!("Ref({})", sub_value)
30163017
}
30173018
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem + '_>> {
30183019
(**self).introspect_child(index)
30193020
}
3021+
fn introspect_len(&self) -> usize {
3022+
(**self).introspect_len()
3023+
}
30203024
}
30213025

30223026
impl<'a,T:Introspect> IntrospectItem<'a> for std::cell::Ref<'a,T> {
@@ -3031,7 +3035,8 @@ impl<'a,T:Introspect> IntrospectItem<'a> for std::cell::Ref<'a,T> {
30313035

30323036
impl<T: Introspect> Introspect for RefCell<T> {
30333037
fn introspect_value(&self) -> String {
3034-
"RefCell".to_string()
3038+
let sub_value = self.borrow().introspect_value();
3039+
format!("RefCell({})", sub_value)
30353040
}
30363041

30373042
fn introspect_child(&self, index: usize) -> Option<Box<dyn IntrospectItem + '_>> {

0 commit comments

Comments
 (0)