@@ -148,12 +148,12 @@ impl Window {
148
148
pub fn new ( width : i32 , height : i32 , title : String ) -> Window {
149
149
unsafe {
150
150
let mut temp: u64 = 0 ;
151
- let cstr_ret = CString :: new ( title. as_bytes ( ) ) ;
151
+ let cstr_ret = CString :: new ( title) ;
152
152
match cstr_ret {
153
153
Ok ( cstr) => {
154
154
let err_val = af_create_window ( & mut temp as MutWndHandle ,
155
155
width as c_int , height as c_int ,
156
- cstr. to_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ) ;
156
+ cstr. as_ptr ( ) ) ;
157
157
HANDLE_ERROR ( AfError :: from ( err_val) ) ;
158
158
Window :: from ( temp)
159
159
} ,
@@ -182,11 +182,11 @@ impl Window {
182
182
/// - `title` is the string to be displayed on window title bar
183
183
pub fn set_title ( & self , title : String ) {
184
184
unsafe {
185
- let cstr_ret = CString :: new ( title. as_bytes ( ) ) ;
185
+ let cstr_ret = CString :: new ( title) ;
186
186
match cstr_ret {
187
187
Ok ( cstr) => {
188
188
let err_val = af_set_title ( self . handle as WndHandle ,
189
- cstr. to_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ) ;
189
+ cstr. as_ptr ( ) ) ;
190
190
HANDLE_ERROR ( AfError :: from ( err_val) ) ;
191
191
} ,
192
192
Err ( _) => HANDLE_ERROR ( AfError :: ERR_INTERNAL ) ,
@@ -285,14 +285,14 @@ impl Window {
285
285
/// - `zlabel` is z axis title
286
286
pub fn set_axes_titles ( & mut self , xlabel : String , ylabel : String , zlabel : String ) {
287
287
let cprops = & Cell { row : self . row , col : self . col , title : String :: from ( "" ) , cmap : self . cmap } ;
288
- let xstr = CString :: new ( xlabel. as_bytes ( ) ) . unwrap ( ) ;
289
- let ystr = CString :: new ( ylabel. as_bytes ( ) ) . unwrap ( ) ;
290
- let zstr = CString :: new ( zlabel. as_bytes ( ) ) . unwrap ( ) ;
288
+ let xstr = CString :: new ( xlabel) . unwrap ( ) ;
289
+ let ystr = CString :: new ( ylabel) . unwrap ( ) ;
290
+ let zstr = CString :: new ( zlabel) . unwrap ( ) ;
291
291
unsafe {
292
292
let err_val = af_set_axes_titles ( self . handle as WndHandle ,
293
- xstr. to_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ,
294
- ystr. to_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ,
295
- zstr. to_bytes_with_nul ( ) . as_ptr ( ) as * const c_char ,
293
+ xstr. as_ptr ( ) ,
294
+ ystr. as_ptr ( ) ,
295
+ zstr. as_ptr ( ) ,
296
296
cprops as * const Cell as CellPtr ) ;
297
297
HANDLE_ERROR ( AfError :: from ( err_val) ) ;
298
298
}
0 commit comments