Skip to content

Comments

Fix using incorrect deserializer when deserialize Option values in maps and structs#548

Merged
dralley merged 3 commits intotafia:masterfrom
Mingun:fix-510
Feb 6, 2023
Merged

Fix using incorrect deserializer when deserialize Option values in maps and structs#548
dralley merged 3 commits intotafia:masterfrom
Mingun:fix-510

Conversation

@Mingun
Copy link
Collaborator

@Mingun Mingun commented Jan 28, 2023

Fixes #510. The reason for the error is that an incorrect deserializer was used after forwarding. The fix changes all methods that can forward actual deserialization to another deserializer, like that:

    fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, DeError>
    where
        V: Visitor<'de>,
    {
        match self.peek()? {
            DeEvent::Text(t) if t.is_empty() => visitor.visit_none(),
            DeEvent::CData(t) if t.is_empty() => visitor.visit_none(),
            DeEvent::Eof => visitor.visit_none(),
            _ => visitor.visit_some(self), // <<< Forwarding deserialization to another deserializer
        }
    }

failures (1):
    issue510
@Mingun Mingun added the serde Issues related to mapping from Rust types to XML label Jan 28, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 28, 2023

Codecov Report

Merging #548 (06d7207) into master (add7406) will increase coverage by 0.07%.
The diff coverage is 95.91%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #548      +/-   ##
==========================================
+ Coverage   61.28%   61.35%   +0.07%     
==========================================
  Files          32       32              
  Lines       15639    15605      -34     
==========================================
- Hits         9584     9575       -9     
+ Misses       6055     6030      -25     
Flag Coverage Δ
unittests 61.35% <95.91%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/de/map.rs 80.58% <50.00%> (+7.77%) ⬆️
src/de/mod.rs 56.20% <100.00%> (-0.66%) ⬇️
src/reader/mod.rs 94.94% <0.00%> (-0.11%) ⬇️
src/events/attributes.rs 93.56% <0.00%> (+0.06%) ⬆️
src/escapei.rs 12.58% <0.00%> (+0.17%) ⬆️
src/lib.rs 13.52% <0.00%> (+0.23%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Mingun Mingun requested a review from dralley January 28, 2023 18:13
@Mingun Mingun mentioned this pull request Jan 30, 2023
13 tasks
@dralley dralley merged commit 221b57d into tafia:master Feb 6, 2023
@Mingun Mingun deleted the fix-510 branch February 6, 2023 05:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

serde Issues related to mapping from Rust types to XML

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Question]: Deserialize optional vector

3 participants