Skip to content

Commit

Permalink
Fix 'cargo build'
Browse files Browse the repository at this point in the history
  • Loading branch information
djmitche committed Feb 18, 2025
1 parent 31394a9 commit fc9d434
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 16 deletions.
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Each segment ends with an exercise. Exercises are typically structured as an
`exercise.rs` containing the problem and solution. This is referenced from
`exercise.md` and `solution.md`, using `{{#include exercise.rs:anchor_name}}` to
match ANCHOR comments in the `exercise.rs` file. Each segment also has a
`Cargo.toml` file containing a `[[bin]]` section referring to `exercise.rs`, and
that Cargo package is referenced from the workspace the root `Cargo.toml`. The
result is that `exercise.rs` is built and tested by `cargo test`.
`Cargo.toml` file containing a `[[bin]]` or `[lib]` section referring to
`exercise.rs`, and that Cargo package is referenced from the workspace the root
`Cargo.toml`. The result is that `exercise.rs` is built and tested by
`cargo test`.

For segments on day 1, exercises should use `fn main() { .. }` and `println!`,
with students visually verifying the correct output. On subsequent days, prefer
Expand Down
2 changes: 1 addition & 1 deletion src/borrowing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
[lib]
name = "borrowing"
path = "../../third_party/rust-on-exercism/health-statistics.rs"
2 changes: 1 addition & 1 deletion src/error-handling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ publish = false
anyhow = "*"
thiserror = "*"

[[bin]]
[lib]
name = "parser"
path = "exercise.rs"
2 changes: 1 addition & 1 deletion src/generics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
[lib]
name = "generics"
path = "exercise.rs"
2 changes: 1 addition & 1 deletion src/generics/exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ minutes: 10
In this short exercise, you will implement a generic `min` function that
determines the minimum of two values, using the [`Ord`] trait.

```rust,compile_fail,editable
```rust,editable
use std::cmp::Ordering;
// TODO: implement the `min` function used in the tests.
Expand Down
1 change: 1 addition & 0 deletions src/generics/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(dead_code)]

// ANCHOR: solution
use std::cmp::Ordering;
Expand Down
4 changes: 2 additions & 2 deletions src/iterators/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "offset-differences"
[lib]
name = "offset_differences"
path = "exercise.rs"
2 changes: 1 addition & 1 deletion src/lifetimes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ publish = false
[dependencies]
thiserror = "*"

[[bin]]
[lib]
name = "protobuf"
path = "exercise.rs"
1 change: 1 addition & 0 deletions src/lifetimes/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(dead_code)]

// ANCHOR: solution
// ANCHOR: preliminaries
Expand Down
2 changes: 1 addition & 1 deletion src/pattern-matching/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
[lib]
name = "eval"
path = "exercise.rs"
4 changes: 2 additions & 2 deletions src/smart-pointers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "binary-tree"
[lib]
name = "binary_tree"
path = "exercise.rs"
1 change: 1 addition & 0 deletions src/smart-pointers/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(dead_code)]

// ANCHOR: solution
use std::cmp::Ordering;
Expand Down
4 changes: 2 additions & 2 deletions src/std-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ version = "0.1.0"
edition = "2021"
publish = false

[[bin]]
name = "std-traits"
[lib]
name = "std_traits"
path = "exercise.rs"
2 changes: 1 addition & 1 deletion src/testing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ publish = false
[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(never)'] }

[[bin]]
[lib]
name = "luhn"
path = "exercise.rs"
1 change: 1 addition & 0 deletions src/testing/exercise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![allow(dead_code)]

// This is the buggy version that appears in the problem.
#[cfg(never)]
Expand Down

0 comments on commit fc9d434

Please sign in to comment.