1- use std:: c_str :: ToCStr ;
2- use std:: kinds :: marker;
1+ use std:: ffi :: CString ;
2+ use std:: marker;
33use std:: str;
44use libc;
55
@@ -44,7 +44,7 @@ impl Config {
4444 :: init ( ) ;
4545 let mut raw = 0 as * mut raw:: git_config ;
4646 unsafe {
47- try_call ! ( raw:: git_config_open_ondisk( & mut raw, path. to_c_str ( ) ) ) ;
47+ try_call ! ( raw:: git_config_open_ondisk( & mut raw, CString :: from_slice ( path. as_vec ( ) ) ) ) ;
4848 Ok ( Config :: from_raw ( raw) )
4949 }
5050 }
@@ -124,7 +124,7 @@ impl Config {
124124 pub fn add_file ( & mut self , path : & Path , level : ConfigLevel ,
125125 force : bool ) -> Result < ( ) , Error > {
126126 unsafe {
127- try_call ! ( raw:: git_config_add_file_ondisk( self . raw, path. to_c_str ( ) ,
127+ try_call ! ( raw:: git_config_add_file_ondisk( self . raw, CString :: from_slice ( path. as_vec ( ) ) ,
128128 level, force) ) ;
129129 Ok ( ( ) )
130130 }
@@ -134,7 +134,7 @@ impl Config {
134134 /// (usually the local one).
135135 pub fn remove ( & mut self , name : & str ) -> Result < ( ) , Error > {
136136 unsafe {
137- try_call ! ( raw:: git_config_delete_entry( self . raw, name. to_c_str ( ) ) ) ;
137+ try_call ! ( raw:: git_config_delete_entry( self . raw, CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
138138 Ok ( ( ) )
139139 }
140140 }
@@ -148,7 +148,7 @@ impl Config {
148148 let mut out = 0 as libc:: c_int ;
149149 unsafe {
150150 try_call ! ( raw:: git_config_get_bool( & mut out, & * self . raw,
151- name. to_c_str ( ) ) ) ;
151+ CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
152152 }
153153 Ok ( if out == 0 { false } else { true } )
154154 }
@@ -162,7 +162,7 @@ impl Config {
162162 let mut out = 0i32 ;
163163 unsafe {
164164 try_call ! ( raw:: git_config_get_int32( & mut out, & * self . raw,
165- name. to_c_str ( ) ) ) ;
165+ CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
166166 }
167167 Ok ( out)
168168 }
@@ -176,7 +176,7 @@ impl Config {
176176 let mut out = 0i64 ;
177177 unsafe {
178178 try_call ! ( raw:: git_config_get_int64( & mut out, & * self . raw,
179- name. to_c_str ( ) ) ) ;
179+ CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
180180 }
181181 Ok ( out)
182182 }
@@ -196,7 +196,7 @@ impl Config {
196196 let mut ret = 0 as * const libc:: c_char ;
197197 unsafe {
198198 try_call ! ( raw:: git_config_get_string( & mut ret, & * self . raw,
199- name. to_c_str ( ) ) ) ;
199+ CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
200200 Ok ( :: opt_bytes ( self , ret) . unwrap ( ) )
201201 }
202202 }
@@ -206,7 +206,7 @@ impl Config {
206206 let mut ret = 0 as * const raw:: git_config_entry ;
207207 unsafe {
208208 try_call ! ( raw:: git_config_get_entry( & mut ret, & * self . raw,
209- name. to_c_str ( ) ) ) ;
209+ CString :: from_slice ( name. as_bytes ( ) ) ) ) ;
210210 Ok ( ConfigEntry :: from_raw ( ret) )
211211 }
212212 }
@@ -234,7 +234,7 @@ impl Config {
234234 Some ( s) => {
235235 try_call ! ( raw:: git_config_iterator_glob_new( & mut ret,
236236 & * self . raw,
237- s . to_c_str ( ) ) ) ;
237+ CString :: from_slice ( s . as_bytes ( ) ) ) ) ;
238238 }
239239 None => {
240240 try_call ! ( raw:: git_config_iterator_new( & mut ret, & * self . raw) ) ;
@@ -274,7 +274,7 @@ impl Config {
274274 /// highest level (usually the local one).
275275 pub fn set_bool ( & mut self , name : & str , value : bool ) -> Result < ( ) , Error > {
276276 unsafe {
277- try_call ! ( raw:: git_config_set_bool( self . raw, name. to_c_str ( ) ,
277+ try_call ! ( raw:: git_config_set_bool( self . raw, CString :: from_slice ( name. as_bytes ( ) ) ,
278278 value) ) ;
279279 }
280280 Ok ( ( ) )
@@ -284,7 +284,7 @@ impl Config {
284284 /// highest level (usually the local one).
285285 pub fn set_i32 ( & mut self , name : & str , value : i32 ) -> Result < ( ) , Error > {
286286 unsafe {
287- try_call ! ( raw:: git_config_set_int32( self . raw, name. to_c_str ( ) ,
287+ try_call ! ( raw:: git_config_set_int32( self . raw, CString :: from_slice ( name. as_bytes ( ) ) ,
288288 value) ) ;
289289 }
290290 Ok ( ( ) )
@@ -294,7 +294,7 @@ impl Config {
294294 /// highest level (usually the local one).
295295 pub fn set_i64 ( & mut self , name : & str , value : i64 ) -> Result < ( ) , Error > {
296296 unsafe {
297- try_call ! ( raw:: git_config_set_int64( self . raw, name. to_c_str ( ) ,
297+ try_call ! ( raw:: git_config_set_int64( self . raw, CString :: from_slice ( name. as_bytes ( ) ) ,
298298 value) ) ;
299299 }
300300 Ok ( ( ) )
@@ -304,8 +304,8 @@ impl Config {
304304 /// highest level (usually the local one).
305305 pub fn set_str ( & mut self , name : & str , value : & str ) -> Result < ( ) , Error > {
306306 unsafe {
307- try_call ! ( raw:: git_config_set_string( self . raw, name. to_c_str ( ) ,
308- value. to_c_str ( ) ) ) ;
307+ try_call ! ( raw:: git_config_set_string( self . raw, CString :: from_slice ( name. as_bytes ( ) ) ,
308+ CString :: from_slice ( value. as_bytes ( ) ) ) ) ;
309309 }
310310 Ok ( ( ) )
311311 }
0 commit comments