diff --git a/cursive-core/src/views/text_view.rs b/cursive-core/src/views/text_view.rs index c2c8b3a..6c0d77f 100644 --- a/cursive-core/src/views/text_view.rs +++ b/cursive-core/src/views/text_view.rs @@ -89,7 +89,7 @@ impl TextContent { S: Into, { self.with_content(|c| { - *Arc::make_mut(&mut c.content_value) = content.into(); + *c = content.into(); }); } @@ -101,7 +101,7 @@ impl TextContent { self.with_content(|c| { // This will only clone content if content_cached and content_value // are sharing the same underlying Rc. - Arc::make_mut(&mut c.content_value).append(content); + c.append(content); }) } @@ -114,7 +114,15 @@ impl TextContent { } /// Apply the given closure to the inner content, and bust the cache afterward. - fn with_content(&self, f: F) -> O + pub fn with_content(&self, f: F) -> O + where + F: FnOnce(&mut StyledString) -> O, + { + self.with_content_inner(|c| f(Arc::make_mut(&mut c.content_value))) + } + + /// Apply the given closure to the inner content, and bust the cache afterward. + fn with_content_inner(&self, f: F) -> O where F: FnOnce(&mut TextContentInner) -> O, {