lloydmeta / frunk

Funktional generic type-level programming in Rust: HList, Coproduct, Generic, LabelledGeneric, Validated, Monoid and friends.
https://beachape.com/frunk/
MIT License
1.24k stars 56 forks source link

The correct way of adding the crate frunk dependency #218

Closed dima-starosud closed 1 year ago

dima-starosud commented 1 year ago

Most likely the issue is related to possibly outdated documentation.

Using rustc 1.70.0 (90c541806 2023-05-31) and following the latest docs here https://docs.rs/frunk/latest/frunk/ I've added frunk = "0.4.2" to the Cargo.toml, but the following code fails to compile:

use frunk::prelude::*;
use frunk::LabelledGeneric;

#[derive(LabelledGeneric)]
struct Zho {}

with the error:

error[E0433]: failed to resolve: could not find `frunk_core` in the list of imported crates
 --> src/main.rs:4:10
  |
4 | #[derive(LabelledGeneric)]
  |          ^^^^^^^^^^^^^^^ could not find `frunk_core` in the list of imported crates
  |
  = note: this error originates in the derive macro `LabelledGeneric` (in Nightly builds, run with -Z macro-backtrace for more info)

Adding frunk_core = "0.4.2" to the Cargo.toml fixes the issue, but I am not sure that's the proper way. Also, I couldn't find anything in the documentation about this.

To me it looks like sole frunk = "0.4.2" should work out of the box.

lloydmeta commented 1 year ago

I think you'll need to pull in frunk_core, unfortunately in order for the derive to work, since it's referenced in the macro that builds the derives.

https://github.com/lloydmeta/frunk/blob/34ba13d8162d276b50dfcb8a6c46d4445c2409a5/derives/src/derive_labelled_generic.rs#L107

dima-starosud commented 1 year ago

Thank you for the response 👍 Do you think we should put this in the doc? i.e. deriving Generic/LabelledGeneric is probably the first prerequisite to use the lib, and to do that one should always pull frunk_core, but docs don't say anything about this.

lloydmeta commented 1 year ago

Thank you for the response 👍 Do you think we should put this in the doc? i.e. deriving Generic/LabelledGeneric is probably the first prerequisite to use the lib, and to do that one should always pull frunk_core, but docs don't say anything about this.

That sounds good to me !

dima-starosud commented 1 year ago

Cool 👍 Should I create a PR for this?

lloydmeta commented 1 year ago

Yeah, sounds good to me.

On Mon, Jul 3, 2023 at 20:12 dima-starosud @.***> wrote:

Cool 👍 Should I create a PR for this?

— Reply to this email directly, view it on GitHub https://github.com/lloydmeta/frunk/issues/218#issuecomment-1617971492, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG7K5I5P4WUUIXJ7DGK2Q3XOKSIZANCNFSM6AAAAAAZVNEGIU . You are receiving this because you commented.Message ID: @.***>

dima-starosud commented 1 year ago

I am not sure I am able to assign this ticket to me 🤔

dima-starosud commented 1 year ago

@lloydmeta created PR for this https://github.com/lloydmeta/frunk/pull/219 Please have a look.

dima-starosud commented 1 year ago

Thank you! That was fast 😃