Skip to content

Commit 5f59284

Browse files
committed
Merge impl blocks with same bounds
After removing `R` generic, some impl blocks began to have the same bounds
1 parent 52d5de0 commit 5f59284

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
@@ -2505,6 +2505,58 @@ impl<'de, 'e, EF> Deserializer<'de, 'e, EF>
25052505
where
25062506
EF: EntityResolverFactory<'de>,
25072507
{
2508+
/// Create a new deserializer that will borrow data from the specified string
2509+
/// and use the specified entity resolver.
2510+
pub fn from_str_with_resolver(source: &'de str, entity_resolver_factory: EF) -> Self {
2511+
Self::borrowing_with_resolver(NsReader::from_str(source), entity_resolver_factory)
2512+
}
2513+
2514+
/// Create a new deserializer that will borrow data from the specified preconfigured
2515+
/// reader and use the specified entity resolver.
2516+
///
2517+
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
2518+
///
2519+
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
2520+
pub fn borrowing_with_resolver(
2521+
mut reader: NsReader<&'de [u8]>,
2522+
entity_resolver_factory: EF,
2523+
) -> Self {
2524+
let config = reader.config_mut();
2525+
config.expand_empty_elements = true;
2526+
2527+
Self::new(XmlReader::borrowed_ns(reader, entity_resolver_factory))
2528+
}
2529+
2530+
/// Create a new deserializer that will copy data from the specified reader
2531+
/// into internal buffer and use the specified entity resolver.
2532+
///
2533+
/// If you already have a string use [`Self::from_str`] instead, because it
2534+
/// will borrow instead of copy. If you have `&[u8]` which is known to represent
2535+
/// UTF-8, you can decode it first before using [`from_str`].
2536+
pub fn with_resolver<R>(reader: R, entity_resolver_factory: EF) -> Self
2537+
where
2538+
R: BufRead + 'de,
2539+
{
2540+
let boxed: Box<dyn BufRead + 'de> = Box::new(reader);
2541+
Self::buffering_with_resolver(NsReader::from_reader(boxed), entity_resolver_factory)
2542+
}
2543+
2544+
/// Create new deserializer that will copy data from the specified preconfigured reader
2545+
/// into internal buffer and use the specified entity resolver.
2546+
///
2547+
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
2548+
///
2549+
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
2550+
pub fn buffering_with_resolver(
2551+
mut reader: NsReader<Box<dyn BufRead + 'de>>,
2552+
entity_resolver_factory: EF,
2553+
) -> Self {
2554+
let config = reader.config_mut();
2555+
config.expand_empty_elements = true;
2556+
2557+
Self::new(XmlReader::buffered_ns(reader, entity_resolver_factory))
2558+
}
2559+
25082560
/// Create an XML deserializer from one of the possible quick_xml input sources.
25092561
///
25102562
/// Typically it is more convenient to use one of these methods instead:
@@ -2998,36 +3050,7 @@ impl<'de, 'e> Deserializer<'de, 'e> {
29983050
pub fn borrowing(reader: NsReader<&'de [u8]>) -> Self {
29993051
Self::borrowing_with_resolver(reader, PredefinedEntityResolver)
30003052
}
3001-
}
3002-
3003-
impl<'de, 'e, EF> Deserializer<'de, 'e, EF>
3004-
where
3005-
EF: EntityResolverFactory<'de>,
3006-
{
3007-
/// Create a new deserializer that will borrow data from the specified string
3008-
/// and use the specified entity resolver.
3009-
pub fn from_str_with_resolver(source: &'de str, entity_resolver_factory: EF) -> Self {
3010-
Self::borrowing_with_resolver(NsReader::from_str(source), entity_resolver_factory)
3011-
}
30123053

3013-
/// Create a new deserializer that will borrow data from the specified preconfigured
3014-
/// reader and use the specified entity resolver.
3015-
///
3016-
/// Note, that config option [`Config::expand_empty_elements`] will be set to `true`.
3017-
///
3018-
/// [`Config::expand_empty_elements`]: crate::reader::Config::expand_empty_elements
3019-
pub fn borrowing_with_resolver(
3020-
mut reader: NsReader<&'de [u8]>,
3021-
entity_resolver_factory: EF,
3022-
) -> Self {
3023-
let config = reader.config_mut();
3024-
config.expand_empty_elements = true;
3025-
3026-
Self::new(XmlReader::borrowed_ns(reader, entity_resolver_factory))
3027-
}
3028-
}
3029-
3030-
impl<'de, 'e> Deserializer<'de, 'e> {
30313054
/// Create a new deserializer that will copy data from the specified reader
30323055
/// into internal buffer.
30333056
///
@@ -3087,41 +3110,6 @@ impl<'de, 'e> Deserializer<'de, 'e> {
30873110
}
30883111
}
30893112

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

0 commit comments

Comments
 (0)