Skip to content

Commit 1ad0a72

Browse files
committed
Remove im_str macro, fix warnings and Clippy lints
1 parent 903e837 commit 1ad0a72

10 files changed

Lines changed: 205 additions & 226 deletions

File tree

crates/spaceman-dmm/build.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::process::Command;
1010
fn main() {
1111
// build info
1212
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
13-
let mut f = File::create(&out_dir.join("build-info.txt")).unwrap();
13+
let mut f = File::create(out_dir.join("build-info.txt")).unwrap();
1414

1515
if let Ok(commit) = read_commit() {
1616
writeln!(f, "commit: {}", commit).unwrap();
@@ -19,28 +19,28 @@ fn main() {
1919

2020
// windres icon
2121
if cfg!(windows) {
22-
let out_dir = env::var("OUT_DIR").ok().expect("can't find out_dir");
22+
let out_dir = env::var("OUT_DIR").expect("can't find out_dir");
2323

2424
if cfg!(target_env = "msvc") {
2525
if let Err(e) = Command::new("windres")
26-
.args(&["res/editor.rc", "-o"])
27-
.arg(&format!("{}/editor_rc.lib", out_dir))
26+
.args(["res/editor.rc", "-o"])
27+
.arg(format!("{}/editor_rc.lib", out_dir))
2828
.status()
2929
{
3030
println!("cargo:warning=`windres` unavailable: {}", e);
3131
return;
3232
}
3333
} else {
3434
if let Err(e) = Command::new("windres")
35-
.args(&["res/editor.rc", "-o"])
36-
.arg(&format!("{}/editor.rc.o", out_dir))
35+
.args(["res/editor.rc", "-o"])
36+
.arg(format!("{}/editor.rc.o", out_dir))
3737
.status()
3838
{
3939
println!("cargo:warning=`windres` unavailable: {}", e);
4040
return;
4141
}
4242
Command::new("ar")
43-
.args(&["crus", "libeditor_rc.a", "editor.rc.o"])
43+
.args(["crus", "libeditor_rc.a", "editor.rc.o"])
4444
.current_dir(Path::new(&out_dir))
4545
.status()
4646
.unwrap();

crates/spaceman-dmm/src/dmi.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl IconCache {
8585
}
8686

8787
impl TextureCache {
88-
pub fn retrieve(&mut self, device: &Device, icons: &IconCache, id: usize) -> &Texture {
88+
pub fn retrieve(&mut self, device: &Device, icons: &IconCache, id: usize) -> &Texture<'_> {
8989
if id >= self.textures.len() {
9090
self.textures.resize_with(id + 1, Default::default);
9191
}
@@ -146,7 +146,7 @@ impl IconFile {
146146
}
147147
}
148148

149-
pub fn texture_from_bytes<'r>(device: &Device, bytes: &[u8]) -> io::Result<Texture<'r>> {
149+
pub fn texture_from_bytes(device: &Device, bytes: &[u8]) -> io::Result<Texture<'static>> {
150150
let mut decoder = Decoder::new();
151151
decoder.info_raw_mut().colortype = ColorType::RGBA;
152152
decoder.info_raw_mut().set_bitdepth(8);
@@ -159,7 +159,7 @@ pub fn texture_from_bytes<'r>(device: &Device, bytes: &[u8]) -> io::Result<Textu
159159
Ok(load_texture(device, &bitmap))
160160
}
161161

162-
pub fn load_texture<'r>(device: &Device, bitmap: &lodepng::Bitmap<RGBA>) -> Texture<'static> {
162+
pub fn load_texture(device: &Device, bitmap: &lodepng::Bitmap<RGBA>) -> Texture<'static> {
163163
let width = bitmap.width as u32;
164164
let height = bitmap.height as u32;
165165

@@ -186,7 +186,8 @@ pub fn load_texture<'r>(device: &Device, bitmap: &lodepng::Bitmap<RGBA>) -> Text
186186
let mut mem = transfer_buffer.map::<u8>(device, true);
187187
let mut dest = mem.mem_mut();
188188
for pixel in &bitmap.buffer {
189-
dest.write_all(&[pixel.a, pixel.b, pixel.g, pixel.r]);
189+
dest.write_all(&[pixel.a, pixel.b, pixel.g, pixel.r])
190+
.unwrap();
190191
}
191192
mem.unmap();
192193

crates/spaceman-dmm/src/edit_prefab.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl EditPrefab {
6767

6868
// show the instance variables - everything which is
6969
// actually set is right at the top
70-
ui.text(im_str!("Instance variables ({})", fab.vars.len()));
70+
ui.text(format!("Instance variables ({})", fab.vars.len()));
7171
let mut remove = std::collections::HashSet::new();
7272
for (name, value) in fab.vars.iter() {
7373
if !name.contains(filter.as_str()) {
@@ -76,18 +76,18 @@ impl EditPrefab {
7676
// TODO: red instead of green if invalid var
7777
{
7878
let style = ui.push_style_color(StyleColor::Text, GREEN);
79-
ui.text(&im_str!(" {}", name));
79+
ui.text(format!(" {}", name));
8080
style.pop();
8181
}
8282
ui.same_line_with_spacing(offset, 0.);
83-
if ui.small_button(&im_str!("X##editprefab_remove_{}", name)) {
83+
if ui.small_button(format!("X##editprefab_remove_{}", name)) {
8484
remove.insert(name.to_owned());
8585
}
8686
if ui.is_item_hovered() {
8787
ui.tooltip_text("Reset");
8888
}
8989
ui.same_line();
90-
ui.text(im_str!("{}", value));
90+
ui.text(format!("{}", value));
9191
}
9292
for key in remove {
9393
fab.vars.shift_remove(&key);
@@ -107,7 +107,7 @@ impl EditPrefab {
107107
let mut search_ty = ty;
108108
while let Some(search) = search_ty {
109109
ui.separator();
110-
ui.text(im_str!("{}", &search.path));
110+
ui.text(&search.path);
111111

112112
for (name, var) in search.vars.iter() {
113113
if !name.contains(filter.as_str()) {
@@ -126,10 +126,10 @@ impl EditPrefab {
126126

127127
if instance_value.is_some() {
128128
let style = ui.push_style_color(StyleColor::Text, GREEN);
129-
ui.text(im_str!("{} {}", prefix, name));
129+
ui.text(format!("{} {}", prefix, name));
130130
style.pop();
131131
} else {
132-
ui.text(im_str!("{} {}", prefix, name));
132+
ui.text(format!("{} {}", prefix, name));
133133
}
134134

135135
if prefix == "-" && ui.is_item_hovered() {
@@ -144,16 +144,16 @@ impl EditPrefab {
144144
if let Some(c) = instance_value {
145145
ui.same_line_with_spacing(offset, 0.);
146146
let style = ui.push_style_color(StyleColor::Text, GREEN);
147-
ui.text(im_str!(" {} ", c));
147+
ui.text(format!(" {} ", c));
148148
style.pop();
149149
if ui.is_item_hovered() {
150150
if let Some(c) = original_value {
151-
ui.tooltip_text(im_str!("Was: {}", c));
151+
ui.tooltip_text(format!("Was: {}", c));
152152
}
153153
}
154154
} else if let Some(c) = original_value {
155155
ui.same_line_with_spacing(offset, 0.);
156-
ui.text(im_str!(" {} ", c));
156+
ui.text(format!(" {} ", c));
157157
if ui.is_item_hovered() {
158158
ui.set_mouse_cursor(Some(MouseCursor::TextInput));
159159
ui.tooltip_text("Click to edit");

0 commit comments

Comments
 (0)