Comments (1)
The problem is with the f64
not the DurationSeconds
. There is no DeserializeAs
implementation for f64
that matches here. That is why you get the error. For the f64
you want to use the default Deserialize
implementation. You do this by using _
. That is an unfortunate papercut, see #202.
This works:
#[serde_as]
#[derive(Deserialize)]
struct T {
#[serde_as(as = "HashMap<DurationSeconds, _>")]
pub a: HashMap<std::time::Duration, f64>
}
from serde_with.
Related Issues (20)
- Question about minimum serde version HOT 6
- Serialize enum without tags HOT 2
- Consider custom/aliased Option-like enums with `skip_serializing_none` HOT 7
- unable to use chrono::DateTime<Utc> HOT 1
- RUSTSEC-2023-0075: Unaligned write of u64 on 32-bit and 16-bit platforms
- Support for serde_as attached to a struct decl (not a field) - multi-field struct with canonical representation via a primitive (e.g. String) HOT 3
- Bug? DisplayFromStr does not use FromStr and accepts invalid values - protected agains inside of impl of FromStr, attached demo HOT 2
- gate `serde_as` behind `is_human_readable` HOT 2
- [Feature request] Deserialization that only uses `FromStr` as a fallback HOT 3
- Feature Request: DurationMinutes
- Bool from anything HOT 1
- VecSkipError fails on tagged enum HOT 3
- Unable to use `serde_with::serde_as` in conjunction with `schemars(schema_with)` HOT 3
- how to deserialize duration like 30s HOT 1
- OneOrMany serialization not implemented? HOT 4
- `#[serde_as(deserialize_as = …)]` generates `#[schemars(deserialize_with(…))]`, which is invalid HOT 1
- serde_with without android dependencies HOT 1
- Deserialize a sequence from a map by ignoring keys HOT 2
- can I combine `#[serde(default = "default_template")]` and `#[serde_as(deserialize_as = "DefaultOnNull")]` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serde_with.