Skip to content

Commit

Permalink
Remove x_ prefix from new trait methods
Browse files Browse the repository at this point in the history
  • Loading branch information
allenap committed Jul 7, 2024
1 parent 2b76555 commit 5be6c18
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/bash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ pub struct Bash;
// ----------------------------------------------------------------------------

impl QuoteInto<Vec<u8>> for Bash {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
Self::quote_into_vec(s, out);
}
}

impl QuoteInto<String> for Bash {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut String) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut String) {
Self::quote_into_vec(s, unsafe { out.as_mut_vec() })
}
}

#[cfg(unix)]
impl QuoteInto<std::ffi::OsString> for Bash {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
use std::os::unix::ffi::OsStringExt;
let s = Self::quote_vec(s);
let s = std::ffi::OsString::from_vec(s);
Expand All @@ -95,7 +95,7 @@ impl QuoteInto<std::ffi::OsString> for Bash {

#[cfg(feature = "bstr")]
impl QuoteInto<bstr::BString> for Bash {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
let s = Self::quote_vec(s);
out.extend(s);
}
Expand Down
8 changes: 4 additions & 4 deletions src/fish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ use crate::{ascii::Char, util::u8_to_hex_escape_uppercase_x, Quotable, QuoteInto
pub struct Fish;

impl QuoteInto<Vec<u8>> for Fish {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
Self::quote_into_vec(s, out);
}
}

impl QuoteInto<String> for Fish {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut String) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut String) {
Self::quote_into_vec(s, unsafe { out.as_mut_vec() })
}
}

#[cfg(unix)]
impl QuoteInto<std::ffi::OsString> for Fish {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
use std::os::unix::ffi::OsStringExt;
let s = Self::quote_vec(s);
let s = std::ffi::OsString::from_vec(s);
Expand All @@ -47,7 +47,7 @@ impl QuoteInto<std::ffi::OsString> for Fish {

#[cfg(feature = "bstr")]
impl QuoteInto<bstr::BString> for Fish {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
let s = Self::quote_vec(s);
out.extend(s);
}
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ pub type Zsh = bash::Bash;
/// Quoting/escaping a string of bytes into a shell-safe form.
pub trait QuoteInto<OUT: ?Sized> {
/// Quote/escape a string of bytes into an existing container.
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut OUT);
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut OUT);
}

/// Quoting/escaping a string of bytes into a shell-safe form.
pub trait Quote<OUT: Default>: QuoteInto<OUT> {
/// Quote/escape a string of bytes into a new container.
fn x_quote<'q, S: ?Sized + Into<Quotable<'q>>>(s: S) -> OUT {
fn quote<'q, S: ?Sized + Into<Quotable<'q>>>(s: S) -> OUT {
let mut out = OUT::default();
Self::x_quote_into(s, &mut out);
Self::quote_into(s, &mut out);
out
}
}
Expand All @@ -73,7 +73,7 @@ impl<T: ?Sized> QuoteExt for T {
Q: QuoteInto<Self>,
S: ?Sized + Into<Quotable<'q>>,
{
Q::x_quote_into(s, self);
Q::quote_into(s, self);
}
}

Expand All @@ -92,7 +92,7 @@ where
S: ?Sized + Into<Quotable<'a>>,
{
fn quoted<Q: Quote<OUT>>(self, _q: Q) -> OUT {
Q::x_quote(self)
Q::quote(self)
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/sh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ use crate::{ascii::Char, Quotable, QuoteInto};
pub struct Sh;

impl QuoteInto<Vec<u8>> for Sh {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut Vec<u8>) {
Self::quote_into_vec(s, out);
}
}

#[cfg(unix)]
impl QuoteInto<std::ffi::OsString> for Sh {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut std::ffi::OsString) {
use std::os::unix::ffi::OsStringExt;
let s = Self::quote_vec(s);
let s = std::ffi::OsString::from_vec(s);
Expand All @@ -98,7 +98,7 @@ impl QuoteInto<std::ffi::OsString> for Sh {

#[cfg(feature = "bstr")]
impl QuoteInto<bstr::BString> for Sh {
fn x_quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
fn quote_into<'q, S: ?Sized + Into<Quotable<'q>>>(s: S, out: &mut bstr::BString) {
let s = Self::quote_vec(s);
out.extend(s);
}
Expand Down

0 comments on commit 5be6c18

Please sign in to comment.