/// Parse a sort expression and return a [Sorter].
///
/// Valid sort expressions consist of a comma-separated list of sorts, each of
/// which may be optionally preceded by a `-` to reverse its sense.
Parse a sort expression and return a [Sorter].
Valid sort expressions consist of a comma-separated list of sorts, each of
which may be optionally preceded by a `-` to reverse its sense.
Parse a sort expression and return a [ Sorter ] . Valid sort expressions consist of a comma - separated list of sorts each of which may be optionally preceded by a ` - ` to reverse its sense .
pub fn create_sort(&self, expr: &str) -> Result<Box<dyn Sorter<R> + 's>, SorterError> {
        let parts = expr.split(',').collect::<Vec<&str>>();
        let mut full_sort: Option<Box<dyn Sorter<R> + 's>> = None;
        for part in parts.iter().rev() {
            let part_sort = if let Some(name) = part.strip_prefix('-') {
                let mut sp = SortProcessor { name, result: None };
                R::get_meta(self.access.clone()).accept_visitor(&mut sp);
                sp.result
                    .ok_or_else(|| SorterError::NoSort(part.to_string()))?
                    .instantiate(true)
            } else {
                let mut sp = SortProcessor {
                    name: *part,
                    result: None,
                };
                R::get_meta(self.access.clone()).accept_visitor(&mut sp);
                sp.result
                    .ok_or_else(|| SorterError::NoSort(part.to_string()))?
                    .instantiate(false)
            };
            full_sort = if let Some(sort) = full_sort {
                Some(Box::new(StackedSorter::new(part_sort, sort)))
            } else {
                Some(part_sort)
            };
        }
        full_sort.ok_or_else(|| SorterError::NoSort(expr.to_string()))
    }
pub fn create_sort ( & self , expr : & str ) -> Result < Box < dyn Sorter < R > + ' s > , SorterError > { let parts = expr . split ( ',' ) . collect :: < Vec < & str > > ( ) ; let mut full_sort : Option < Box < dyn Sorter < R > + ' s > > = None ; for part in parts . iter ( ) . rev ( ) { let part_sort = if let Some ( name ) = part . strip_prefix ( '-' ) { let mut sp = SortProcessor { name , result : None } ; R :: get_meta ( self . access . clone ( ) ) . accept_visitor ( & mut sp ) ; sp . result . ok_or_else ( | | SorterError :: NoSort ( part . to_string ( ) ) ) ? . instantiate ( true ) } else { let mut sp = SortProcessor { name : * part , result : None , } ; R :: get_meta ( self . access . clone ( ) ) . accept_visitor ( & mut sp ) ; sp . result . ok_or_else ( | | SorterError :: NoSort ( part . to_string ( ) ) ) ? . instantiate ( false ) } ; full_sort = if let Some ( sort ) = full_sort { Some ( Box :: new ( StackedSorter :: new ( part_sort , sort ) ) ) } else { Some ( part_sort ) } ; } full_sort . ok_or_else ( | | SorterError :: NoSort ( expr . to_string ( ) ) ) }
Parse a sort expression and return a [Sorter].
Parse a sort expression and return a [ Sorter ] .
&self
expr
&str