From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- .../listings/ch09-error-handling/listing-09-10/Cargo.lock | 6 ++++++ .../listings/ch09-error-handling/listing-09-10/Cargo.toml | 6 ++++++ .../listings/ch09-error-handling/listing-09-10/output.txt | 15 +++++++++++++++ .../ch09-error-handling/listing-09-10/src/main.rs | 5 +++++ 4 files changed, 32 insertions(+) create mode 100644 src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.lock create mode 100644 src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.toml create mode 100644 src/doc/book/listings/ch09-error-handling/listing-09-10/output.txt create mode 100644 src/doc/book/listings/ch09-error-handling/listing-09-10/src/main.rs (limited to 'src/doc/book/listings/ch09-error-handling/listing-09-10') diff --git a/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.lock b/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.lock new file mode 100644 index 000000000..1fa96b797 --- /dev/null +++ b/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "error-handling" +version = "0.1.0" + diff --git a/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.toml b/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.toml new file mode 100644 index 000000000..c496db783 --- /dev/null +++ b/src/doc/book/listings/ch09-error-handling/listing-09-10/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "error-handling" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/doc/book/listings/ch09-error-handling/listing-09-10/output.txt b/src/doc/book/listings/ch09-error-handling/listing-09-10/output.txt new file mode 100644 index 000000000..26e4ff8cc --- /dev/null +++ b/src/doc/book/listings/ch09-error-handling/listing-09-10/output.txt @@ -0,0 +1,15 @@ +$ cargo run + Compiling error-handling v0.1.0 (file:///projects/error-handling) +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) + --> src/main.rs:4:48 + | +3 | / fn main() { +4 | | let greeting_file = File::open("hello.txt")?; + | | ^ cannot use the `?` operator in a function that returns `()` +5 | | } + | |_- this function should return `Result` or `Option` to accept `?` + | + = help: the trait `FromResidual>` is not implemented for `()` + +For more information about this error, try `rustc --explain E0277`. +error: could not compile `error-handling` due to previous error diff --git a/src/doc/book/listings/ch09-error-handling/listing-09-10/src/main.rs b/src/doc/book/listings/ch09-error-handling/listing-09-10/src/main.rs new file mode 100644 index 000000000..38b005480 --- /dev/null +++ b/src/doc/book/listings/ch09-error-handling/listing-09-10/src/main.rs @@ -0,0 +1,5 @@ +use std::fs::File; + +fn main() { + let greeting_file = File::open("hello.txt")?; +} -- cgit v1.2.3