Debian Codegraph @

tests/test_source.rs

raw symbols SCIP
1 use anyhowrust-analyzer cargo anyhow 1.0.103 crate/::anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!;
2 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#;
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{selfrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#};
4 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/;
5
6 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:)]
7 enum TestErrorrust-analyzer cargo anyhow 1.0.103 TestError# {
8 Iorust-analyzer cargo anyhow 1.0.103 TestError#Io#(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#),
9 }
10
11 impl Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# for TestErrorrust-analyzer cargo anyhow 1.0.103 TestError# {
12 fn fmtrust-analyzer cargo anyhow 1.0.103 impl#[TestError][Display]fmt().(&self, formatter: &mut fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#) -> fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Result# {
13 match self {
14 TestErrorrust-analyzer cargo anyhow 1.0.103 TestError#::Iorust-analyzer cargo anyhow 1.0.103 TestError#Io#(e) => Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#::fmtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error][Display]fmt().(e, formatter),
15 }
16 }
17 }
18
19 impl StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# for TestErrorrust-analyzer cargo anyhow 1.0.103 TestError# {
20 fn sourcerust-analyzer cargo anyhow 1.0.103 impl#[TestError][Error]source().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&(dyn StdErrorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error# + 'static)> {
21 match self {
22 TestErrorrust-analyzer cargo anyhow 1.0.103 TestError#::Iorust-analyzer cargo anyhow 1.0.103 TestError#Io#(io) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(io),
23 }
24 }
25 }
26
27 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
28 fn test_literal_sourcerust-analyzer cargo anyhow 1.0.103 test_literal_source().() {
29 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!("oh no!");
30 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
31 }
32
33 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
34 fn test_variable_sourcerust-analyzer cargo anyhow 1.0.103 test_variable_source().() {
35 let msg = "oh no!";
36 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(msg);
37 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
38
39 let msg = msg.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
40 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(msg);
41 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
42 }
43
44 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
45 fn test_fmt_sourcerust-analyzer cargo anyhow 1.0.103 test_fmt_source().() {
46 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!("{} {}!", "oh", "no");
47 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(error.sourcerust-analyzer cargo core https://github.com/rust-lang/rust/library/core error/Error#source().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
48 }
49
50 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
51 fn test_io_sourcerust-analyzer cargo anyhow 1.0.103 test_io_source().() {
52 let io = 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!");
53 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(TestErrorrust-analyzer cargo anyhow 1.0.103 TestError#::Iorust-analyzer cargo anyhow 1.0.103 TestError#Io#(io));
54 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().());
55 }
56
57 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
58 fn test_anyhow_from_anyhowrust-analyzer cargo anyhow 1.0.103 test_anyhow_from_anyhow().() {
59 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!("oh no!").contextrust-analyzer cargo anyhow 1.0.103 error/impl#[Error]context().("context");
60 let error = anyhowrust-analyzer cargo anyhow 1.0.103 macros/anyhow!!(error);
61 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().());
62 }