11//! A fixed capacity [`CString`](https://doc.rust-lang.org/std/ffi/struct.CString.html).
22
3- use crate :: { vec:: Vec , CapacityError } ;
3+ use crate :: { len_type :: DefaultLenType , vec:: Vec , CapacityError , LenType } ;
44use core:: {
55 borrow:: Borrow ,
66 cmp:: Ordering ,
@@ -14,11 +14,11 @@ use core::{
1414///
1515/// It stores up to `N - 1` non-nul characters with a trailing nul terminator.
1616#[ derive( Clone , Hash ) ]
17- pub struct CString < const N : usize > {
18- inner : Vec < u8 , N > ,
17+ pub struct CString < const N : usize , LenT : LenType = DefaultLenType < N > > {
18+ inner : Vec < u8 , N , LenT > ,
1919}
2020
21- impl < const N : usize > CString < N > {
21+ impl < const N : usize , LenT : LenType > CString < N , LenT > {
2222 /// Creates a new C-compatible string with a terminating nul byte.
2323 ///
2424 /// ```rust
@@ -264,28 +264,28 @@ impl<const N: usize> CString<N> {
264264 }
265265}
266266
267- impl < const N : usize > AsRef < CStr > for CString < N > {
267+ impl < const N : usize , LenT : LenType > AsRef < CStr > for CString < N , LenT > {
268268 #[ inline]
269269 fn as_ref ( & self ) -> & CStr {
270270 self . as_c_str ( )
271271 }
272272}
273273
274- impl < const N : usize > Borrow < CStr > for CString < N > {
274+ impl < const N : usize , LenT : LenType > Borrow < CStr > for CString < N , LenT > {
275275 #[ inline]
276276 fn borrow ( & self ) -> & CStr {
277277 self . as_c_str ( )
278278 }
279279}
280280
281- impl < const N : usize > Default for CString < N > {
281+ impl < const N : usize , LenT : LenType > Default for CString < N , LenT > {
282282 #[ inline]
283283 fn default ( ) -> Self {
284284 Self :: new ( )
285285 }
286286}
287287
288- impl < const N : usize > Deref for CString < N > {
288+ impl < const N : usize , LenT : LenType > Deref for CString < N , LenT > {
289289 type Target = CStr ;
290290
291291 #[ inline]
@@ -294,23 +294,27 @@ impl<const N: usize> Deref for CString<N> {
294294 }
295295}
296296
297- impl < const N : usize , const M : usize > PartialEq < CString < M > > for CString < N > {
297+ impl < const N : usize , const M : usize , LenT1 : LenType , LenT2 : LenType > PartialEq < CString < M , LenT2 > >
298+ for CString < N , LenT1 >
299+ {
298300 #[ inline]
299- fn eq ( & self , rhs : & CString < M > ) -> bool {
301+ fn eq ( & self , rhs : & CString < M , LenT2 > ) -> bool {
300302 self . as_c_str ( ) == rhs. as_c_str ( )
301303 }
302304}
303305
304- impl < const N : usize > Eq for CString < N > { }
306+ impl < const N : usize , LenT : LenType > Eq for CString < N , LenT > { }
305307
306- impl < const N : usize , const M : usize > PartialOrd < CString < M > > for CString < N > {
308+ impl < const N : usize , const M : usize , LenT1 : LenType , LenT2 : LenType > PartialOrd < CString < M , LenT2 > >
309+ for CString < N , LenT1 >
310+ {
307311 #[ inline]
308- fn partial_cmp ( & self , rhs : & CString < M > ) -> Option < Ordering > {
312+ fn partial_cmp ( & self , rhs : & CString < M , LenT2 > ) -> Option < Ordering > {
309313 self . as_c_str ( ) . partial_cmp ( rhs. as_c_str ( ) )
310314 }
311315}
312316
313- impl < const N : usize > Ord for CString < N > {
317+ impl < const N : usize , LenT : LenType > Ord for CString < N , LenT > {
314318 #[ inline]
315319 fn cmp ( & self , rhs : & Self ) -> Ordering {
316320 self . as_c_str ( ) . cmp ( rhs. as_c_str ( ) )
0 commit comments