@@ -29,22 +29,25 @@ fn depth_offset(reader: &dyn Reader) -> usize {
2929 let catalogs = reader. list_catalogs ( ) . unwrap_or_default ( ) ;
3030 if catalogs. is_empty ( ) {
3131 let schemas = reader. list_schemas ( "" ) . unwrap_or_default ( ) ;
32- if schemas. is_empty ( ) { 2 } else { 1 }
32+ if schemas. is_empty ( ) {
33+ 2
34+ } else {
35+ 1
36+ }
3337 } else {
3438 0
3539 }
3640}
3741
38- fn full_path < ' a > ( offset : usize , path : & ' a [ String ] ) -> Vec < & ' a str > {
39- std:: iter:: repeat ( "" )
40- . take ( offset)
41- . chain ( path. iter ( ) . map ( |s| s. as_str ( ) ) )
42+ fn full_path ( offset : usize , path : & [ String ] ) -> Vec < String > {
43+ std:: iter:: repeat_n ( String :: new ( ) , offset)
44+ . chain ( path. iter ( ) . cloned ( ) )
4245 . collect ( )
4346}
4447
4548/// Resolve a UI path to a full `[catalog, schema, ...]` path, padding
4649/// skipped hierarchy levels with empty strings.
47- pub fn resolve_path < ' a > ( reader : & dyn Reader , path : & ' a [ String ] ) -> Vec < & ' a str > {
50+ pub fn resolve_path ( reader : & dyn Reader , path : & [ String ] ) -> Vec < String > {
4851 full_path ( depth_offset ( reader) , path)
4952}
5053
@@ -53,8 +56,8 @@ pub fn list_objects(reader: &dyn Reader, path: &[String]) -> Result<Vec<ObjectSc
5356 let full = full_path ( depth_offset ( reader) , path) ;
5457 match full. len ( ) {
5558 0 => list_catalogs ( reader) ,
56- 1 => list_schemas ( reader, full[ 0 ] ) ,
57- 2 => list_tables ( reader, full[ 0 ] , full[ 1 ] ) ,
59+ 1 => list_schemas ( reader, & full[ 0 ] ) ,
60+ 2 => list_tables ( reader, & full[ 0 ] , & full[ 1 ] ) ,
5861 _ => Ok ( vec ! [ ] ) ,
5962 }
6063}
@@ -65,7 +68,7 @@ pub fn list_fields(reader: &dyn Reader, path: &[String]) -> Result<Vec<FieldSche
6568 if full. len ( ) != 3 {
6669 return Ok ( vec ! [ ] ) ;
6770 }
68- list_columns ( reader, full[ 0 ] , full[ 1 ] , full[ 2 ] )
71+ list_columns ( reader, & full[ 0 ] , & full[ 1 ] , & full[ 2 ] )
6972}
7073
7174/// Whether the path points to an object that contains data (table or view).
0 commit comments