Search code examples
rustrust-cargorust-obsolete

Cargo.toml for lib


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 ?


Solution

  • 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)