diff options
Diffstat (limited to 'src/doc/book/listings/ch14-more-about-cargo/listing-14-01')
3 files changed, 25 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.lock b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.lock new file mode 100644 index 000000000..b304dd7c7 --- /dev/null +++ b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "my_crate" +version = "0.1.0" + diff --git a/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.toml b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.toml new file mode 100644 index 000000000..c52da0412 --- /dev/null +++ b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "my_crate" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/src/lib.rs b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/src/lib.rs new file mode 100644 index 000000000..ed7abb727 --- /dev/null +++ b/src/doc/book/listings/ch14-more-about-cargo/listing-14-01/src/lib.rs @@ -0,0 +1,13 @@ +/// Adds one to the number given. +/// +/// # Examples +/// +/// ``` +/// let arg = 5; +/// let answer = my_crate::add_one(arg); +/// +/// assert_eq!(6, answer); +/// ``` +pub fn add_one(x: i32) -> i32 { + x + 1 +} |