File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -529,6 +529,29 @@ impl From<StrV> for Vec<GString> {
529
529
}
530
530
}
531
531
532
+ impl From < Vec < String > > for StrV {
533
+ #[ inline]
534
+ fn from ( value : Vec < String > ) -> Self {
535
+ unsafe {
536
+ let len = value. len ( ) ;
537
+ let mut s = Self :: with_capacity ( len) ;
538
+ for ( i, item) in value. into_iter ( ) . enumerate ( ) {
539
+ * s. ptr . as_ptr ( ) . add ( i) = GString :: from ( item) . into_glib_ptr ( ) ;
540
+ }
541
+ s. len = len;
542
+ * s. ptr . as_ptr ( ) . add ( s. len ) = ptr:: null_mut ( ) ;
543
+ s
544
+ }
545
+ }
546
+ }
547
+
548
+ impl < ' a > From < Vec < & ' a str > > for StrV {
549
+ #[ inline]
550
+ fn from ( value : Vec < & ' a str > ) -> Self {
551
+ value. as_slice ( ) . into ( )
552
+ }
553
+ }
554
+
532
555
impl From < Vec < GString > > for StrV {
533
556
#[ inline]
534
557
fn from ( value : Vec < GString > ) -> Self {
@@ -561,6 +584,21 @@ impl<const N: usize> From<[GString; N]> for StrV {
561
584
}
562
585
}
563
586
587
+ impl < ' a , const N : usize > From < [ & ' a str ; N ] > for StrV {
588
+ #[ inline]
589
+ fn from ( value : [ & ' a str ; N ] ) -> Self {
590
+ unsafe {
591
+ let mut s = Self :: with_capacity ( value. len ( ) ) ;
592
+ for ( i, item) in value. iter ( ) . enumerate ( ) {
593
+ * s. ptr . as_ptr ( ) . add ( i) = GString :: from ( * item) . into_glib_ptr ( ) ;
594
+ }
595
+ s. len = value. len ( ) ;
596
+ * s. ptr . as_ptr ( ) . add ( s. len ) = ptr:: null_mut ( ) ;
597
+ s
598
+ }
599
+ }
600
+ }
601
+
564
602
impl < ' a > From < & ' a [ & ' a str ] > for StrV {
565
603
#[ inline]
566
604
fn from ( value : & ' a [ & ' a str ] ) -> Self {
You can’t perform that action at this time.
0 commit comments