Skip to content
This repository was archived by the owner on Dec 6, 2024. It is now read-only.

Commit b6ded1d

Browse files
committed
Pass base_url by reference to namerd::resolve (#37)
Clippy notes that namerd::resolve does not need to take ownership of `base_url`: $ cargo clippy ... warning: this argument is passed by value, but not consumed in the function body --> src/namerd.rs:45:29 | 45 | pub fn resolve<C>(base_url: String, | ^^^^^^ | = note: #[warn(needless_pass_by_value)] on by default help: consider changing the type to `&str` | pub fn resolve<C>(base_url: &str, = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#needless_pass_by_valu This doesn't have any serious impact, but it is noisy when linting. To fix this, we pass a `&str` instead of a `String`.
1 parent d61091f commit b6ded1d

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/app/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Loader for Namerd {
188188
interval_secs);
189189
let addrs = {
190190
let client = Client::new(&handle);
191-
namerd::resolve(url, client, interval, &ns, &path, self.metrics)
191+
namerd::resolve(&url, client, interval, &ns, &path, self.metrics)
192192
};
193193
let driver = {
194194
let sink = self.sender.sink_map_err(|_| error!("sink error"));

src/namerd.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Stats {
4242
/// to a set of addresses.
4343
///
4444
/// The returned stream never completes.
45-
pub fn resolve<C>(base_url: String,
45+
pub fn resolve<C>(base_url: &str,
4646
client: Client<C>,
4747
period: time::Duration,
4848
namespace: &str,
@@ -53,8 +53,7 @@ pub fn resolve<C>(base_url: String,
5353
{
5454
let url = {
5555
let base = format!("{}/api/1/resolve/{}", base_url, namespace);
56-
Url::parse_with_params(&base, &[("path", &target)])
57-
.expect("invalid namerd url")
56+
Url::parse_with_params(&base, &[("path", &target)]).expect("invalid namerd url")
5857
};
5958
let stats = Stats::new(metrics);
6059
let client = Rc::new(client);

0 commit comments

Comments
 (0)