Skip to content

Commit 3b10a1c

Browse files
committed
Merge impl blocks with same bounds
After removing `R` generic, some impl blocks began to have the same bounds
1 parent cb8d12a commit 3b10a1c

1 file changed

Lines changed: 52 additions & 64 deletions

File tree

src/de/mod.rs

Lines changed: 52 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2494,6 +2494,58 @@ impl<'de, 'e, EF> Deserializer<'de, 'e, EF>
24942494
where
24952495
EF: EntityResolverFactory<'de>,
24962496
{
2497+
/// Create a new deserializer that will borrow data from the specified string
2498+
/// and use the specified entity resolver.
2499+
pub fn from_str_with_resolver(source: &'de str, entity_resolver_factory: EF) -> Self {
2500+
Self::borrowing_with_resolver(NsReader::from_str(source), entity_resolver_factory)
2501+
}
2502+
2503+
/// Create a new deserializer that will borrow data from the specified preconfigured
2504+
/// reader and use the specified entity resolver.
2505+
///
2506+
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
2507+
///
2508+
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
2509+
pub fn borrowing_with_resolver(
2510+
mut reader: NsReader<&'de [u8]>,
2511+
entity_resolver_factory: EF,
2512+
) -> Self {
2513+
let config = reader.config_mut();
2514+
config.expand_empty_elements = true;
2515+
2516+
Self::new(XmlReader::borrowed_ns(reader, entity_resolver_factory))
2517+
}
2518+
2519+
/// Create a new deserializer that will copy data from the specified reader
2520+
/// into internal buffer and use the specified entity resolver.
2521+
///
2522+
/// If you already have a string use [`Self::from_str`] instead, because it
2523+
/// will borrow instead of copy. If you have `&[u8]` which is known to represent
2524+
/// UTF-8, you can decode it first before using [`from_str`].
2525+
pub fn with_resolver<R>(reader: R, entity_resolver_factory: EF) -> Self
2526+
where
2527+
R: BufRead + 'de,
2528+
{
2529+
let boxed: Box<dyn BufRead + 'de> = Box::new(reader);
2530+
Self::buffering_with_resolver(NsReader::from_reader(boxed), entity_resolver_factory)
2531+
}
2532+
2533+
/// Create new deserializer that will copy data from the specified preconfigured reader
2534+
/// into internal buffer and use the specified entity resolver.
2535+
///
2536+
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
2537+
///
2538+
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
2539+
pub fn buffering_with_resolver(
2540+
mut reader: NsReader<Box<dyn BufRead + 'de>>,
2541+
entity_resolver_factory: EF,
2542+
) -> Self {
2543+
let config = reader.config_mut();
2544+
config.expand_empty_elements = true;
2545+
2546+
Self::new(XmlReader::buffered_ns(reader, entity_resolver_factory))
2547+
}
2548+
24972549
/// Create an XML deserializer from one of the possible quick_xml input sources.
24982550
///
24992551
/// Typically it is more convenient to use one of these methods instead:
@@ -2987,36 +3039,7 @@ impl<'de, 'e> Deserializer<'de, 'e> {
29873039
pub fn borrowing(reader: NsReader<&'de [u8]>) -> Self {
29883040
Self::borrowing_with_resolver(reader, PredefinedEntityResolver)
29893041
}
2990-
}
2991-
2992-
impl<'de, 'e, EF> Deserializer<'de, 'e, EF>
2993-
where
2994-
EF: EntityResolverFactory<'de>,
2995-
{
2996-
/// Create a new deserializer that will borrow data from the specified string
2997-
/// and use the specified entity resolver.
2998-
pub fn from_str_with_resolver(source: &'de str, entity_resolver_factory: EF) -> Self {
2999-
Self::borrowing_with_resolver(NsReader::from_str(source), entity_resolver_factory)
3000-
}
30013042

3002-
/// Create a new deserializer that will borrow data from the specified preconfigured
3003-
/// reader and use the specified entity resolver.
3004-
///
3005-
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
3006-
///
3007-
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
3008-
pub fn borrowing_with_resolver(
3009-
mut reader: NsReader<&'de [u8]>,
3010-
entity_resolver_factory: EF,
3011-
) -> Self {
3012-
let config = reader.config_mut();
3013-
config.expand_empty_elements = true;
3014-
3015-
Self::new(XmlReader::borrowed_ns(reader, entity_resolver_factory))
3016-
}
3017-
}
3018-
3019-
impl<'de, 'e> Deserializer<'de, 'e> {
30203043
/// Create a new deserializer that will copy data from the specified reader
30213044
/// into internal buffer.
30223045
///
@@ -3076,41 +3099,6 @@ impl<'de, 'e> Deserializer<'de, 'e> {
30763099
}
30773100
}
30783101

3079-
impl<'de, 'e, EF> Deserializer<'de, 'e, EF>
3080-
where
3081-
EF: EntityResolverFactory<'de>,
3082-
{
3083-
/// Create a new deserializer that will copy data from the specified reader
3084-
/// into internal buffer and use the specified entity resolver.
3085-
///
3086-
/// If you already have a string use [`Self::from_str`] instead, because it
3087-
/// will borrow instead of copy. If you have `&[u8]` which is known to represent
3088-
/// UTF-8, you can decode it first before using [`from_str`].
3089-
pub fn with_resolver<R>(reader: R, entity_resolver_factory: EF) -> Self
3090-
where
3091-
R: BufRead + 'de,
3092-
{
3093-
let boxed: Box<dyn BufRead + 'de> = Box::new(reader);
3094-
Self::buffering_with_resolver(NsReader::from_reader(boxed), entity_resolver_factory)
3095-
}
3096-
3097-
/// Create new deserializer that will copy data from the specified preconfigured reader
3098-
/// into internal buffer and use the specified entity resolver.
3099-
///
3100-
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
3101-
///
3102-
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
3103-
pub fn buffering_with_resolver(
3104-
mut reader: NsReader<Box<dyn BufRead + 'de>>,
3105-
entity_resolver_factory: EF,
3106-
) -> Self {
3107-
let config = reader.config_mut();
3108-
config.expand_empty_elements = true;
3109-
3110-
Self::new(XmlReader::buffered_ns(reader, entity_resolver_factory))
3111-
}
3112-
}
3113-
31143102
impl<'de, 'e, EF> de::Deserializer<'de> for &mut Deserializer<'de, 'e, EF>
31153103
where
31163104
EF: EntityResolverFactory<'de>,

0 commit comments

Comments
 (0)