Linked Questions

9 votes
1 answer
6k views

Is it possible to change the name of main.rs and still have commands like cargo run work? If it is possible could someone give me an example of how to have cargo run target say example.rs?
John164's user avatar
  • 149
6 votes
1 answer
7k views

I'd like to create a rust package with two binary crates and a library which contains the shared code. I know how do do this for a simple program by putting the source files for the binaries in a src/...
Bob's user avatar
  • 1,207
8 votes
1 answer
2k views

How do I create a library and executable in one project? I just want to test my library while working on it and using tests isn't always the best way to do that. I believe I have to use [lib] and [???]...
user avatar
5 votes
0 answers
2k views

I'm building an app that hooks some Windows events. The hook code must be in a DLL for that to work. I set [lib] with crate-type = ["cdylib"] in Cargo.toml and use it in main.rs. │ Cargo.toml │ └───...
Adamarla's user avatar
  • 874
0 votes
1 answer
527 views

I have the following directory structure in my Rust project: borrowing | |-------src | |-------borrow.rs | |-------lib.rs | |-------Cargo.toml |-------main.rs ...
user366312's user avatar
  • 17.5k
0 votes
0 answers
176 views

Let's assume we have the following file tree: src |--bin | |--hw.rs |--libs | |--streams.rs | |--structs.rs |--main.rs I want to access some structs from the structs module inside the hw file, ...
AT3RM0N's user avatar
204 votes
8 answers
149k views

I have 4 files: main.rs mod bar; fn main() { let v = vec![1, 2, 3]; println!("Hello, world!"); } lib.rs pub mod foo; pub mod bar; foo.rs pub fn say_foo() { } bar.rs use crate::foo; fn ...
nz_21's user avatar
  • 7,781
279 votes
3 answers
141k views

I'd like to make a project with a daemon and a client, connecting through a unix socket. A client and a daemon requires two binaries, so how do I tell Cargo to build two targets from two different ...
RallionRl's user avatar
  • 2,983
62 votes
5 answers
45k views

I created a new binary using Cargo: cargo new my_binary --bin A function in my_binary/src/main.rs can be used for a test: fn function_from_main() { println!("Test OK"); } #[test] fn my_test() { ...
ideasman42's user avatar
  • 49.3k
35 votes
1 answer
9k views

My project's path structure is as follows: demo ├── benches │   └── crypto_bench.rs ├── src │   ├── main.rs │   └── crypto.rs ├── Cargo.lock └── Cargo.toml crypto.rs contains a struct Crypto with ...
Anton's user avatar
  • 1,136
31 votes
1 answer
19k views

Right now I have a Cargo workspace with three members. [workspace] members = [ "foo", "bar", "baz", ] If I run cargo run in the root directory, I get this error: error: manifest path /...
Lukas Kalbertodt's user avatar
11 votes
1 answer
21k views

I have included a library as a submodule in my program. The structure looks like this: . ├── my_lib/ │ ├── Cargo.toml │ └── src/ │ ├── lib/ │ │ ├── mod.rs │ │ └── ...
Daniel Mancebo's user avatar
1 vote
1 answer
5k views

I have a front-end project that has a lot of stuff in src folder, and I have the opportunity to also use Rust on the server side. All my Rust server files are in the server folder; how can I tell ...
ColdHands's user avatar
  • 1,078
1 vote
1 answer
4k views

I'm stuck when learning how to access a module. I'm trying to insert a folder other than src into src. It's not working and it gives me an error. Here this is my project tree. $ Project1 . |-- src | ...
user avatar

15 30 50 per page