vionya / discord-rich-presence

A cross-platform Discord Rich Presence library written in Rust
MIT License
94 stars 20 forks source link

What is this error? #32

Closed B3ni15 closed 5 months ago

B3ni15 commented 5 months ago
error: expected one of `!` or `::`, found `<eof>`
 --> tempCodeRunnerFile.rs:1:1
  |
1 | DiscordIpc
  | ^^^^^^^^^^ expected one of `!` or `::`

error: aborting due to 1 previous error

Someone can help me with that?

The code:

use discord_rich_presence::{activity, DiscordIpc, DiscordIpcClient};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut client = DiscordIpcClient::new("1214134857999982622")?;

    client.connect()?;
    client.set_activity(activity::Activity::new()
        .state("foo")
        .details("bar")
    )?;
    client.close()?;

    Ok(())
}

image image

Bowarc commented 5 months ago

You have a file called tempCodeRunnerFile.rs somewhere in your src folder that only contains DiscordIpc which itself is not valid rust code.

Bowarc commented 5 months ago

What did you change between thoses two terminal screens ?

B3ni15 commented 5 months ago

What did you change between thoses two terminal screens ?

Nothing. I just ran it differently.

B3ni15 commented 5 months ago

You have a file called tempCodeRunnerFile.rs somewhere in your src folder that only contains DiscordIpc which itself is not valid rust code.

How can I fix it?

Bowarc commented 5 months ago

Nothing

Oh im a dumbass i diddn't saw that, well, cargo uses the src/main.rs as entry point.

Im guessing that you diddn't linked your 2nd file in your main using something like mod myfile? That file just got ignored.

Bowarc commented 5 months ago

Put your code in your src/main.rs and use cargo if you have dependencies.

To set the project's name, use the cargo.toml's name parameter

vionya commented 5 months ago

has this issue been resolved? if so i'll close it. thanks @Bowarc for helping :)