Skip to content

Commit 05a22a7

Browse files
committed
Fix nits
Add comments explaining how we test this, and use a slice for debugging instead of a clone of the iterator.
1 parent 5438465 commit 05a22a7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/libstd/sys/windows/args.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,20 @@ pub fn args() -> Args {
3535
}
3636
}
3737

38-
/// Implements the Windows command-line argument parsing algorithm, described at
38+
/// Implements the Windows command-line argument parsing algorithm.
39+
///
40+
/// Microsoft's documentation for the Windows CLI argument format can be found at
3941
/// <https://docs.microsoft.com/en-us/previous-versions//17w5ykft(v=vs.85)>.
4042
///
4143
/// Windows includes a function to do this in shell32.dll,
4244
/// but linking with that DLL causes the process to be registered as a GUI application.
4345
/// GUI applications add a bunch of overhead, even if no windows are drawn. See
4446
/// <https://randomascii.wordpress.com/2018/12/03/a-not-called-function-can-cause-a-5x-slowdown/>.
47+
///
48+
/// This function was tested for equivalence to the shell32.dll implementation in
49+
/// Windows 10 Pro v1803, using an exhaustive test suite available at
50+
/// <https://gist.github.com/notriddle/dde431930c392e428055b2dc22e638f5> or
51+
/// <https://paste.gg/p/anonymous/47d6ed5f5bd549168b1c69c799825223>.
4552
unsafe fn parse_lp_cmd_line<F: Fn() -> OsString>(lp_cmd_line: *const u16, exe_name: F)
4653
-> vec::IntoIter<OsString> {
4754
const BACKSLASH: u16 = '\\' as u16;
@@ -176,13 +183,13 @@ impl<'a> fmt::Debug for ArgsInnerDebug<'a> {
176183
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
177184
f.write_str("[")?;
178185
let mut first = true;
179-
for i in self.args.parsed_args_list.clone() {
186+
for i in self.args.parsed_args_list.as_slice() {
180187
if !first {
181188
f.write_str(", ")?;
182189
}
183190
first = false;
184191

185-
fmt::Debug::fmt(&i, f)?;
192+
fmt::Debug::fmt(i, f)?;
186193
}
187194
f.write_str("]")?;
188195
Ok(())

0 commit comments

Comments
 (0)