Skip to content

Commit d0ba722

Browse files
dns2utf8dbrgn
authored andcommitted
Replace many .to_string() calls with .into()
1 parent f6fae19 commit d0ba722

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
- Danilo Bargen (@dbrgn)
44
- Raphael Nestler (@rnestler)
5+
- Stefan Schindler (@dns2tuf8)

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
[package]
22
name = "spaceapi-server"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
documentation = "https://coredump-ch.github.io/rust-docs/spaceapi-server/spaceapi_server/index.html"
55
repository = "https://github.com/coredump-ch/spaceapi-server-rs"
66
license = "MIT OR Apache-2.0"
77
authors = [
88
"Raphael Nestler <[email protected]>",
99
"Danilo Bargen <[email protected]>",
10+
"Stefan Schindler <[email protected]>",
1011
]
1112
description = "A library that allows you to easily implement a Space API server."
1213
readme = "README.md"

src/server/handlers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ impl ToJson for ErrorResponse {
2626
/// Serialize an ErrorResponse object into a proper JSON structure.
2727
fn to_json(&self) -> Json {
2828
let mut d = BTreeMap::new();
29-
d.insert("status".to_string(), "error".to_json());
30-
d.insert("reason".to_string(), self.reason.to_json());
29+
d.insert("status".into(), "error".to_json());
30+
d.insert("reason".into(), self.reason.to_json());
3131
Json::Object(d)
3232
}
3333
}
@@ -140,7 +140,7 @@ impl UpdateHandler {
140140
let sensor_specs = self.sensor_specs.lock().unwrap();
141141
let sensor_spec = try!(sensor_specs.iter()
142142
.find(|&spec| spec.data_key == sensor)
143-
.ok_or(sensors::SensorError::UnknownSensor(sensor.to_string())));
143+
.ok_or(sensors::SensorError::UnknownSensor(sensor.into())));
144144

145145
// Store data
146146
sensor_spec.set_sensor_value(&self.redis_connection_info, value)
@@ -157,7 +157,7 @@ impl UpdateHandler {
157157

158158
/// Build an error response with the specified `error_code` and the specified `reason` text.
159159
fn err_response(&self, error_code: status::Status, reason: &str) -> Response {
160-
let error = ErrorResponse { reason: reason.to_string() };
160+
let error = ErrorResponse { reason: reason.into() };
161161
Response::with((error_code, error.to_json().to_string()))
162162
// Set headers
163163
.set(Header(headers::ContentType("application/json; charset=utf-8".parse().unwrap())))

0 commit comments

Comments
 (0)