Skip to main content

NoWindow

Trait NoWindow 

Source
pub trait NoWindow {
    // Required method
    fn no_window(&mut self) -> &mut Self;
}
Expand description

Spawn a child without opening a console window for it.

Every crate that spawns a child on Windows needs the same three lines: #[cfg(windows)], use std::os::windows::process::CommandExt, cmd.creation_flags(CREATE_NO_WINDOW). Forgetting them is silent, and shows up only as a console flashing over the splash on a user’s desktop (#2171, #2173, #3788). This trait makes it one call that is a no-op off Windows, and works for both std::process::Command and tokio::process::Command.

creation_flags replaces the flags, it does not OR them, so a spawn that needs other flags too (CREATE_SUSPENDED | CREATE_NO_WINDOW) or a different one (CREATE_NEW_CONSOLE) still calls creation_flags itself.

Required Methods§

Source

fn no_window(&mut self) -> &mut Self

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl NoWindow for Command

Source§

fn no_window(&mut self) -> &mut Self

Source§

impl NoWindow for Command

Source§

fn no_window(&mut self) -> &mut Self

Implementors§