Skip to content

Commit d74fa1e

Browse files
committed
wmi: Fix string lifetime
Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent 7a287da commit d74fa1e

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

framework_lib/src/wmi.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ pub fn print_yellow_bangs() {
5151
// TODO: Unpack the Variant types
5252
// TODO: Use serde
5353
let description = if let Variant::String(s) = &bang["Description"] {
54-
s
54+
s.clone()
5555
} else {
56-
&"".to_string()
56+
"".to_string()
5757
};
5858
println!(" {}", description);
5959
println!(" Compatible IDs: {:?}", &bang["CompatibleID"]);
@@ -141,14 +141,14 @@ pub fn print_drivers() {
141141
.unwrap();
142142
for val in results.iter() {
143143
let device_name = if let Variant::String(s) = &val["DeviceName"] {
144-
s
144+
s.clone()
145145
} else {
146-
&"".to_string()
146+
"".to_string()
147147
};
148148
let version = if let Variant::String(s) = &val["DriverVersion"] {
149-
s
149+
s.clone()
150150
} else {
151-
&"".to_string()
151+
"".to_string()
152152
};
153153

154154
// Skip those that we don't care about
@@ -165,14 +165,14 @@ pub fn print_drivers() {
165165
.unwrap();
166166
for val in results.iter() {
167167
let name = if let Variant::String(s) = &val["Name"] {
168-
s
168+
s.clone()
169169
} else {
170-
&"".to_string()
170+
"".to_string()
171171
};
172172
let version = if let Variant::String(s) = &val["Version"] {
173-
s
173+
s.clone()
174174
} else {
175-
&"".to_string()
175+
"".to_string()
176176
};
177177

178178
// Skip those that we don't care about
@@ -264,19 +264,19 @@ pub fn print_drivers() {
264264
.unwrap();
265265
for val in results.iter() {
266266
let display_name = if let Variant::String(s) = &val["DisplayName"] {
267-
s
267+
s.clone()
268268
} else {
269-
&"".to_string()
269+
"".to_string()
270270
};
271271
let name = if let Variant::String(s) = &val["Name"] {
272-
s
272+
s.clone()
273273
} else {
274-
&"".to_string()
274+
"".to_string()
275275
};
276276
let path_name = if let Variant::String(s) = &val["PathName"] {
277-
s
277+
s.clone()
278278
} else {
279-
&"".to_string()
279+
"".to_string()
280280
};
281281

282282
// select * from CIM_Datafile" & _ " where Name = '" & Replace(strPath, "\", "\\") &
@@ -299,13 +299,13 @@ pub fn print_drivers() {
299299
};
300300

301301
// Skip those that we don't care about
302-
let str_name: &str = name;
302+
let str_name: &str = &name;
303303
//if let Ok(alias) = system_drivers.binary_search_by(|(k, _)| k.cmp(&str_name)).map(|x| system_drivers[x].1) {
304304
if let Some(alias) = system_drivers.get(&str_name) {
305305
let alias = if let Some(alias) = alias {
306306
*alias
307307
} else {
308-
display_name
308+
&display_name
309309
};
310310
println!(" {}", alias);
311311
debug!(" Display: {}", display_name);

0 commit comments

Comments
 (0)