#[derive(SortableWithPersianRug)]
{
    // Attributes available to this derive:
    #[django]
}
Available on crate features sort and persian-rug only.
Expand description

Derive the SortableWithContext trait for persian-rug types.

This is only implemented for structs with named fields. No fields will be available to use as sort orders, unless there are annotations to indicate otherwise. The annotations use the django attribute, which has the following significant options here:

  • #[django(rename="new_name")] Expose the annotated member for sorting as `new_name instead of using its name in the source code.

  • #[django(sort)] The field, which must be Ord, will be exposed as a sort order for the enclosing type. The ordering is taken directly from Ord.

  • #[django(sort="name","age")] The field has a type which is itself Sortable. Expose this field as defining a sort order of the same name, and When sorting by this field make the order defined by the field’s own member name, and then by its own member age as a secondary sort.

The struct itself must also be annotated with the django attribute, which gives the persian-rug constraints to apply to to each derived impl:

  • #[django(persian_rug(context=Rug))] The persian-rug context type for this type is Rug.

  • #[django(persian_rug(context=C, access(Foo<C>)))] The persian-rug context type is the template parameter C. The context must provide access to Foo<C>.