Skip to content

Commit

Permalink
Merge pull request #10 from dtolnay/render
Browse files Browse the repository at this point in the history
Convert all flag rendering to OsString
  • Loading branch information
dtolnay committed Apr 17, 2024
2 parents e885f0f + d00b5b2 commit a4db501
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ impl IntoIterator for Flag {
rename,
} => {
flags.push(OsString::from("-l"));
let mut flag = String::new();
let mut flag = OsString::new();
if kind != LinkKind::default() || !modifiers.is_empty() {
write!(flag, "{}", kind);
}
for (i, (prefix, modifier)) in modifiers.iter().enumerate() {
flag.push(if i == 0 { ':' } else { ',' });
flag.push(if i == 0 { ":" } else { "," });
write!(flag, "{}{}", prefix, modifier);
}
if !flag.is_empty() {
flag.push('=');
flag.push("=");
}
flag.push_str(&name);
flag.push(name);
if let Some(rename) = rename {
flag.push(':');
flag.push_str(&rename);
flag.push(":");
flag.push(rename);
}
flags.push(OsString::from(flag));
flags.push(flag);
}

Flag::CrateType(crate_type) => {
Expand Down
6 changes: 0 additions & 6 deletions src/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ pub(crate) trait WriteFmt {
fn write_fmt(&mut self, args: fmt::Arguments);
}

impl WriteFmt for String {
fn write_fmt(&mut self, args: fmt::Arguments) {
fmt::Write::write_fmt(self, args).unwrap();
}
}

impl WriteFmt for OsString {
fn write_fmt(&mut self, args: fmt::Arguments) {
fmt::Write::write_fmt(self, args).unwrap();
Expand Down

0 comments on commit a4db501

Please sign in to comment.