Comments (2)
This is #27
You can work around this by specifying bounds explictly, eg #[educe(Debug(bound()))]
I think will work in this case.
from educe.
#[derive(Clone, PartialEq, Eq, educe::Educe)]
#[educe(Debug)]
#[repr(u8)]
pub enum BorshDiffs<'a> {
/// if change will fail deserialization, for example fixed array changed to non fixed
/// but tuple <-> struct is ok, and same type struct <-> tuple <-> fixed sequence is ok
/// with type of change
Serde(DiffPair<'a>) = 0,
/// just checking value equality, like number value or string
Eq(DiffPair<'a>) = 1,
// /// exact same data in non singular container, so order change
// /// with element positions change map
// Order(#[educe(Debug(ignore))] DiffPair<'a>) = 2,
// /// if to make set of elements in container, no equality
// Set(#[educe(Debug(ignore))] DiffPair<'a>) = 3,
/// any sort-oblivion sequence with 2-tuple like add(key)/remove(key)/modify(for value)
OrderedKeyValue(
#[educe(Debug(ignore))] DiffPair<'a>,
Vec<Sequence2TupleEntryChange<'a, &'a BorshView, &'a BorshView>>,
) = 4,
// ... etc etc ...
/// list of differences
Multi(#[educe(Debug(ignore))] DiffPair<'a>, Vec<BorshDiffs<'a>>) = u8::MAX,
}
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
pub struct DiffPair<'a> {
#[allow(dead_code)]
old: &'a BorshView,
new: &'a BorshView,
}
#[derive(
Clone, Debug, PartialEq, Eq, BorshSchema, BorshSerialize, BorshDeserialize, PartialOrd, Ord,
)]
pub struct BorshView {
pub path: BorshPath,
pub value: BorshViews,
}
#[derive(
Clone, Debug, PartialEq, Eq, BorshSchema, BorshSerialize, BorshDeserialize, PartialOrd, Ord,
)]
#[borsh(use_discriminant = true)]
#[repr(u16)]
pub enum BorshViews {
Empty = 0,
Bool(bool),
U8(u8),
U16(u16),
U32(u32),
U64(u64),
U128(u128),
I8(i8),
I16(i16),
I32(i32),
I64(i64),
I128(i128),
/// fixed length
Tuple(Vec<BorshView>),
/// non fixed length
/// sequence of chars
SequenceString(String),
/// may have duplicate entries, can be Vec or Set, etc
Sequence(Vec<BorshView>),
/// fixed length
FixedSequence(Vec<BorshView>),
/// non fixed length
/// may have duplicate keys
/// really conventionally is just Sequence of Tuples
Sequence2Tuple(Vec<(BorshView, BorshView)>),
/// heterogenous fixed size sequence (unnamed struct), cannot be reordered
/// specific case of map when key is unique and String
/// fixed length
NamedTuple(Vec<(String, BorshView)>),
/// single element sequence (or single variant enum)
/// fixed lenght
Option(Box<BorshView>),
/// single element heterogeneous map
/// fixed length
Enum(String, Box<BorshView>),
}
/// Somewhat valid Rust accessor to raw data similar to jq/xpath path like `.ob.markets["USD/BTC"].orderbook[0].price`
type BorshPath = String;
/// Old to new map updates difference structure.
/// Applicable to non fixed size containers only.
#[derive(Clone, Eq, PartialEq, Debug)]
pub enum Sequence2TupleEntryChange<'a, K, V> {
Insert(K, V),
Remove(K, V),
Modify(K, V, V, BorshDiffs<'a>),
}
from educe.
Related Issues (17)
- Multiple bounds are confused HOT 2
- PartialEq macro generates incorrect code HOT 1
- Set default per type HOT 5
- `#[derive(Serde)]` shorthand for `#[derive(Serialize, Deserialize)]` HOT 1
- `educe` uses legacy (^1) version of `syn` crate. HOT 3
- Panic when other attributes contain non-literal tokens
- Missing white spaces in default expressions HOT 1
- Debug for unions is unsound, exposes uninitialized memory HOT 4
- Name collision if an enum field is named `f` or `builder` HOT 3
- Suggestions for reducing implementation code duplication
- Wrong bounds applied to derived impls HOT 3
- Namespace problems with MyDebug, RawString, and possibly others
- Explicitly defining bounds with multiple traits leads to spurious bounds HOT 3
- Version 0.5.12 contains breaking changes. HOT 6
- Handle recursive enum HOT 1
- Help with Default with generics not working. 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 educe.