mirror of
https://github.com/FliegendeWurst/cursive.git
synced 2024-11-23 17:35:00 +00:00
Accept Into<String>
in EditView::set_content
This commit is contained in:
parent
d51772f714
commit
24511ae5f1
@ -165,10 +165,13 @@ impl EditView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Replace the entire content of the view with the given one.
|
/// Replace the entire content of the view with the given one.
|
||||||
pub fn set_content(&mut self, content: &str) {
|
pub fn set_content<S: Into<String>>(&mut self, content: S) {
|
||||||
self.content = Rc::new(content.to_string());
|
let content = content.into();
|
||||||
|
let len = content.len();
|
||||||
|
|
||||||
|
self.content = Rc::new(content);
|
||||||
self.offset = 0;
|
self.offset = 0;
|
||||||
self.set_cursor(content.len());
|
self.set_cursor(len);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current text.
|
/// Get the current text.
|
||||||
@ -179,7 +182,7 @@ impl EditView {
|
|||||||
/// Sets the current content to the given value.
|
/// Sets the current content to the given value.
|
||||||
///
|
///
|
||||||
/// Convenient chainable method.
|
/// Convenient chainable method.
|
||||||
pub fn content(mut self, content: &str) -> Self {
|
pub fn content<S: Into<String>>(mut self, content: S) -> Self {
|
||||||
self.set_content(content);
|
self.set_content(content);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user