@@ -4,7 +4,6 @@ use std::ffi::CString;
4
4
use std:: marker;
5
5
use std:: path:: Path ;
6
6
use std:: ptr;
7
- use std:: result:: Result as StdResult ;
8
7
use super :: Code ;
9
8
use super :: DataType ;
10
9
use super :: Graph ;
@@ -44,27 +43,23 @@ impl Session {
44
43
-> Result < Self > {
45
44
let mut status = Status :: new ( ) ;
46
45
47
- let export_dir_cstr = try!( export_dir. as_ref ( )
48
- . to_str ( )
49
- . and_then ( |s| CString :: new ( s. as_bytes ( ) ) . ok ( ) )
50
- . ok_or_else ( || {
51
- Status :: new_set ( Code :: InvalidArgument , "Invalid export directory path" ) . unwrap ( )
52
- } ) ) ;
46
+ let export_dir_cstr =
47
+ try!( export_dir. as_ref ( )
48
+ . to_str ( )
49
+ . and_then ( |s| CString :: new ( s. as_bytes ( ) ) . ok ( ) )
50
+ . ok_or_else ( || invalid_arg ! ( "Invalid export directory path" ) ) ) ;
53
51
54
52
let tags_cstr: Vec < _ > = try!( tags. into_iter ( )
55
53
. map ( |t| CString :: new ( t. as_ref ( ) ) )
56
- . collect :: < StdResult < _ , _ > > ( )
57
- . map_err ( |_| {
58
- Status :: new_set ( Code :: InvalidArgument , "Invalid tag name" ) . unwrap ( )
59
- } ) ) ;
54
+ . collect :: < :: std:: result:: Result < _ , _ > > ( )
55
+ . map_err ( |_| invalid_arg ! ( "Invalid tag name" ) ) ) ;
60
56
// keeping tags_cstr to retain strings in memory
61
57
let tags_ptr: Vec < * const c_char > = tags_cstr. iter ( ) . map ( |t| t. as_ptr ( ) ) . collect ( ) ;
62
58
63
59
let inner = unsafe {
64
60
tf:: TF_LoadSessionFromSavedModel ( options. inner ,
65
61
ptr:: null ( ) ,
66
- export_dir_cstr. to_bytes_with_nul ( ) . as_ptr ( ) as
67
- * const c_char ,
62
+ export_dir_cstr. as_ptr ( ) ,
68
63
tags_ptr. as_ptr ( ) ,
69
64
tags_ptr. len ( ) as c_int ,
70
65
graph. inner ( ) ,
@@ -351,3 +346,4 @@ mod tests {
351
346
assert_eq ! ( data[ 1 ] , 6.0 ) ;
352
347
}
353
348
}
349
+
0 commit comments