From 06743da5def5401e5208dcd37520e4a0922cd248 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Wed, 16 Mar 2022 17:27:10 -0500 Subject: [PATCH] Warn if `Request`s aren't sent (#490) I added `ureq::get("http://example.com")` to a toy program and was very confused when it did nothing. Change `Request` to give a warning if unsent: ``` warning: unused `ureq::Request` that must be used --> src/main.rs:48:5 | 48 | ureq::get("http://example.com"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: Requests do nothing until consumed by `call()` ``` --- src/request.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/request.rs b/src/request.rs index 42eb455..ed2a987 100644 --- a/src/request.rs +++ b/src/request.rs @@ -24,6 +24,7 @@ pub type Result = std::result::Result; /// # } /// ``` #[derive(Clone)] +#[must_use = "Requests do nothing until consumed by `call()`"] pub struct Request { agent: Agent, method: String,