Debian Codegraph @

tests/test_boxed.rs

raw symbols SCIP
1 #![allow(
2 // Clippy bug: https://github.com/rust-lang/rust-clippy/issues/7422
3 clippy::nonstandard_macro_braces,
4 )]
5
6 use anyhowrust-analyzer cargo anyhow 1.0.103 crate/::anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!;
7 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std error/::Errorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# as StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#;
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/;
9 use thiserrorrust-analyzer cargo thiserror 2.0.18 crate/::Errorrust-analyzer cargo thiserror-impl 2.0.18 Error:;
10
11 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Errorrust-analyzer cargo thiserror-impl 2.0.18 Error:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
12 #[error("outer")]
13 struct MyErrorrust-analyzer cargo anyhow 1.0.103 MyError# {
14 sourcerust-analyzer cargo anyhow 1.0.103 MyError#source.: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#,
15 }
16
17 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
18 fn test_boxed_strrust-analyzer cargo anyhow 1.0.103 test_boxed_str().() {
19 let error = Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/convert/impl#[`Box<dyn Error + Send + Sync + 'a>`][`From<&str>`]from().("oh no!");
20 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(error);
21 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("oh no!", error.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
22 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
23 "oh no!",
24 error
25 .downcast_refrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]downcast_ref().::<Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + Sendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Send# + Syncrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sync#>>()
26 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().()
27 .to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().()
28 );
29 }
30
31 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
32 fn test_boxed_thiserrorrust-analyzer cargo anyhow 1.0.103 test_boxed_thiserror().() {
33 let error = MyErrorrust-analyzer cargo anyhow 1.0.103 MyError# {
34 sourcerust-analyzer cargo anyhow 1.0.103 MyError#source.: iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]new().(iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::ErrorKindrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#::Otherrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/ErrorKind#Other#, "oh no!"),
35 };
36 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(error);
37 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("oh no!", error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
38 }
39
40 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
41 fn test_boxed_anyhowrust-analyzer cargo anyhow 1.0.103 test_boxed_anyhow().() {
42 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!("oh no!").contextrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]context().("it failed");
43 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(error);
44 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!("oh no!", error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().());
45 }