Skip to content

Commit 5bb3ab3

Browse files
authored
Merge pull request #210 from frankier/escape-public
Make escape module public apart from EscapeError
2 parents fc62309 + 8d40188 commit 5bb3ab3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/escape.rs renamed to src/escapei.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,8 @@ const MAX_ONE_B: u32 = 0x80;
6363
const MAX_TWO_B: u32 = 0x800;
6464
const MAX_THREE_B: u32 = 0x10000;
6565

66-
/// helper function to escape a `&[u8]` and replace all
67-
/// xml special characters (<, >, &, ', ") with their corresponding
68-
/// xml escaped value.
66+
/// Escapes a `&[u8]` and replaces all xml special characters (<, >, &, ', ") with their
67+
/// corresponding xml escaped value.
6968
pub fn escape(raw: &[u8]) -> Cow<[u8]> {
7069
fn to_escape(b: u8) -> bool {
7170
match b {
@@ -105,8 +104,8 @@ pub fn escape(raw: &[u8]) -> Cow<[u8]> {
105104
}
106105
}
107106

108-
/// helper function to unescape a `&[u8]` and replace all
109-
/// xml escaped characters ('&...;') into their corresponding value
107+
/// Unescape a `&[u8]` and replaces all xml escaped characters ('&...;') into their corresponding
108+
/// value
110109
pub fn unescape(raw: &[u8]) -> Result<Cow<[u8]>, EscapeError> {
111110
let mut unescaped = None;
112111
let mut last_end = 0;

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ extern crate serde;
120120
#[cfg(feature = "serialize")]
121121
pub mod de;
122122
mod errors;
123-
mod escape;
123+
mod escapei;
124+
pub mod escape {
125+
//! Manage xml character escapes
126+
pub(crate) use escapei::EscapeError;
127+
pub use escapei::{escape, unescape};
128+
}
124129
pub mod events;
125130
mod reader;
126131
#[cfg(feature = "serialize")]

0 commit comments

Comments
 (0)