From 485c8a230e3b11ed3109ca49ca2db7f2bbb6800b Mon Sep 17 00:00:00 2001 From: Malik Olivier Boussejra Date: Wed, 30 May 2018 14:20:28 +0900 Subject: [PATCH] window_draw_list: Use generic to add_text This change allows to use `add_text` with any type that implements `AsRef`. This includes `String`, `&str`, `ImString` and `&ImStr`. --- src/window_draw_list.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/window_draw_list.rs b/src/window_draw_list.rs index 3a34f80..4790b5f 100644 --- a/src/window_draw_list.rs +++ b/src/window_draw_list.rs @@ -210,11 +210,13 @@ impl<'ui> WindowDrawList<'ui> { } /// Draw a text whose upper-left corner is at point `pos`. - pub fn add_text(&self, pos: P, col: C, text: &str) + pub fn add_text(&self, pos: P, col: C, text: T) where P: Into, C: Into, + T: AsRef, { + let text = text.as_ref(); unsafe { let start = text.as_ptr() as *const i8; let end = (start as usize + text.len()) as *const i8;