A `method!` macro to define methods at build time
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
Direzione di ricerca
Inizia leggendo Method::from_bytes e la issue collegata di hyperium/http sui metodi HTTP non definiti. Determina come una macro potrebbe validare un verbo letterale in fase di compilazione e produrre un Method senza la gestione di Result a runtime. Il lavoro è completato quando la forma proposta method!("PROPFIND") ha una semantica definita e accetta verbi personalizzati validi, rifiutando quelli non validi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Using HTTP verbs / methods that are not defined in this crate has very ugly semantics, e.g.:
Method::from_bytes(b"PROPFIND").expect("PROPFIND is a valid method")
This expect adds a lot of noise all over the place, but it also can't be defined as a const. The following in invalid:
const PROPFIND: Method = Method::from_bytes(b"PROPFIND")
.expect("PROPFIND is a valid method")
At the same time, these verbs are something that can be validated at build time (rather than runtime). Do you think a macro to create methods would be reasonable? I'm thinking something along the lines of:
method!("PROPFIND");
It would simply be replaced by the correct method, but a proc_macro could allow validating that the string is an acceptable verb at build time (hence, avoiding having a Result for an operation that is known to be infallible).
- Lingua principale
- Rust
- Stelle
- 1.4k
- Fork
- 378
- Merge medio
- 1g 21h
- PR unite (30g)
- 5
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di hyperium/http
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 62/100
Tutte le issue di hyperium/http
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
state:needs triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
zed-industries/zed#64680 · 2 commenti ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
RustPython/RustPython#8802 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
TheLarkInn/aipm#2390 ·