diff --git a/rust/chg/src/clientext.rs b/rust/chg/src/clientext.rs --- a/rust/chg/src/clientext.rs +++ b/rust/chg/src/clientext.rs @@ -32,29 +32,27 @@ E: AsRawFd; /// Changes the working directory of the server. - fn set_current_dir

(self, dir: P) -> OneShotRequest - where - P: AsRef; + fn set_current_dir(self, dir: impl AsRef) -> OneShotRequest; /// Updates the environment variables of the server. - fn set_env_vars_os(self, vars: I) -> OneShotRequest - where - I: IntoIterator, - P: AsRef; + fn set_env_vars_os( + self, + vars: impl IntoIterator, impl AsRef)>, + ) -> OneShotRequest; /// Changes the process title of the server. - fn set_process_name

(self, name: P) -> OneShotRequest - where - P: AsRef; + fn set_process_name(self, name: impl AsRef) -> OneShotRequest; /// Changes the umask of the server process. fn set_umask(self, mask: u32) -> OneShotRequest; /// Runs the specified Mercurial command with cHg extension. - fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand + fn run_command_chg( + self, + handler: H, + args: impl IntoIterator>, + ) -> ChgRunCommand where - I: IntoIterator, - P: AsRef, H: SystemHandler; /// Validates if the server can run Mercurial commands with the expected @@ -65,10 +63,10 @@ /// /// Client-side environment must be sent prior to this request, by /// `set_current_dir()` and `set_env_vars_os()`. - fn validate(self, args: I) -> OneShotQuery io::Result>> - where - I: IntoIterator, - P: AsRef; + fn validate( + self, + args: impl IntoIterator>, + ) -> OneShotQuery io::Result>>; } impl ChgClientExt for Client @@ -84,25 +82,18 @@ AttachIo::with_client(self, stdin, stdout, Some(stderr)) } - fn set_current_dir

(self, dir: P) -> OneShotRequest - where - P: AsRef, - { + fn set_current_dir(self, dir: impl AsRef) -> OneShotRequest { OneShotRequest::start_with_args(self, b"chdir", dir.as_ref().as_os_str().as_bytes()) } - fn set_env_vars_os(self, vars: I) -> OneShotRequest - where - I: IntoIterator, - P: AsRef, - { + fn set_env_vars_os( + self, + vars: impl IntoIterator, impl AsRef)>, + ) -> OneShotRequest { OneShotRequest::start_with_args(self, b"setenv", message::pack_env_vars_os(vars)) } - fn set_process_name

(self, name: P) -> OneShotRequest - where - P: AsRef, - { + fn set_process_name(self, name: impl AsRef) -> OneShotRequest { OneShotRequest::start_with_args(self, b"setprocname", name.as_ref().as_bytes()) } @@ -112,20 +103,21 @@ OneShotRequest::start_with_args(self, b"setumask2", args) } - fn run_command_chg(self, handler: H, args: I) -> ChgRunCommand + fn run_command_chg( + self, + handler: H, + args: impl IntoIterator>, + ) -> ChgRunCommand where - I: IntoIterator, - P: AsRef, H: SystemHandler, { ChgRunCommand::with_client(self, handler, message::pack_args_os(args)) } - fn validate(self, args: I) -> OneShotQuery io::Result>> - where - I: IntoIterator, - P: AsRef, - { + fn validate( + self, + args: impl IntoIterator>, + ) -> OneShotQuery io::Result>> { OneShotQuery::start_with_args( self, b"validate", diff --git a/rust/chg/src/locator.rs b/rust/chg/src/locator.rs --- a/rust/chg/src/locator.rs +++ b/rust/chg/src/locator.rs @@ -75,11 +75,7 @@ } /// Specifies the arguments to be passed to the server at start. - pub fn set_early_args(&mut self, args: I) - where - I: IntoIterator, - P: AsRef, - { + pub fn set_early_args(&mut self, args: impl IntoIterator>) { self.hg_early_args = args.into_iter().map(|a| a.as_ref().to_owned()).collect(); } @@ -358,10 +354,7 @@ /// Creates a directory which the other users cannot access to. /// /// If the directory already exists, tests its permission. -fn create_secure_dir

(path: P) -> io::Result<()> -where - P: AsRef, -{ +fn create_secure_dir(path: impl AsRef) -> io::Result<()> { DirBuilder::new() .mode(0o700) .create(path.as_ref()) @@ -404,11 +397,7 @@ } /// Collects arguments which need to be passed to the server at start. -pub fn collect_early_args(args: I) -> Vec -where - I: IntoIterator, - P: AsRef, -{ +pub fn collect_early_args(args: impl IntoIterator>) -> Vec { let mut args_iter = args.into_iter(); let mut early_args = Vec::new(); while let Some(arg) = args_iter.next() { diff --git a/rust/chg/src/message.rs b/rust/chg/src/message.rs --- a/rust/chg/src/message.rs +++ b/rust/chg/src/message.rs @@ -113,11 +113,9 @@ /// /// Panics if key or value contains `\0` character, or key contains '=' /// character. -pub fn pack_env_vars_os(vars: I) -> Bytes -where - I: IntoIterator, - P: AsRef, -{ +pub fn pack_env_vars_os( + vars: impl IntoIterator, impl AsRef)>, +) -> Bytes { let mut vars_iter = vars.into_iter(); if let Some((k, v)) = vars_iter.next() { let mut dst = BytesMut::with_capacity(INITIAL_PACKED_ENV_VARS_CAPACITY); @@ -143,17 +141,11 @@ dst.put_slice(v.as_bytes()); } -fn decode_latin1(s: S) -> String -where - S: AsRef<[u8]>, -{ +fn decode_latin1(s: impl AsRef<[u8]>) -> String { s.as_ref().iter().map(|&c| c as char).collect() } -fn new_parse_error(error: E) -> io::Error -where - E: Into>, -{ +fn new_parse_error(error: impl Into>) -> io::Error { io::Error::new(io::ErrorKind::InvalidData, error) }