mirror of
https://github.com/openharmony/third_party_rust_os_str_bytes.git
synced 2026-07-20 01:23:35 -04:00
Use new features of "print_bytes"
This commit is contained in:
@@ -30,7 +30,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
RUSTFLAGS: -Dwarnings
|
||||
flags: --feature-powerset --optional-deps --exclude-features 'print_bytes' --target ${{ matrix.target }}
|
||||
flags: --feature-powerset --optional-deps --target ${{ matrix.target }}
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
with:
|
||||
|
||||
+20
-3
@@ -1089,24 +1089,41 @@ r#impl!(RawOsString, String);
|
||||
#[cfg(feature = "print_bytes")]
|
||||
#[cfg_attr(os_str_bytes_docs_rs, doc(cfg(feature = "print_bytes")))]
|
||||
mod print_bytes {
|
||||
use print_bytes::Bytes;
|
||||
use print_bytes::ByteStr;
|
||||
use print_bytes::ToBytes;
|
||||
#[cfg(any(windows))]
|
||||
use print_bytes::WideStr;
|
||||
|
||||
#[cfg(windows)]
|
||||
use crate::imp::raw;
|
||||
|
||||
use super::RawOsStr;
|
||||
use super::RawOsString;
|
||||
|
||||
impl ToBytes for RawOsStr {
|
||||
#[inline]
|
||||
fn to_bytes(&self) -> Bytes<'_> {
|
||||
fn to_bytes(&self) -> ByteStr<'_> {
|
||||
self.0.to_bytes()
|
||||
}
|
||||
|
||||
#[cfg(any(windows))]
|
||||
#[inline]
|
||||
fn to_wide(&self) -> Option<WideStr> {
|
||||
Some(WideStr::new(raw::encode_wide_unchecked(&self.0).collect()))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToBytes for RawOsString {
|
||||
#[inline]
|
||||
fn to_bytes(&self) -> Bytes<'_> {
|
||||
fn to_bytes(&self) -> ByteStr<'_> {
|
||||
(**self).to_bytes()
|
||||
}
|
||||
|
||||
#[cfg(any(windows))]
|
||||
#[inline]
|
||||
fn to_wide(&self) -> Option<WideStr> {
|
||||
(**self).to_wide()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -6,7 +6,9 @@ pub(crate) use crate::util::is_continuation;
|
||||
use super::wtf8;
|
||||
use super::wtf8::CodePoints;
|
||||
|
||||
fn encode_wide_unchecked(string: &[u8]) -> impl '_ + Iterator<Item = u16> {
|
||||
pub(crate) fn encode_wide_unchecked(
|
||||
string: &[u8],
|
||||
) -> impl '_ + Iterator<Item = u16> {
|
||||
wtf8::encode_wide(string).map(|x| x.expect("invalid string"))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user