Skip to content

Commit

Permalink
change: TransportV2Ext::invoke(…,features,…) can take key-value pai…
Browse files Browse the repository at this point in the history
…rs more flexibly.

Value can now also be owned, which is useful if the value type is a
`Cow<'_, String>`.
  • Loading branch information
Byron committed Nov 9, 2022
1 parent f957d9a commit 28615b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions git-transport/src/client/blocking_io/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub trait TransportV2Ext {
fn invoke<'a>(
&mut self,
command: &str,
capabilities: impl Iterator<Item = (&'a str, Option<&'a str>)>,
capabilities: impl Iterator<Item = (&'a str, Option<impl AsRef<str>>)>,
arguments: Option<impl Iterator<Item = bstr::BString>>,
) -> Result<Box<dyn ExtendedBufRead + Unpin + '_>, Error>;
}
Expand All @@ -79,14 +79,14 @@ impl<T: Transport> TransportV2Ext for T {
fn invoke<'a>(
&mut self,
command: &str,
capabilities: impl Iterator<Item = (&'a str, Option<&'a str>)>,
capabilities: impl Iterator<Item = (&'a str, Option<impl AsRef<str>>)>,
arguments: Option<impl Iterator<Item = BString>>,
) -> Result<Box<dyn ExtendedBufRead + Unpin + '_>, Error> {
let mut writer = self.request(WriteMode::OneLfTerminatedLinePerWriteCall, MessageKind::Flush)?;
writer.write_all(format!("command={}", command).as_bytes())?;
for (name, value) in capabilities {
match value {
Some(value) => writer.write_all(format!("{}={}", name, value).as_bytes()),
Some(value) => writer.write_all(format!("{}={}", name, value.as_ref()).as_bytes()),
None => writer.write_all(name.as_bytes()),
}?;
}
Expand Down

0 comments on commit 28615b3

Please sign in to comment.