summaryrefslogtreecommitdiffstats
path: root/third_party/rust/error-chain/examples/all.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /third_party/rust/error-chain/examples/all.rs
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/error-chain/examples/all.rs')
-rw-r--r--third_party/rust/error-chain/examples/all.rs36
1 files changed, 36 insertions, 0 deletions
diff --git a/third_party/rust/error-chain/examples/all.rs b/third_party/rust/error-chain/examples/all.rs
new file mode 100644
index 0000000000..840ca95e27
--- /dev/null
+++ b/third_party/rust/error-chain/examples/all.rs
@@ -0,0 +1,36 @@
+#[macro_use]
+extern crate error_chain;
+
+pub mod inner {
+ error_chain! {}
+}
+
+#[cfg(feature = "a_feature")]
+pub mod feature {
+ error_chain! {}
+}
+
+error_chain! {
+ // Types generated by the macro. If empty or absent, it defaults to
+ // Error, ErrorKind, Result;
+ types {
+ // With custom names:
+ MyError, MyErrorKind, MyResult;
+ // Without the `Result` wrapper:
+ // Error, ErrorKind;
+ }
+
+ // Automatic bindings to other error types generated by `error_chain!`.
+ links {
+ Inner(inner::Error, inner::ErrorKind);
+ // Attributes can be added at the end of the declaration.
+ Feature(feature::Error, feature::ErrorKind) #[cfg(feature = "a_feature")];
+ }
+
+ // Bindings to types implementing std::error::Error.
+ foreign_links {
+ Io(::std::io::Error);
+ }
+}
+
+fn main() {}