Cargo can't find package despite being written in Cargo.toml

Nothing much to add here.

Perhaps you are using a workspace with multiple crates and the Cargo.toml you are showing is for a different crate than the crate containing the src/scalar.rs file? I can't think of anything else.

2 Likes

I rechecked this cause I know myself to often making such errors.
Far as I can tell this is accurate. I could try doing it again later .

In the [package] section of Cargo.toml what is the value of the edition key?

I just checked the source of the curve25519-dalek crate. The issue primarily lies in src/lib.rs. First, since Cargo.toml specifies no edition key, the crate defaults to the 2015 edition. In this edition, all dependencies must first be declared with extern crate foo;. And in src/lib.rs, extern crate serde; is predicated on the optional dependency:

#[cfg(feature = "serde")]
extern crate serde;

Commenting out the #[cfg(...)] line fixes the issue.

1 Like

As mentioned by @LegionMammal978 bellow, the edition in the .toml is not specified.

It works now, thanks to @LegionMammal978 's solution.

Thanks in part to all your responses I got to know about the features feature of the Cargo and realize that since the feature was not 'enabled' - which I am still not sure how I did it - a defined implementation of Serialize couldn't be used. I just enabled this feature in the project where I was using this crate as the dependency and won't have to do a lot of kinky workarounds now. Thanks!