Debian Codegraph @

tests/basic.rs

raw symbols SCIP
1 extern crate transformation_pipelinerust-analyzer cargo transformation-pipeline 0.1.0 transformation_pipeline/;
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/::Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#;
4 use transformation_pipelinerust-analyzer cargo transformation-pipeline 0.1.0 crate/::{TransformationStagerust-analyzer cargo transformation-pipeline 0.1.0 stage/TransformationStage#, StageActionsrust-analyzer cargo transformation-pipeline 0.1.0 result/StageActions#, StageResultrust-analyzer cargo transformation-pipeline 0.1.0 result/StageResult#, TransformationPipelinerust-analyzer cargo transformation-pipeline 0.1.0 pipeline/TransformationPipeline#};
5
6 struct Userrust-analyzer cargo transformation-pipeline 0.1.0 User# {
7
8 namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
9
10 }
11
12 impl Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# for Userrust-analyzer cargo transformation-pipeline 0.1.0 User# {
13
14 fn clonerust-analyzer cargo transformation-pipeline 0.1.0 impl#[User][Clone]clone().(&self) -> Selfrust-analyzer cargo transformation-pipeline 0.1.0 impl#[User][Clone] {
15 Userrust-analyzer cargo transformation-pipeline 0.1.0 User# {
16 namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: self.namerust-analyzer cargo transformation-pipeline 0.1.0 User#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(),
17 }
18 }
19
20 }
21
22 struct CapitializeNamerust-analyzer cargo transformation-pipeline 0.1.0 CapitializeName# {}
23
24 impl TransformationStagerust-analyzer cargo transformation-pipeline 0.1.0 stage/TransformationStage#<Userrust-analyzer cargo transformation-pipeline 0.1.0 User#> for CapitializeNamerust-analyzer cargo transformation-pipeline 0.1.0 CapitializeName# {
25
26 fn runrust-analyzer cargo transformation-pipeline 0.1.0 impl#[CapitializeName][`TransformationStage<User>`]run().(&self, previous: Userrust-analyzer cargo transformation-pipeline 0.1.0 User#) -> StageResultrust-analyzer cargo transformation-pipeline 0.1.0 result/StageResult#<Userrust-analyzer cargo transformation-pipeline 0.1.0 User#> {
27
28 let mut name: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = previous.namerust-analyzer cargo transformation-pipeline 0.1.0 User#name..charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
29 name[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = name[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().0]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..to_uppercaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core char/methods/impl#[char]to_uppercase().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(0).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
30
31 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StageActionsrust-analyzer cargo transformation-pipeline 0.1.0 result/StageActions#::Nextrust-analyzer cargo transformation-pipeline 0.1.0 result/StageActions#Next#(Userrust-analyzer cargo transformation-pipeline 0.1.0 User# {
32 namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: name.into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().(),
33 }))
34 }
35 }
36
37 /*
38 I normally don't assume that all individuals are male. This is just a test.
39 */
40 struct ImposeMrrust-analyzer cargo transformation-pipeline 0.1.0 ImposeMr# {}
41
42 impl TransformationStagerust-analyzer cargo transformation-pipeline 0.1.0 stage/TransformationStage#<Userrust-analyzer cargo transformation-pipeline 0.1.0 User#> for ImposeMrrust-analyzer cargo transformation-pipeline 0.1.0 ImposeMr# {
43
44 fn runrust-analyzer cargo transformation-pipeline 0.1.0 impl#[ImposeMr][`TransformationStage<User>`]run().(&self, previous: Userrust-analyzer cargo transformation-pipeline 0.1.0 User#) -> StageResultrust-analyzer cargo transformation-pipeline 0.1.0 result/StageResult#<Userrust-analyzer cargo transformation-pipeline 0.1.0 User#> {
45
46 let mut name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = "Mr. ".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
47 name.push_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]push_str().(&previous.namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.);
48
49 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(StageActionsrust-analyzer cargo transformation-pipeline 0.1.0 result/StageActions#::Nextrust-analyzer cargo transformation-pipeline 0.1.0 result/StageActions#Next#(Userrust-analyzer cargo transformation-pipeline 0.1.0 User# {
50 namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: name,
51 }))
52 }
53 }
54
55 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
56 fn run_pipelinerust-analyzer cargo transformation-pipeline 0.1.0 run_pipeline().() {
57 let pipeline: TransformationPipelinerust-analyzer cargo transformation-pipeline 0.1.0 pipeline/TransformationPipeline#<Userrust-analyzer cargo transformation-pipeline 0.1.0 User#> = TransformationPipelinerust-analyzer cargo transformation-pipeline 0.1.0 pipeline/TransformationPipeline#::newrust-analyzer cargo transformation-pipeline 0.1.0 pipeline/impl#[`TransformationPipeline<T>`]new().(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![
58 Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(CapitializeNamerust-analyzer cargo transformation-pipeline 0.1.0 CapitializeName# {}),
59 Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(ImposeMrrust-analyzer cargo transformation-pipeline 0.1.0 ImposeMr# {}),
60 ]);
61
62 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pipeline.runrust-analyzer cargo transformation-pipeline 0.1.0 pipeline/impl#[`TransformationPipeline<T>`]run().(Userrust-analyzer cargo transformation-pipeline 0.1.0 User# { namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: "john".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().namerust-analyzer cargo transformation-pipeline 0.1.0 User#name., "Mr. John");
63 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(pipeline.runrust-analyzer cargo transformation-pipeline 0.1.0 pipeline/impl#[`TransformationPipeline<T>`]run().(Userrust-analyzer cargo transformation-pipeline 0.1.0 User# { namerust-analyzer cargo transformation-pipeline 0.1.0 User#name.: "John Doe".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().namerust-analyzer cargo transformation-pipeline 0.1.0 User#name., "Mr. John Doe");
64 }