Git Product home page Git Product logo

doublets-rs's Introduction

Doublets

Build Status

later

later

Example

A basic operations in doublets:

use doublets::{data, mem, unit, Doublets, DoubletsExt, Links};

fn main() -> Result<(), doublets::Error<usize>> {
    // use file as memory for doublets
    let mem = mem::FileMapped::from_path("db.links")?;
    let mut store = unit::Store::<usize, _>::new(mem)?;

    // create 1: 1 1 - it's point: link where source and target it self
    let point = store.create_link(1, 1)?;

    // `any` constant denotes any link
    let any = store.constants().any;

    // print all store from store where (index: any, source: any, target: any)
    store.each_iter([any, any, any]).for_each(|link| {
        println!("{link:?}");
    });

    // delete point with handler (Link, Link)
    store
        .delete_with(point, |before, after| {
            println!("delete: {before:?} => {after:?}");
            // track issue: https://github.com/linksplatform/doublets-rs/issues/4
            data::Flow::Continue
        })
        .map(|_| ())
}

doublets-rs's People

Contributors

dependabot[bot] avatar flakeed avatar freephoenix888 avatar konard avatar uselessgoddess avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

flakeed

doublets-rs's Issues

Wrap all exported functions to catch and unwind

All panics must be catch and unwind otherwise it is UB.
I recommend use catch_unwind with the following if let:

let result = panic::catch_unwind(|| {
    // ffi function call
});

if let Err(err) = result {
    // if `err` panic in `Drop` we will be sad
    forget(err);
}

You can create macro or function to resolve it
In currently implementation:

#[ffi::specialize_for(
    . . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
    let links: &mut WrappedLinks<T> = unnull_or_panic(this);
    drop_in_place(links);
}

We can split to:

unsafe fn drop_links_impl<T: LinkType>(this: *mut c_void) {
    // impl
}

#[ffi::specialize_for(
    . . .
)]
unsafe fn drop_links<T: LinkType>(this: *mut c_void) {
    catch_unwind(/* some */)
}

Or add this behavior to ffi::specialize_for

Inline initiative

Add #[inline] attribute to relevant places

#[inline] – any obvious functions:

fn try_get_link(&self, index: T) -> Result<Link<T>, Error<T>> {
    self.get_link(index).ok_or(Error::NotExists(index))
}

#[inline(always)] – any hard delegations:

pub fn len(&self) -> usize {
    self.0.len()
}

#[cfg_attr(feature = "inline-more", inline)] – some questionable or rarely used or internal functions:

// from united/store.rs:194
fn is_unused(&self, link: T) -> bool {
   // impl . . . 
}

Use Links trait from data

At the moment Doublets trait use Links trait. This is due to the fact that for a long time data::Links Error = Box<dyn Error>

This is now fixed at linksplatform/core-rs@a2cadfa.

However, data::Error still loses information. It may be worth impl Links for Doublets, instead of Doublets for Links

Use buffered iterators to speed up the search

Currently, op_iter functions use Vec to collect op results to vec and returns vec.into_iter().
I recommend use buffered lock-free iterator generator crate - buter or similar

For example, it will look like this:

//! before
let mut vec = Vec::with_capacity(...);
self.each(..., |link| {
    vec.push(link);
    Continue
});
vec.into_iter()

//! after
let writer = self.buter.writer();
self.each(..., |link| {
    writer.extend(Some(link));
    Continue
});
writer.into_iter()

error[E0412]: cannot find type `Link` in this scope

IMG_2830

gitpod /workspace/Solver (main) $ rustup toolchain install nightly-2022-08-22 && cargo +nightly-2022-08-22 build
info: syncing channel updates for 'nightly-2022-08-22-x86_64-unknown-linux-gnu'

  nightly-2022-08-22-x86_64-unknown-linux-gnu unchanged - rustc 1.65.0-nightly (c0941dfb5 2022-08-21)

info: checking for self-update
   Compiling linux-raw-sys v0.4.14
   Compiling bitflags v2.5.0
   Compiling fastrand v2.1.0
   Compiling cfg-if v1.0.0
   Compiling beef v0.5.2
   Compiling funty v2.0.0
   Compiling tap v1.0.1
   Compiling bumpalo v3.14.0
   Compiling leak_slice v0.2.0
   Compiling libc v0.2.155
   Compiling thiserror v1.0.61
   Compiling rustix v0.38.34
   Compiling platform-data v0.1.0-beta.3 (https://github.com/linksplatform/doublets-rs#5522d91c)
   Compiling memmap2 v0.5.10
   Compiling platform-trees v0.1.0-beta.1 (https://github.com/linksplatform/doublets-rs#5522d91c)
   Compiling tempfile v3.10.1
   Compiling platform-mem v0.1.0-pre+beta.2 (https://github.com/linksplatform/doublets-rs#5522d91c)
   Compiling doublets v0.1.0-pre+beta.15 (https://github.com/linksplatform/doublets-rs#5522d91c)
   Compiling solver v0.1.0 (/workspace/Solver)
error[E0412]: cannot find type `Link` in this scope
  --> src/main.rs:70:75
   |
70 | fn get_link_by_id(store: &mut unit::Store<usize, _>, id: usize) -> Result<Link<usize>, Error<usize>> {
   |                                                                           ^^^^
   |
  ::: /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/doublets/src/data/traits.rs:16:1
   |
16 | pub trait Links<T: LinkType>: Send + Sync {
   | ----------------------------------------- similarly named trait `Links` defined here
   |
help: a trait with a similar name exists
   |
70 | fn get_link_by_id(store: &mut unit::Store<usize, _>, id: usize) -> Result<Links<usize>, Error<usize>> {
   |                                                                           ~~~~~
help: consider importing this struct
   |
1  | use doublets::Link;
   |

error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
  --> src/main.rs:70:50
   |
70 | fn get_link_by_id(store: &mut unit::Store<usize, _>, id: usize) -> Result<Link<usize>, Error<usize>> {
   |                                                  ^ not allowed in type signatures
   |
help: use type parameters instead
   |
70 | fn get_link_by_id<T>(store: &mut unit::Store<usize, T>, id: usize) -> Result<Link<usize>, Error<usize>> {
   |                  +++                                ~

Some errors have detailed explanations: E0121, E0412.
For more information about an error, try `rustc --explain E0121`.
error: could not compile `solver` due to 2 previous errors

error[E0432]: unresolved import `thiserror` (in latest cargo version)

IMG_2831

gitpod /workspace/Solver (main) $ cargo add doublets
    Updating crates.io index
      Adding doublets v0.1.0-pre to dependencies.
             Features:
             + data
             + mem
             + num
             + platform
             - full
             - smallvec
             - smallvec-optimization
gitpod /workspace/Solver (main) $ cargo watch -x run
[Running 'cargo run']
   Compiling ppv-lite86 v0.2.17
   Compiling static_assertions v1.1.0
   Compiling getrandom v0.2.15
   Compiling num-traits v0.2.19
   Compiling platform-data v0.1.0-beta.3
error[E0432]: unresolved import `thiserror`
 --> /workspace/.cargo/registry/src/github.com-1ecc6299db9ec823/platform-data-0.1.0-beta.3/src/links.rs:4:10
  |
4 | #[derive(thiserror::Error, Debug)]
  |          ^^^^^^^^^^^^^^^^ no `ThiserrorProvide` in `__private`
  |
  = note: this error originates in the derive macro `thiserror::Error` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0412]: cannot find type `Request` in module `std::error`
 --> /workspace/.cargo/registry/src/github.com-1ecc6299db9ec823/platform-data-0.1.0-beta.3/src/links.rs:4:10
  |
4 | #[derive(thiserror::Error, Debug)]
  |          ^^^^^^^^^^^^^^^^ not found in `std::error`
  |
  = note: this error originates in the derive macro `thiserror::Error` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0658]: use of unstable library feature 'error_generic_member_access'
 --> /workspace/.cargo/registry/src/github.com-1ecc6299db9ec823/platform-data-0.1.0-beta.3/src/links.rs:4:10
  |
4 | #[derive(thiserror::Error, Debug)]
  |          ^^^^^^^^^^^^^^^^
  |
  = note: see issue #99301 <https://github.com/rust-lang/rust/issues/99301> for more information
  = help: add `#![feature(error_generic_member_access)]` to the crate attributes to enable
  = note: this error originates in the derive macro `thiserror::Error` (in Nightly builds, run with -Z macro-backtrace for more info)

   Compiling rand_core v0.6.4
error[E0599]: no method named `thiserror_provide` found for reference `&std::io::Error` in the current scope
  --> /workspace/.cargo/registry/src/github.com-1ecc6299db9ec823/platform-data-0.1.0-beta.3/src/links.rs:18:13
   |
18 |     #[error("unable to allocate memory for links storage: `{0}`")]
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `&std::io::Error`

Some errors have detailed explanations: E0412, E0432, E0599, E0658.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `platform-data` due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
[Finished running. Exit status: 101]

Add log level resetting for FFI

Waiting for the next version of tracing, but will use tracing_subscriber::reload::Handle to hold a global (lazy_static) handle to the level. Just can't do this currently because of issues with generic types in statics, and don't want to create a holder object for it.

Use associated types in Doublets trait

Use Doublets<Item = T> instead of Doublets<T>

This is idiomatically more correct. For example – AsRef and Deref:

let string = "hello".to_string();
// we want `AsRef<[u8]>`
let bytes: &[u8] = string.as_ref();
// we want `AsRef<str>`
let str: &str = string.as_ref();
let string = "hello".to_string();
let str = &*string; // we are given `str`

This will also make generic storing doublets than easier.

struct Wrapper<T, D: Doublets<T>> {
    doublets: D,
    _marker: PhantomData<T>,
}
struct Wrapper<D: Doublets> {
    doublets: D,
}
// `T` is `D::Item`

Unnecessary trailing Flow::Continue

At the moment, in any Handler, you need to return Try<Output = ()>. This is cool and allows interrupting operations in errors.
But it inflates the code:

// one operation handler
|link| {
    worker.work(link);
    Continue // <- :(
}

But everyone wants to:

|link| worker.work(link)

I see two ways

1. Inspired by std::Termination create Termination-like trait

It might look something like this:

trait HandlerResult {
    type Try: Try<Output = ()>;

    fn try_it(self) -> Self::Try;
}

// impl for ()
// impl for all Try

2. Discard `Handlers' outside the internal code (track it #3)

Use $OP_iter so each_iter and others
example above:

.each_iter(...).for_each(|link| worker.work(link))

What do you think about this?

In particular @Konard

Stacked borrows Initiative

Now the experimental miri stacked borrows consider this as Undefined Behavior

error: Undefined Behavior: not granting access to tag <83023706> because incompatible item [Unique for <83025302>] is protected by call 27318525
   --> /home/runner/.rustup/toolchains/nightly-2022-07-29-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/non_null.rs:432:18
    |
432 |         unsafe { &mut *self.as_ptr() }
    |                  ^^^^^^^^^^^^^^^^^^^ not granting access to tag <83023706> because incompatible item [Unique for <83025302>] is protected by call 27318525
    |
    = help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
    = help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <83023706> was created by a retag at offsets [0x0..0x4000000]
   --> /home/runner/work/doublets-rs/doublets-rs/doublets/src/mem/unit/store.rs:85:19
    |
85  |         let mem = self.mem.alloc(capacity)?.leak();
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: <83023706> was protected due to <83025299> which was created here
   --> /home/runner/work/doublets-rs/doublets-rs/doublets/src/mem/unit/store.rs:158:29
    |
158 |         self.sources.attach(&mut *root, index)
    |                             ^^^^^^^^^^

I find it very difficult to thread safety when multiple mutable pointers are stored in different places.
I recommend using Yoda notation in regard to pointer storing.

# instead of 
struct DoubletsTree {
    # ha-ha i own this data
    ptr: Pointer*
    
    fn method(link: T) {
        # touch `ptr`
    }
}

# i recommend use 
struct DoubletsTree {
    # where is my data :(

    fn method(i_m_here: Pointer*, link: T) {
        # touch ptr
    }
}

This works well with stacked borrows:

#! before

# borrow data[x..y]:2
self.touch_first_tree(leak -> root_of_tree, link)
# borrow data[z..w]:3 
self.touch_second_tree(leak -> root_of_tree, link)
# [x..y] and [z..w] overlapping :(

#! after
data = self.get_data(...) # -- borrow data:1

# borrow data[x..y]:2 (not borrow self)
Tree::touch_first_tree(data, root_of_tree, link)
# unborrow data[z..w]:2

# borrow data[z..w]:2 (not borrow self)
Tree::touch_second_tree(data, root_of_tree, link)
# unborrow data[z..w]:2

# unborrow data:1 :)

error[E0658]: `impl Trait` in associated types is unstable (on latest rust nightly and git dependency)

IMG_2832

gitpod /workspace/Solver (main) $ rustup update nightly
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.81.0-nightly (f21554f7f 2024-06-08)

info: checking for self-update
gitpod /workspace/Solver (main) $ cargo add doublets
    Updating git repository `https://github.com/linksplatform/doublets-rs`
      Adding doublets (git) to dependencies.
gitpod /workspace/Solver (main) $ cargo +nightly run
   Compiling delegate v0.7.0
   Compiling platform-data v0.1.0-beta.3 (https://github.com/linksplatform/doublets-rs#5522d91c)
error[E0658]: `impl Trait` in associated types is unstable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/point.rs:52:21
   |
52 |     type IntoIter = impl Iterator<Item = T>;
   |                     ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information
   = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable
   = note: this compiler was built on 2024-06-08; consider upgrading it if it is out of date

error[E0635]: unknown feature `const_deref`
 --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:8:12
  |
8 | #![feature(const_deref)]
  |            ^^^^^^^^^^^

error[E0635]: unknown feature `const_result_drop`
 --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:5:12
  |
5 | #![feature(const_result_drop)]
  |            ^^^^^^^^^^^^^^^^^

error[E0635]: unknown feature `const_convert`
 --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:7:12
  |
7 | #![feature(const_convert)]
  |            ^^^^^^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
 --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/converters.rs:9:47
  |
9 |     pub const fn convert<T: LinkType + ~const Integral + ~const Sub>(&self, source: T) -> T {
  |                                               ^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
 --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/converters.rs:9:65
  |
9 |     pub const fn convert<T: LinkType + ~const Integral + ~const Sub>(&self, source: T) -> T {
  |                                                                 ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/converters.rs:18:47
   |
18 |     pub const fn convert<T: LinkType + ~const Integral + ~const Sub>(&self, source: T) -> T {
   |                                               ^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/converters.rs:18:65
   |
18 |     pub const fn convert<T: LinkType + ~const Integral + ~const Sub>(&self, source: T) -> T {
   |                                                                 ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:17:19
   |
17 |         T: ~const Div<Output = T>,
   |                   ^^^^^^^^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:24:19
   |
24 |         T: ~const Integral + ~const Sub,
   |                   ^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:24:37
   |
24 |         T: ~const Integral + ~const Sub,
   |                                     ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:37:19
   |
37 |         T: ~const Integral + ~const Sub,
   |                   ^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:37:37
   |
37 |         T: ~const Integral + ~const Sub,
   |                                     ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:44:19
   |
44 |         T: ~const Default + ~const PartialEq,
   |                   ^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:51:19
   |
51 |         T: ~const Div + ~const PartialOrd,
   |                   ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:51:32
   |
51 |         T: ~const Div + ~const PartialOrd,
   |                                ^^^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:58:19
   |
58 |         T: ~const Div + ~const PartialOrd + ~const PartialEq,
   |                   ^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:58:32
   |
58 |         T: ~const Div + ~const PartialOrd + ~const PartialEq,
   |                                ^^^^^^^^^^

error: `~const` can only be applied to `#[const_trait]` traits
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:65:19
   |
65 |         T: ~const Integral,
   |                   ^^^^^^^^

error[E0015]: cannot call non-const fn `<T as FuntyPart>::funty` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:19:18
   |
19 |         T::MAX / T::funty(2)
   |                  ^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const operator in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:19:9
   |
19 |         T::MAX / T::funty(2)
   |         ^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const operator in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:39:9
   |
39 |         (T::MAX - value).wrapping_add(T::funty(1))
   |         ^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as FuntyPart>::funty` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:39:39
   |
39 |         (T::MAX - value).wrapping_add(T::funty(1))
   |                                       ^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as Integral>::wrapping_add` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:39:26
   |
39 |         (T::MAX - value).wrapping_add(T::funty(1))
   |                          ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as FuntyPart>::funty` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:46:23
   |
46 |         self.value == T::funty(0)
   |                       ^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const operator in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:46:9
   |
46 |         self.value == T::funty(0)
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const operator in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:53:9
   |
53 |         self.value < Self::half() // || self.value == T::default()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as FuntyPart>::funty` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:60:46
   |
60 |         !self.is_internal() || self.value == T::funty(0)
   |                                              ^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const operator in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:60:32
   |
60 |         !self.is_internal() || self.value == T::funty(0)
   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as FuntyPart>::funty` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:67:33
   |
67 |         self.value.wrapping_add(T::funty(1)).wrapping_add(T::MAX)
   |                                 ^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as Integral>::wrapping_add` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:67:20
   |
67 |         self.value.wrapping_add(T::funty(1)).wrapping_add(T::MAX)
   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

error[E0015]: cannot call non-const fn `<T as Integral>::wrapping_add` in constant functions
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/hybrid.rs:67:46
   |
67 |         self.value.wrapping_add(T::funty(1)).wrapping_add(T::MAX)
   |                                              ^^^^^^^^^^^^^^^^^^^^
   |
   = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
help: add `#![feature(effects)]` to the crate attributes to enable
  --> /workspace/.cargo/git/checkouts/doublets-rs-3835f06948971044/5522d91/dev-deps/data-rs/src/lib.rs:11:1
   |
11 + #![feature(effects)]
   |

Some errors have detailed explanations: E0015, E0635, E0658.
For more information about an error, try `rustc --explain E0015`.
error: could not compile `platform-data` (lib) due to 32 previous errors
warning: build failed, waiting for other jobs to finish...
gitpod /workspace/Solver (main) $ 

Improve `ffi::specialize_for`

Now the specialization for all integer types looks like this:

#[ffi::specialize_for(
    types = "u8",
    types = "u16",
    types = "u32",
    types = "u64",
    convention = "rust",
    name = "doublets_constants_*"
)]

I see two ways of development:

1. Remove convention and add explicit annotation with more luxury style:

#[ffi::specialize_for(
    types(
        u8  => "u8",
        u16 => "uint16",
        u32 => "uint",
        u64 => "ll",
    )
    name = "doublets_constants_*"
)]
#[ffi::specialize_for(
    u8(u8), u16(uint16), u32(uint), u64(ll),
    name = "doublets_constants_*"
)]

2. Use a more limited solution with embedded annotations:

#[ffi::specialize("doublets_constants_*")]

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.