File tree Expand file tree Collapse file tree 1 file changed +22
-2
lines changed
Expand file tree Collapse file tree 1 file changed +22
-2
lines changed Original file line number Diff line number Diff line change 1+ use core:: num:: { ParseFloatError , ParseIntError } ;
12use std:: ffi:: CString ;
23use std:: slice;
34use std:: str;
4- use core:: num:: { ParseFloatError , ParseIntError } ;
55
66pub type RedisResult = Result < RedisValue , RedisError > ;
77
@@ -68,6 +68,21 @@ impl From<&str> for RedisValue {
6868 }
6969}
7070
71+ impl From < Option < String > > for RedisValue {
72+ fn from ( s : Option < String > ) -> Self {
73+ match s {
74+ Some ( v) => RedisValue :: SimpleString ( v) ,
75+ None => RedisValue :: None ,
76+ }
77+ }
78+ }
79+
80+ impl From < Vec < Option < String > > > for RedisValue {
81+ fn from ( strings : Vec < Option < String > > ) -> Self {
82+ RedisValue :: Array ( strings. into_iter ( ) . map ( |v| v. into ( ) ) . collect ( ) )
83+ }
84+ }
85+
7186impl From < Vec < String > > for RedisValue {
7287 fn from ( strings : Vec < String > ) -> Self {
7388 RedisValue :: Array ( strings. into_iter ( ) . map ( RedisValue :: BulkString ) . collect ( ) )
@@ -76,7 +91,12 @@ impl From<Vec<String>> for RedisValue {
7691
7792impl From < Vec < & String > > for RedisValue {
7893 fn from ( strings : Vec < & String > ) -> Self {
79- RedisValue :: Array ( strings. into_iter ( ) . map ( |s| RedisValue :: BulkString ( s. to_string ( ) ) ) . collect ( ) )
94+ RedisValue :: Array (
95+ strings
96+ . into_iter ( )
97+ . map ( |s| RedisValue :: BulkString ( s. to_string ( ) ) )
98+ . collect ( ) ,
99+ )
80100 }
81101}
82102
You can’t perform that action at this time.
0 commit comments