Comments (4)
BorshDeserialize has the same issue with R
FWIW so that probably needs renaming too.
from borsh-rs.
NOTE: serde
has similar issue, though it uses a hidden type parameter __S
in the example, which behaves the same, but is less likely to be used outside of derived code context:
use serde::Serialize;
#[derive(Debug, Serialize)]
struct Generic<K, __S>
{
x: HashMap<K, __S>,
y: String,
}
error[E0403]: the name `__S` is already used for a generic parameter in this item's generic parameters
--> src/serialize.rs:8:21
|
8 | #[derive(Debug, Serialize)]
| ^^^^^^^^^ already used
9 | struct Generic<K, __S>
| --- first use of `__S`
|
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace formore info)
error[E0053]: method `serialize` has an incompatible type for trait
--> src/serialize.rs:8:21
|
8 | #[derive(Debug, Serialize)]
| ^^^^^^^^^
| |
| expected type parameter `__S`, found a different type parameter `__S`
| help: change the parameter type to match the trait: `__S`
9 | struct Generic<K, __S>
| --- found type parameter
|
= note: expected signature `fn(&serialize::_struct::Generic<K, __S>, __S) -> Result<<__S as Serializer>::Ok, <__Sas Serializer>::Error>`
found signature `fn(&serialize::_struct::Generic<K, __S>, __S) -> Result<_, _>`
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace formore info)
from borsh-rs.
Right. As far as I understand, the macros are not hygenic w.r.t. generic type parameters (though I have no idea what the reasoning is) so the usual hacks are to use names that are unlikely to be taken by user.
from borsh-rs.
@dj8yfo Can we rename W
to __S
to reduce chances of naming collision?
from borsh-rs.
Related Issues (20)
- Restriction on Serializing Zero-Sized Types Affects Marker Component Usage HOT 7
- BorshSerialize derive fails for structs with packed attribute HOT 4
- Should `std` feature imply `rc` feature and vice-versa? HOT 4
- Read/Write mutable reference in `serialize` and `deserialize_reader` is unnecessary HOT 8
- `derive` macros require `cargo` to be present HOT 4
- Old NEAR contracts won't compile with the new `borsh` re-exported from `near-sdk-rs` ("Could not find `borsh`") HOT 5
- equivalent of `#[serde(default)]` HOT 2
- Borsh 2.0? Not planned HOT 2
- Extract `alloc` feature (2.0 candidate) HOT 1
- `bytes::Bytes` and `bytes::BytesMut` can be complemented with `BorshSchema`
- `bson::oid::ObjectId` can be complemented with `BorshSchema`
- Add struct/enum attr to relax bounds
- feat(schema): for chars HOT 4
- feat(schema): support serde of HashMap with S hasher
- Support for adding new fields to previously serialized structs HOT 2
- Can't serialize a `Vec<ZST>`, but it appears that the attack is only on deserialization HOT 1
- blanket implementation of `BorshSchema` for `&T` (where `T: BorshSchema`)
- Replace `schema_map!` tests with `insta` snapshots
- Backport Vec<ZST> deserialisation fix to 0.10.x HOT 3
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 borsh-rs.