Skip to content

Commit b8fab52

Browse files
committed
Improved function names
`from_str_using_string_unescape_buffer` => `from_str_escaped` `from_slice_using_string_unescape_buffer` => `from_slice_escaped`
1 parent 35765f4 commit b8fab52

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/de/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ impl fmt::Display for Error {
833833

834834
/// Deserializes an instance of type `T` from bytes of JSON text, using the provided buffer to unescape strings
835835
/// Returns the value and the number of bytes consumed in the process
836-
pub fn from_slice_using_string_unescape_buffer<'a, T>(
836+
pub fn from_slice_escaped<'a, T>(
837837
v: &'a [u8],
838838
string_unescape_buffer: &mut [u8],
839839
) -> Result<(T, usize)>
@@ -853,7 +853,7 @@ pub fn from_slice<'a, T>(v: &'a [u8]) -> Result<(T, usize)>
853853
where
854854
T: de::Deserialize<'a>,
855855
{
856-
from_slice_using_string_unescape_buffer(v, &mut []).map_err(|error| {
856+
from_slice_escaped(v, &mut []).map_err(|error| {
857857
if let Error::EscapedStringIsTooLong = error {
858858
Error::EscapedStringRequiresBuffer
859859
} else {
@@ -863,14 +863,11 @@ where
863863
}
864864

865865
/// Deserializes an instance of type T from a string of JSON text, using the provided buffer to unescape strings
866-
pub fn from_str_using_string_unescape_buffer<'a, T>(
867-
s: &'a str,
868-
string_unescape_buffer: &mut [u8],
869-
) -> Result<(T, usize)>
866+
pub fn from_str_escaped<'a, T>(s: &'a str, string_unescape_buffer: &mut [u8]) -> Result<(T, usize)>
870867
where
871868
T: de::Deserialize<'a>,
872869
{
873-
from_slice_using_string_unescape_buffer(s.as_bytes(), string_unescape_buffer)
870+
from_slice_escaped(s.as_bytes(), string_unescape_buffer)
874871
}
875872

876873
/// Deserializes an instance of type T from a string of JSON text
@@ -949,7 +946,7 @@ mod tests {
949946
fn from_str_test<'de, T: serde::Deserialize<'de>>(
950947
s: &'de str,
951948
) -> super::Result<(T, usize)> {
952-
crate::from_str_using_string_unescape_buffer(s, &mut [0; 8])
949+
crate::from_str_escaped(s, &mut [0; 8])
953950
}
954951

955952
assert_eq!(from_str_test(r#""n""#), Ok(('n', 3)));
@@ -981,7 +978,7 @@ mod tests {
981978
fn from_str_test<'de, T: serde::Deserialize<'de>>(
982979
s: &'de str,
983980
) -> super::Result<(T, usize)> {
984-
crate::from_str_using_string_unescape_buffer(s, &mut [0; 16])
981+
crate::from_str_escaped(s, &mut [0; 16])
985982
}
986983

987984
// escaped " in the string content
@@ -1027,7 +1024,7 @@ mod tests {
10271024
fn from_str_test<'de, T: serde::Deserialize<'de>>(
10281025
s: &'de str,
10291026
) -> super::Result<(T, usize)> {
1030-
crate::from_str_using_string_unescape_buffer(s, &mut [0; 16])
1027+
crate::from_str_escaped(s, &mut [0; 16])
10311028
}
10321029

10331030
// The combined length of the first and third strings are longer than the buffer, but that's OK,

src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ pub mod de;
6565
pub mod ser;
6666

6767
#[doc(inline)]
68-
pub use self::de::{
69-
from_slice, from_slice_using_string_unescape_buffer, from_str,
70-
from_str_using_string_unescape_buffer,
71-
};
68+
pub use self::de::{from_slice, from_slice_escaped, from_str, from_str_escaped};
7269
#[doc(inline)]
7370
pub use self::ser::to_slice;
7471
#[cfg(feature = "heapless")]

0 commit comments

Comments
 (0)