Add capacity_with_nul to ImString

This commit is contained in:
Joonas Javanainen 2017-04-25 22:35:29 +03:00
parent cf587e4de4
commit cfd887d2ab
No known key found for this signature in database
GPG Key ID: D39CCA5CB19B9179
2 changed files with 2 additions and 3 deletions

View File

@ -152,10 +152,8 @@ impl<'ui, 'p> InputText<'ui, 'p> {
pub fn build(self) -> bool {
unsafe {
imgui_sys::igInputText(self.label.as_ptr(),
// TODO: this is evil.
// Perhaps something else than &mut str is better
self.buf.as_ptr() as *mut i8,
self.buf.capacity() + 1,
self.buf.capacity_with_nul(),
self.flags,
None,
ptr::null_mut())

View File

@ -35,6 +35,7 @@ impl ImString {
self.0.push(b'\0');
}
pub fn capacity(&self) -> usize { self.0.capacity() - 1 }
pub fn capacity_with_nul(&self) -> usize { self.0.capacity() }
pub fn reserve(&mut self, additional: usize) {
self.0.reserve(additional);
}