Coder Social home page Coder Social logo

Deserialize &'a str about serde_urlencoded HOT 6 CLOSED

nox avatar nox commented on July 28, 2024
Deserialize &'a str

from serde_urlencoded.

Comments (6)

nox avatar nox commented on July 28, 2024

Sure, those are Cow<'de, str> internally so I don't see why that doesn't currently work.

from serde_urlencoded.

allevo avatar allevo commented on July 28, 2024

Using Cow<'de, str>. Here the link to the playground.

https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&code=%23%5Bmacro_use%5D%0Aextern%20crate%20serde_derive%3B%0A%0Aextern%20crate%20serde%3B%0Aextern%20crate%20serde_urlencoded%3B%20%2F%2F%200.5.4%3B%0A%0A%23%5Bderive(Deserialize)%5D%0Astruct%20MyParams%3C%27a%3E%20%7B%0A%20%20%20%20key%3A%20%26%27a%20str%0A%7D%0A%0Afn%20main()%20-%3E%20Result%3C()%2C%20Box%3Cstd%3A%3Aerror%3A%3AError%3E%3E%20%7B%0A%20%20%20%20println!(%22%7B%3A%3F%7D%22%2C%20%22aaa%22)%3B%0A%20%20%20%20let%20r%3A%20MyParams%20%3D%20serde_urlencoded%3A%3Afrom_str(%22key%3Dbb%22).unwrap()%3B%0A%20%20%20%20println!(%22%7B%3A%3F%7D%22%2C%20r.key)%3B%0A%20%20%20%20Ok(())%0A%7D

Anyway the documentation doesn't say nothing nor tests.
I'll happy to send a PR a test for that case.

from serde_urlencoded.

nox avatar nox commented on July 28, 2024

Ok I now understand the problem:

https://github.com/serde-rs/serde/blob/11cc7014b3b2507a19465404599a1999e7c48cce/serde/src/de/value.rs#L612-L648

I misunderstood this impl, and didn't notice that the impl isn't for CowStrDeserializer<'de, E>.

from serde_urlencoded.

nox avatar nox commented on July 28, 2024

I'll release 0.5.5 as soon as #54 lands.

from serde_urlencoded.

nox avatar nox commented on July 28, 2024

Done! Thanks for the bug report.

from serde_urlencoded.

allevo avatar allevo commented on July 28, 2024

Awesome! Many thanks

from serde_urlencoded.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.