Just discovered @rustlang figures out src/bin automagically (you don't _need_ to be explicit in Cargo.toml) and it took me about 10mins to divide my project into a library and a tiny binary that consumes it.
Thanks in particular to @sgrif and his fabulous Diesel tutorial code.
-
-
"Cargo will also treat any files located in src/bin/*.rs as executables": https://doc.rust-lang.org/stable/cargo/reference/manifest.html#the-project-layout … The specific tutorial I was looking at when it clicked into place:https://github.com/diesel-rs/diesel/tree/master/examples/mysql/getting_started_step_1 …
1 reply 2 retweets 13 likesShow this thread -
Replying to @Gisleburt
is that similar to putting code in the `examples` folder?
1 reply 0 retweets 0 likes -
Replying to @TobiasBieniek
Looks like yes, but I would guess that examples should be for example implementation of your code rather than production of a specific binary. That said, I don't see any downside to using examples instead of bin in the docs, perhaps
@rustlang or someone else could elaborate?1 reply 0 retweets 1 like
Yes, examples, binaries, and benchmark tests do all of this kind of automatic inference. The release tomorrow has a bit about a tweak to it, even. Examples and secondary binaries are different for the reason you describe. Examples are also compiled by “cargo test”, binaries not
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.