Builder pattern in Rust
Në shqip: Modeli Builder në Rust
ShpjegimiSQ
Rust s'ka parametra opsionalë, prandaj për tipe me shumë cilësime përdoret „builder“: Kerkese::new(url).timeout(5).header(...).build(). reqwest dhe shumë crate-e e përdorin.
EnglishEN
Rust has no optional parameters, so types with many settings use a “builder”: Request::new(url).timeout(5).header(...).build(). reqwest and many crates use it.
Si ta mendosh
Si të porositësh një pizza duke shtuar përbërës një nga një.
Lexoje në anglisht
Like ordering a pizza by adding toppings one by one.
Shembull kodirust
let klienti = reqwest::Client::builder()
.timeout(Duration::from_secs(5))
.user_agent("fjalori")
.build()?;