summaryrefslogtreecommitdiffstats
path: root/native/src/widget/text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/widget/text.rs')
-rw-r--r--native/src/widget/text.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/native/src/widget/text.rs b/native/src/widget/text.rs
index c4ab88d3..cf0701b9 100644
--- a/native/src/widget/text.rs
+++ b/native/src/widget/text.rs
@@ -32,9 +32,9 @@ impl Text {
/// Create a new fragment of [`Text`] with the given contents.
///
/// [`Text`]: struct.Text.html
- pub fn new(label: &str) -> Self {
+ pub fn new<T: Into<String>>(label: T) -> Self {
Text {
- content: String::from(label),
+ content: label.into(),
size: None,
color: None,
font: Font::Default,
@@ -174,8 +174,15 @@ where
/// [renderer]: ../../renderer/index.html
/// [`UserInterface`]: ../../struct.UserInterface.html
pub trait Renderer: crate::Renderer {
+ /// Returns the default size of the [`Text`].
+ ///
+ /// [`Text`]: struct.Text.html
fn default_size(&self) -> u16;
+ /// Measures the [`Text`] in the given bounds and returns the minimum
+ /// boundaries that can fit the contents.
+ ///
+ /// [`Text`]: struct.Text.html
fn measure(
&self,
content: &str,