Import not found when using latest `master`

Hello Folks,

Disclaimer: I’m fairly new to Rust, so it could be that I’m doing something completely obvious or silly, therefore, I ask you exercise patience if this seems like a glaring/obvious mistake. The truth is, I wouldn’t be posting here if I would have been able to figure this out; I hope to learn something new :slight_smile:

I have created a fresh Rust project (latest stable rust), and to separate things, I have used the workspace feature, the way I think is correct. (I’ll show the details of the project structure below) but first I’d like to point out the error in case this is fairly simple:

In my “main/root” Cargo.toml, I’ve added

git = ... (url of the iced repo)
rev = ... latest rev on master

(note: I tried the rev linked in the documentation and even none at all, it’s the same).

Now, this seems to work fine except I cannot find many of the usual imports, like “iced::Sandbox” for example.

So in I get a red import.

Now, if I change the above to just

iced = "0.12.1"

It works fine. (I want to use the latest though…)

Am I missing something here?

Details about the project structure

Because I wanted to separate most of the logic, I created a lib project inside this one.

The structure is simple, let’s say the app is called… app in the name of originality:

/app/applib/Cargo.toml # 1
/app/Cargo.toml #2

Cargo.toml number 1 (the lib one)
looks like:

name = "applib"
# version, edition, etc... all standard (omitted for brevity)

#dep versions omitted here for brevity as well...
serde = ...
serde_yaml = ...
git2 = ...

In the Cargo.toml number 2, that is the “main crate”, I have:

workspace = { members = ["applib"] }
name = "app"
# version, edition, etc... 

name = "myapp"
path = "src/"

applib = { path = "applib" }

git = ... # path to iced github
rev = ... # HEAD of master atm, but tried others.

Now when I do this, the app was working fine (that is, all the code in is able to use the applib crate and access its public code.
But the Iced dependency, is for the app not the lib, since the lib contains no UI code.

However, as it is, it just doesn’t work.

In, I do for e.g.:

use iced::{Application} # this line is red, import cannot be found.

fn main() {

#[derive(Default, Debug, Clone)]
enum MyApp {

impl Application for MyApp { ## This line is red because `Application` is not found.


Now, if I change the cargo.toml to use:

applib = { path = "applib" }
iced = "0.12.1"

#git = ... # path to iced github
#rev = ... # HEAD of master atm, but tried others.

Then the import works fine!

What am I missing?

Thank you for your help!

Could you share the Error that the rust analyzer is giving you?


Using Sandbox as an example, there are two errors:

(btw, I’m using RustRover, if it matters)

Unresolved import: `iced::Sandbox` [E0432]:1
Cannot find trait `Sandbox` in this scope [E0405]:21

I suppose the numbers at the end are the line numbers where the error happens.

I don’t see any other error.

The rev I’m using is:


EDIT: I tried doing cargo build from a terminal emulator.

The Rust Error underlines the Sandbox in the use statement with:

use iced::{Element, Sandbox};
                    ^^^^^^^ no `Sandbox` in the root

Is this what you were after?

Last Update:

I was doing all this on a macOS machine. Since I don’t like them much (work machine) I decided to try on a Linux box.

I created a fresh project, then added a crate (type library) and it looks exactly like the code I’ve manually created on the work machine, the even comes with a simple “add(x,y)” function that works when called from the simple main():

fn main() {
    println!("Hello, world!");

But adding an enum, then impl Sandbox for MyEnum fails the same way when using the latest master commit, and not when using iced 0.12.1 directly.

Sandbox has been removed in master:

1 Like

Ahhh well that explains it then! Apologies for the noise.

I was following “the book” and it suggested to use certain commit, but I figured using a more recent one was better; I guess I was very wrong.

Thank you very much, I’ll take a look at the new API.