pub struct TextContent { /* private fields */ }
Expand description
Provides access to the content of a TextView
.
Cloning this object will still point to the same content.
§Examples
let mut content = TextContent::new("content");
let view = TextView::new_with_content(content.clone());
// Later, possibly in a different thread
content.set_content("new content");
assert!(view.get_content().source().contains("new"));
Implementations§
Source§impl TextContent
impl TextContent
Sourcepub fn new<S>(content: S) -> TextContent
pub fn new<S>(content: S) -> TextContent
Creates a new text content around the given value.
Parses the given value.
Source§impl TextContent
impl TextContent
Sourcepub fn set_content<S>(&self, content: S)
pub fn set_content<S>(&self, content: S)
Replaces the content with the given value.
Sourcepub fn get_content(&self) -> TextContentRef
pub fn get_content(&self) -> TextContentRef
Returns a reference to the content.
This locks the data while the returned value is alive, so don’t keep it too long.
Sourcepub fn with_content<F, O>(&self, f: F) -> O
pub fn with_content<F, O>(&self, f: F) -> O
Apply the given closure to the inner content, and bust the cache afterward.
Trait Implementations§
Source§impl Clone for TextContent
impl Clone for TextContent
Source§fn clone(&self) -> TextContent
fn clone(&self) -> TextContent
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for TextContent
impl !RefUnwindSafe for TextContent
impl Send for TextContent
impl Sync for TextContent
impl Unpin for TextContent
impl !UnwindSafe for TextContent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more