Overview
This project contains two crates: lens-rs
and lens-rs_derive
. The lens-rs
provide some definitions of lens. The lens-rs_derive
provide the macro to derive lens for data types.
This project contains two crates: lens-rs
and lens-rs_derive
. The lens-rs
provide some definitions of lens. The lens-rs_derive
provide the macro to derive lens for data types.
derive_optic
was removed but the README still references it.
https://github.com/TOETOE55/lens-rs/commit/3c19d0d2516dd0ca128972bcd194da861cf0ae5d#diff-dc4a22e0b81ffbabfdb6f61ae197ca2f0a406ddf9141d14e930b56b5df7b3a74R41
How can we have optics on struct fields now?
I know this crate is very new, but I'm excited about it. Nice work!
When I build I see
Compiling lens-rs v0.3.2 (.../repos/lens-rs/lens-rs)
error[E0583]: file not found for module `dyn_optics`
--> lens-rs/src/lib.rs:210:1
|
210 | pub mod dyn_optics;
| ^^^^^^^^^^^^^^^^^^^
|
= help: to create the module `dyn_optics`, create file "lens-rs/src/dyn_optics.rs" or "lens-rs/src/dyn_optics/mod.rs"
It looks like the recent merge added line 210 above, but not the dyn_optics.rs file. Thanks for this crate!
rust version is rustc 1.57.0 (f1edd0429 2021-11-29)
With example as blow
#[derive(Copy, Clone, Debug, Review, Prism)]
enum Either<L, R> {
#[optic]
Left(L), // generate optics::Left
#[optic]
Right(R), // generate optics::Right
}
#[derive(Copy, Clone, Debug, Lens)]
struct Tuple<A, B>(#[optic] A, #[optic] B);
// use optics::_0 or optics::_1 to access it
#[derive(Copy, Clone, Debug, Lens)]
struct Foo<A, B> {
#[optic]
a: A, // generate optics::a
#[optic]
b: B, // generate optics::b
}
#[derive(Clone, Debug, Lens)]
struct Bar {
#[optic]
a: String, // generate optics::a, same as above
#[optic]
c: i32, // generate optics::c
}```
get error
```error[E0412]: cannot find type `Left` in module `lens_rs::optics`
--> src/domain/mod.rs:15:5
|
15 | Left(L), // generate optics::Left
| ^^^^ not found in `lens_rs::optics`
|
help: there is an enum variant `core::fmt::Alignment::Left` and 11 others; try using the variant's enum
|
12 | #[derive(Copy, Clone, Debug, core::fmt::Alignment, Prism)]
| ~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, core::fmt::rt::v1::Alignment, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, crate::domain::Either, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, futures::future::Either, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~~~
and 7 other candidates
error[E0412]: cannot find type `Right` in module `lens_rs::optics`
--> src/domain/mod.rs:17:5
|
17 | Right(R), // generate optics::Right
| ^^^^^ not found in `lens_rs::optics`
|
help: there is an enum variant `core::fmt::Alignment::Right` and 11 others; try using the variant's enum
|
12 | #[derive(Copy, Clone, Debug, core::fmt::Alignment, Prism)]
| ~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, core::fmt::rt::v1::Alignment, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, crate::domain::Either, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, futures::future::Either, Prism)]
| ~~~~~~~~~~~~~~~~~~~~~~~
and 7 other candidates
error[E0412]: cannot find type `Left` in module `lens_rs::optics`
--> src/domain/mod.rs:15:5
|
15 | Left(L), // generate optics::Left
| ^^^^ not found in `lens_rs::optics`
|
help: there is an enum variant `core::fmt::Alignment::Left` and 11 others; try using the variant's enum
|
12 | #[derive(Copy, Clone, Debug, Review, core::fmt::Alignment)]
| ~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, core::fmt::rt::v1::Alignment)]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, crate::domain::Either)]
| ~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, futures::future::Either)]
| ~~~~~~~~~~~~~~~~~~~~~~~
and 7 other candidates
error[E0412]: cannot find type `Right` in module `lens_rs::optics`
--> src/domain/mod.rs:17:5
|
17 | Right(R), // generate optics::Right
| ^^^^^ not found in `lens_rs::optics`
|
help: there is an enum variant `core::fmt::Alignment::Right` and 11 others; try using the variant's enum
|
12 | #[derive(Copy, Clone, Debug, Review, core::fmt::Alignment)]
| ~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, core::fmt::rt::v1::Alignment)]
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, crate::domain::Either)]
| ~~~~~~~~~~~~~~~~~~~~~
12 | #[derive(Copy, Clone, Debug, Review, futures::future::Either)]
| ~~~~~~~~~~~~~~~~~~~~~~~
and 7 other candidates
error[E0412]: cannot find type `a` in module `lens_rs::optics`
--> src/domain/mod.rs:27:5
|
27 | a: A, // generate optics::a
| ^ not found in `lens_rs::optics`
error[E0412]: cannot find type `b` in module `lens_rs::optics`
--> src/domain/mod.rs:29:5
|
29 | b: B, // generate optics::b
| ^ not found in `lens_rs::optics`
error[E0412]: cannot find type `a` in module `lens_rs::optics`
--> src/domain/mod.rs:36:5
|
36 | a: String, // generate optics::a, same as above
| ^ not found in `lens_rs::optics`
error[E0412]: cannot find type `c` in module `lens_rs::optics`
--> src/domain/mod.rs:38:5
|
38 | c: i32, // generate optics::c
| ^ not found in `lens_rs::optics`
warning: unused import: `ChildStdin`
--> src/domain/command.rs:3:34
|
3 | use std::process::{Stdio,Command,ChildStdin};
| ^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
warning: unused import: `super::validate::validate_raw`
--> src/domain/model.rs:9:5
|
9 | use super::validate::validate_raw;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0207]: the type parameter `__Rv` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:12:30
|
12 | #[derive(Copy, Clone, Debug, Review, Prism)]
| ^^^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Review` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Tr` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:12:38
|
12 | #[derive(Copy, Clone, Debug, Review, Prism)]
| ^^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Prism` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Pm` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:12:38
|
12 | #[derive(Copy, Clone, Debug, Review, Prism)]
| ^^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Prism` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Tr` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:24:30
|
24 | #[derive(Copy, Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Lens` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Pm` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:24:30
|
24 | #[derive(Copy, Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Lens` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Ls` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:24:30
|
24 | #[derive(Copy, Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Lens` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Tr` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:33:24
|
33 | #[derive(Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Lens` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Pm` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:33:24
|
33 | #[derive(Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
|
= note: this error originates in the derive macro `Lens` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0207]: the type parameter `__Ls` is not constrained by the impl trait, self type, or predicates
--> src/domain/mod.rs:33:24
|
33 | #[derive(Clone, Debug, Lens)]
| ^^^^ unconstrained type parameter
Can you please give a example project can pass build.
I get the following test errors when i try to do cargo test:
failures: src/lib.rs - (line 103) src/lib.rs - (line 115) src/lib.rs - (line 131) src/lib.rs - (line 182) src/lib.rs - (line 222) src/lib.rs - (line 35) src/lib.rs - (line 45) src/lib.rs - (line 54) src/lib.rs - (line 63) src/lib.rs - (line 72) src/lib.rs - (line 87) src/lib.rs - Optics (line 222) src/lib.rs - optics (line 222) src/traits.rs - traits::prism (line 56) src/traits.rs - traits::traversal (line 24)
1. Specify path for the dependency of lens-rs_derive in lens-rs's Cargo.toml.
According to the [cargo book](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html?highlight=specify%20depend#multiple-locations):
> One example where this can be useful is when you have split up a library into multiple packages within the same workspace. You can then use path dependencies to point to the local packages within the workspace to use the local version during development, and then use the crates.io version once it is published.
2. Crate lens-rs_derive adds experimental support for deriving lens_rs::{Optic, Review, Prism, Lens} for [structx](https://github.com/oooutlk/structx/tree/structx_derives_lens).
bit-counter Package for counting the number of one bits in a numpy array of uint8 values. Implemented as a Python module using Rust, providing high pe
Please be aware that this crate is no longer actively maintained, please look into the much more feature rich cbindgen instead. rusty-cheddar rusty-ch
Using unsafe for Fun and Profit A guide to traversing the FFI boundary between Rust and other languages. A rendered version is available here. This gu
A library to compile C/C++/assembly into a Rust library/application.
ur-wasm-js WASM/JS bindings for the ur-rust rust library Getting started Installation Either build the library yourself with wasm-pack or install for
cbindgen Read the full user docs here! cbindgen creates C/C++11 headers for Rust libraries which expose a public C API. While you could do this by h
bindgen bindgen automatically generates Rust FFI bindings to C (and some C++) libraries. For example, given the C header doggo.h: typedef struct Doggo
CXX — safe FFI between Rust and C++ This library provides a safe mechanism for calling C++ code from Rust and Rust code from C++, not subject to the m
Rustler Documentation | Getting Started | Example Rustler is a library for writing Erlang NIFs in safe Rust code. That means there should be no ways t
Curryrs Curryrs (a play on the name of Haskell Curry, rs for Rust libraries, and it's pronunciation couriers) is a library for providing easy to use b
Provides an example for using Rust in Haskell. To use this you'll need cargo, rustc, cabal and GHC installed. To execute the example run the following
Java Native Interface Bindings for Rust This library provides complete FFI bindings to the Java Native Interface, as well as a safe and intuitive wrap
Java/Rust Example An example project showing how to call into Rust code from Java. OSX Linux Windows Requirements Java 7+ Rust (tested with 1.0, night
jdbc A Rust library that allows you to use JDBC and JDBC drivers. Usage First, add the following to your Cargo.toml: [dependencies] jdbc = "0.1" Next,
rust-lua53 Aims to be complete Rust bindings for Lua 5.3 and beyond. Currently, master is tracking Lua 5.3.3. Requires a Unix-like environment. On Win
rust-lua Copyright 2014 Lily Ballard Description This is a set of Rust bindings to Lua 5.1. The goal is to provide a (relatively) safe interface to Lu
td_rlua This library is a high-level binding for Lua 5.3. You don't have access to the Lua stack, all you can do is read/write variables (including ca
hlua This library is a high-level binding for Lua 5.2. You don't have access to the Lua stack, all you can do is read/write variables (including callb
mrusty. mruby safe bindings for Rust mrusty lets you: run Ruby 1.9 files with a very restricted API (without having to install Ruby) reflect Rust stru