Skip to content

Commit 1dddc98

Browse files
committed
cleanup style
1 parent a753ab6 commit 1dddc98

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

dogstatsd/src/datadog.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl MetricsIntakeUrlPrefix {
116116

117117
#[inline]
118118
fn from_site(site: Site) -> Self {
119-
Self(format!("https://api.{}", site))
119+
Self(format!("https://api.{site}"))
120120
}
121121
}
122122

@@ -185,25 +185,23 @@ impl DdApi {
185185
body: Vec<u8>,
186186
content_type: &str,
187187
) -> Result<Response, ShippingError> {
188-
if let Some(client) = &self.client {
189-
let start = std::time::Instant::now();
190-
191-
let resp = client
192-
.post(&url)
193-
.header("DD-API-KEY", &self.api_key)
194-
.header("Content-Type", content_type)
195-
.body(body)
196-
.send()
197-
.await;
198-
199-
let elapsed = start.elapsed();
200-
debug!("Request to {} took {}ms", url, elapsed.as_millis());
201-
resp.map_err(|e| {
202-
ShippingError::Destination(e.status(), format!("Cannot reach {}", url))
203-
})
204-
} else {
205-
Err(ShippingError::Destination(None, "No client".to_string()))
206-
}
188+
let client = &self
189+
.client
190+
.as_ref()
191+
.ok_or_else(|| ShippingError::Destination(None, "No client".to_string()))?;
192+
let start = std::time::Instant::now();
193+
194+
let resp = client
195+
.post(&url)
196+
.header("DD-API-KEY", &self.api_key)
197+
.header("Content-Type", content_type)
198+
.body(body)
199+
.send()
200+
.await;
201+
202+
let elapsed = start.elapsed();
203+
debug!("Request to {} took {}ms", url, elapsed.as_millis());
204+
resp.map_err(|e| ShippingError::Destination(e.status(), format!("Cannot reach {url}")))
207205
}
208206
}
209207

0 commit comments

Comments
 (0)