1

I want to create a library for rust. This is the Cargo.toml file for my project :

[package]
name = "binary_tree"
version = "0.0.1"
authors = ["Guillaume Bersac <bersac_1@hotmail.fr>"]

[lib]
test = true
plugin = false

This is the file of my repository :

Cargo.toml
README.md
src
|_node.rs

When I run the command "cargo run" or "cargo build" or "cargo test", I get the following error message :

Cargo.toml is not a valid manifest

expected a value of type array, but found a value of type table for the key lib

How to format my Cargo.toml so that it compile correctly ?

daboross
  • 716
  • 10
  • 23
Moebius
  • 6,242
  • 7
  • 42
  • 54

2 Answers2

6

Are you running the latest rustc and cargo? If not, I think you used to need [[lib]], which creates a table array in TOML.

BurntSushi5
  • 13,917
  • 7
  • 52
  • 45
1

This is the correct Cargo.toml :

[package]
name = "binary_tree"
version = "0.0.1"
authors = ["Guillaume Bersac <bersac_1@hotmail.fr>"]

[[lib]]
name="binary_tree"
test = true
plugin = false

It looks like I am running an old version of cargo. It is strange because I installed it yesterday following the official guide and using this command :

$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh

My rustc version is : rustc 0.13.0-nightly (40b244973 2014-10-14 23:22:20 +0000)

My cargo version is : cargo 0.0.1-pre-nightly (9788700 2014-10-15 20:14:53 +0000)

Moebius
  • 6,242
  • 7
  • 42
  • 54
  • 2
    I'm not sure why you unaccepted my answer. My answer included a guess that you were using an old `cargo` and that you probably needed to use `[[lib]]`. Indeed, that's precisely what you have here. – BurntSushi5 Oct 27 '14 at 13:36
  • Your answer is right, I defined my answer as beeing the right answer because my answer is more precise than yours (example of the solution). It is better for any user who come on this page to see the most detailed answer. Sorry for the 15 reputation point you lose because of that changement. – Moebius Oct 27 '14 at 15:15
  • 5
    In the future, it would be courteous of you to leave a comment asking the answerer to expand with a full example. – BurntSushi5 Oct 27 '14 at 15:51