Skip to content

Commit fc17a26

Browse files
Merge pull request #6 from dylni/dependabot/cargo/uniquote-3.0
2 parents 96af769 + e59b2b8 commit fc17a26

File tree

6 files changed

+45
-5
lines changed

6 files changed

+45
-5
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ name: build
33
on:
44
pull_request:
55
push:
6+
branches:
7+
- master
68
schedule:
79
- cron: 0 0 * * FRI
810

@@ -28,7 +30,7 @@ jobs:
2830
runs-on: ubuntu-latest
2931
env:
3032
RUSTFLAGS: -Dwarnings
31-
flags: --feature-powerset --optional-deps --exclude-features 'print_bytes uniquote' --target ${{ matrix.target }}
33+
flags: --feature-powerset --optional-deps --exclude-features 'print_bytes' --target ${{ matrix.target }}
3234
steps:
3335
- uses: actions/checkout@v1
3436
with:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ rustdoc-args = ["--cfg", "os_str_bytes_docs_rs"]
2121
[dependencies]
2222
memchr = { version = "2.4", optional = true }
2323
print_bytes = { version = "0.4", optional = true }
24-
uniquote = { version = "2.0", optional = true }
24+
uniquote = { version = "3.0", optional = true }
2525

2626
[dev-dependencies]
2727
getrandom = { version = "0.2", features = ["js"] }

src/common/raw.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ pub(crate) fn debug(string: &[u8], f: &mut Formatter<'_>) -> fmt::Result {
2525
}
2626
Ok(())
2727
}
28+
29+
#[cfg(feature = "uniquote")]
30+
pub(crate) mod uniquote {
31+
use uniquote::Formatter;
32+
use uniquote::Quote;
33+
use uniquote::Result;
34+
35+
pub(crate) fn escape(string: &[u8], f: &mut Formatter<'_>) -> Result {
36+
string.escape(f)
37+
}
38+
}

src/raw_str.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,13 +1117,15 @@ mod uniquote {
11171117
use uniquote::Quote;
11181118
use uniquote::Result;
11191119

1120+
use crate::imp::raw;
1121+
11201122
use super::RawOsStr;
11211123
use super::RawOsString;
11221124

11231125
impl Quote for RawOsStr {
11241126
#[inline]
11251127
fn escape(&self, f: &mut Formatter<'_>) -> Result {
1126-
self.0.escape(f)
1128+
raw::uniquote::escape(&self.0, f)
11271129
}
11281130
}
11291131

src/wasm32/raw.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,14 @@ pub(crate) fn debug(string: &[u8], _: &mut Formatter<'_>) -> fmt::Result {
2626
assert!(string.is_empty());
2727
Ok(())
2828
}
29+
30+
#[cfg(feature = "uniquote")]
31+
pub(crate) mod uniquote {
32+
use uniquote::Formatter;
33+
use uniquote::Quote;
34+
use uniquote::Result;
35+
36+
pub(crate) fn escape(string: &[u8], f: &mut Formatter<'_>) -> Result {
37+
string.escape(f)
38+
}
39+
}

src/windows/raw.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ pub(crate) use crate::util::is_continuation;
66
use super::wtf8;
77
use super::wtf8::CodePoints;
88

9+
fn encode_wide_unchecked(string: &[u8]) -> impl '_ + Iterator<Item = u16> {
10+
wtf8::encode_wide(string).map(|x| x.expect("invalid string"))
11+
}
12+
913
pub(crate) fn decode_code_point(string: &[u8]) -> u32 {
1014
let mut code_points = CodePoints::new(string.iter().copied());
1115
let code_point = code_points
@@ -25,8 +29,18 @@ pub(crate) fn starts_with(string: &[u8], prefix: &[u8]) -> bool {
2529
}
2630

2731
pub(crate) fn debug(string: &[u8], f: &mut Formatter<'_>) -> fmt::Result {
28-
for wchar in wtf8::encode_wide(string) {
29-
write!(f, "\\u{{{:X}}}", wchar.expect("invalid string"))?;
32+
for wchar in encode_wide_unchecked(string) {
33+
write!(f, "\\u{{{:X}}}", wchar)?;
3034
}
3135
Ok(())
3236
}
37+
38+
#[cfg(feature = "uniquote")]
39+
pub(crate) mod uniquote {
40+
use uniquote::Formatter;
41+
use uniquote::Result;
42+
43+
pub(crate) fn escape(string: &[u8], f: &mut Formatter<'_>) -> Result {
44+
f.escape_utf16(super::encode_wide_unchecked(string))
45+
}
46+
}

0 commit comments

Comments
 (0)