diff options
Diffstat (limited to 'src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias')
3 files changed, 27 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.lock b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.lock new file mode 100644 index 000000000..b1977d01e --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "traits-example" +version = "0.1.0" + diff --git a/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.toml b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.toml new file mode 100644 index 000000000..52395a587 --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "traits-example" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs new file mode 100644 index 000000000..573559934 --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/no-listing-06-result-alias/src/lib.rs @@ -0,0 +1,15 @@ +use std::fmt; + +// ANCHOR: here +type Result<T> = std::result::Result<T, std::io::Error>; +// ANCHOR_END: here + +// ANCHOR: there +pub trait Write { + fn write(&mut self, buf: &[u8]) -> Result<usize>; + fn flush(&mut self) -> Result<()>; + + fn write_all(&mut self, buf: &[u8]) -> Result<()>; + fn write_fmt(&mut self, fmt: fmt::Arguments) -> Result<()>; +} +// ANCHOR_END: there |