Coder Social home page Coder Social logo

bug(Debug): error[E0275]: overflow evaluating the requirement `engine::tests::borsh_diff::Sequence2TupleEntryChange<'_, &engine::tests::borsh_diff::BorshView, &engine::tests::borsh_diff::BorshView>: std::marker::Sized` about educe HOT 2 OPEN

dzmitry-lahoda avatar dzmitry-lahoda commented on August 20, 2024
bug(Debug): error[E0275]: overflow evaluating the requirement `engine::tests::borsh_diff::Sequence2TupleEntryChange<'_, &engine::tests::borsh_diff::BorshView, &engine::tests::borsh_diff::BorshView>: std::marker::Sized`

from educe.

Comments (2)

ijackson avatar ijackson commented on August 20, 2024 1

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.

dzmitry-lahoda avatar dzmitry-lahoda commented on August 20, 2024
#[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)

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.