Want a mechanism to avoid automatically applied derive macros

Aperta
#62 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
30/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
tooling

Direzione di ricerca

Read the issue’s example of the generated PartialOrd and Ord implementations and the proposed per-type trait exclusions. Start by locating where typify chooses and generates derived traits; the issue does not name files or tests. Done means users can suppress selected derived traits for specific types so they can provide their own implementations.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I have an OpenAPI document with a type PortId. That is an enum, but represented in the schema as a strictly-formatted string, as "prefixN", where the prefix is defined by the enum variant and N is a u8 limited to some range. For example, "qsfp4" or "rear0". Typify derives the ordering traits PartialOrd and Ord for this type, which delegate to the implementations for String. I would like to implement these traits myself, because (1) I'd like numeric sorting based on N rather than lexicographic, and (2) I'd like to put all values "rearM" before any `"qsfpN".

It would be nice to have escape hatches to ask typify not to generate certain derivable traits, ideally for specific types. Something like a mapping from type names to traits that should not be derived seems pretty flexible.

Lingua principale
Rust
Stelle
4
Fork
4
Merge medio
15h 16m
PR unite (30g)
26

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di oxidecomputer/typespace

Tutte le issue di oxidecomputer/typespace

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.