From 9d358df88e30ee865b8de7cd5f189d2e6452d27f Mon Sep 17 00:00:00 2001 From: Nikolai Vazquez Date: Mon, 18 Oct 2021 21:42:23 -0400 Subject: [PATCH] Default endianness to native Most UTF-16 implementations use the native endian. This is a breaking change. --- src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 212fa58..312538b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -79,7 +79,7 @@ use std::slice::ChunksExact; use byteorder::ByteOrder; -pub use byteorder::{BigEndian, LittleEndian, BE, LE}; +pub use byteorder::{BigEndian, LittleEndian, NativeEndian, BE, LE}; mod error; mod iters; @@ -130,7 +130,7 @@ pub struct Utf16Error { /// assert_eq!(s0, s1); /// ``` #[derive(Debug, Eq, PartialEq, Hash)] -pub struct WString { +pub struct WString { buf: Vec, _endian: PhantomData<&'static E>, } @@ -160,7 +160,7 @@ pub struct WString { #[derive(Debug, Eq, PartialEq, Hash)] #[repr(transparent)] -pub struct WStr { +pub struct WStr { _endian: PhantomData<&'static E>, raw: [u8], } @@ -170,7 +170,7 @@ pub struct WStr { /// The slice must contain valid UTF-16, otherwise this may panic or cause undefined /// behaviour. #[derive(Debug)] -pub struct WStrChars<'a, E: 'static + ByteOrder> { +pub struct WStrChars<'a, E: 'static + ByteOrder = NativeEndian> { chunks: ChunksExact<'a, u8>, _endian: PhantomData<&'static E>, } @@ -180,7 +180,7 @@ pub struct WStrChars<'a, E: 'static + ByteOrder> { /// The slice must contain valid UTF-16, otherwise this may panic or cause undefined /// behaviour. #[derive(Debug)] -pub struct WStrCharIndices<'a, E: 'static + ByteOrder> { +pub struct WStrCharIndices<'a, E: 'static + ByteOrder = NativeEndian> { chars: WStrChars<'a, E>, index: usize, }