Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expected tuple struct or tuple variant, found struct variant KbKey::Character #2403

Open
vimyang opened this issue Jun 24, 2024 · 3 comments

Comments

@vimyang
Copy link

vimyang commented Jun 24, 2024

When I was using druid version 0.7.0, the code worked fine.

 [dependencies]
 druid = "0.7.0"
 reqwest = { version = "0.11", features = ["blocking"] }
 serde = { version = "1.0", features = ["derive"] }
 serde_json = "1.0"

But when I modify my 0.8.3, I get an error that has nothing to do with my code, as follows
image

I tried the following operations, and it still didn’t solve the problem after re-running it.

# problem not solved
cargo clean 

# problem not solved
rm -rf ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3

Thanks ~

run command

cargo run --bin radio

the code

use druid::widget::{Flex, Label, RadioGroup};
use druid::{AppLauncher, Data, Lens, Widget, WidgetExt, WindowDesc};

#[derive(Clone, Data, Lens)]
struct AppData {
    choice: String,
}

fn build_ui() -> impl Widget<AppData> {
    let choices = vec![
        ("Option 1".to_string(), "Value 1".to_string()),
        ("Option 2".to_string(), "Value 2".to_string()),
        ("Option 3".to_string(), "Value 3".to_string()),
    ];
    let radio = RadioGroup::new(choices).lens(AppData::choice);

    let label = Label::new(|data: &AppData, _env: &druid::Env| {
        format!("You selected: {}", data.choice)
    });

    Flex::column()
        .with_child(radio)
        .with_child(label)
}

fn main() {
    let main_window = WindowDesc::new(build_ui)
        .title("RadioGroup Example")
        .window_size((300.0, 200.0));

    let data = AppData { choice: "Value 1".to_string() };

    AppLauncher::with_window(main_window)
        .use_simple_logger()
        .launch(data)
        .expect("Failed to launch application");
}

@xStrom
Copy link
Member

xStrom commented Jun 27, 2024

I tried your code and it works fine for me with both 0.7 and 0.8, x64 Windows 11.

Try deleting your Cargo.lock file and see if that helps, it might contain some incompatible dependency.

What OS and version are you using? x64 or ARM?

@vimyang
Copy link
Author

vimyang commented Jun 28, 2024

Thank you for your reply. My system is mac m1 arm. I plan to delete the Cargo.lock file and verify it. If you have any questions, please consult me. Thank you 🙏

@vimyang
Copy link
Author

vimyang commented Jul 1, 2024

  1. rm Cargo.lock && cargo update -> not ok
  2. rm -rf /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/ -> not ok

code: https://github.com/yangmingming/learn_rust/tree/error

git checkout origin/error
cd druid
cargo run --bin radio

Even if the version in Cargo.toml is modified to v0.8.1, the version in the regenerated Cargo.lock is still v0.8.3

[dependencies]
druid = "0.8.1"

error msg

(base) xxxxxxx@xxxxxxx druid % cargo run --bin radio

   Compiling druid-shell v0.8.3
ls  Building [=======================> ] 175/178: druid-shell                                                                                       
error[E0533]: expected value, found struct variant `KbKey::Character`
   --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/backend/mac/keyboard.rs:316:21
    |
316 |                     KbKey::Character(characters)
    |                     ^^^^^^^^^^^^^^^^ not a value

error[E0533]: expected value, found struct variant `KbKey::Character`
   --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/backend/mac/keyboard.rs:320:25
    |
320 |                         KbKey::Character(chars_ignoring)
    |                         ^^^^^^^^^^^^^^^^ not a value

error[E0164]: expected tuple struct or tuple variant, found struct variant `KbKey::Character`
   --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/backend/mac/menu.rs:123:13
    |
123 |             KbKey::Character(t) => t,
    |             ^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant

error[E0164]: expected tuple struct or tuple variant, found struct variant `KbKey::Character`
  --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/hotkey.rs:97:16
   |
97 |         if let KbKey::Character(s) = &self.key {
   |                ^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant

error[E0533]: expected value, found struct variant `KbKey::Character`
   --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/keyboard.rs:219:9
    |
219 |         KbKey::Character(self.into())
    |         ^^^^^^^^^^^^^^^^ not a value

error[E0164]: expected tuple struct or tuple variant, found struct variant `KbKey::Character`
   --> /Users/xxxxxxx/.cargo/registry/src/index.crates.io-6f17d22bba15001f/druid-shell-0.8.3/src/text.rs:473:9
    |
473 |         KbKey::Character(c) if !event.mods.ctrl() && !event.mods.meta() && !event.mods.alt() => {
    |         ^^^^^^^^^^^^^^^^^^^ not a tuple struct or tuple variant

Some errors have detailed explanations: E0164, E0533.
For more information about an error, try `rustc --explain E0164`.
error: could not compile `druid-shell` (lib) due to 6 previous errors
(base) xxxxxxx@Baidu-xxxxxxx druid % 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants