aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2023-08-16 22:35:47 +0200
committerHampusM <hampus@hampusmat.com>2023-08-16 22:36:09 +0200
commit800e164a83388aa5ca7675f8031b0f0d7c6b6051 (patch)
tree744cbab2db5ff7ca4edb3713ceabf24d79620df0 /examples
parent595806824d41c696b660f40c01914a24e9618f1d (diff)
test: make the prevent-circular example an integration test
Diffstat (limited to 'examples')
-rw-r--r--examples/prevent-circular/main.rs52
1 files changed, 0 insertions, 52 deletions
diff --git a/examples/prevent-circular/main.rs b/examples/prevent-circular/main.rs
deleted file mode 100644
index c690a9c..0000000
--- a/examples/prevent-circular/main.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-//! Example demonstrating the prevention of circular dependencies.
-//!
-//! Having circular dependencies is generally bad practice and is detected by Syrette when
-//! the `prevent-circular` feature is enabled.
-#![deny(clippy::all)]
-#![deny(clippy::pedantic)]
-#![allow(clippy::disallowed_names)]
-
-use syrette::di_container::blocking::prelude::*;
-use syrette::injectable;
-use syrette::ptr::TransientPtr;
-
-struct Foo
-{
- _bar: TransientPtr<Bar>,
-}
-
-#[injectable]
-impl Foo
-{
- fn new(bar: TransientPtr<Bar>) -> Self
- {
- Self { _bar: bar }
- }
-}
-
-struct Bar
-{
- _foo: TransientPtr<Foo>,
-}
-
-#[injectable]
-impl Bar
-{
- fn new(foo: TransientPtr<Foo>) -> Self
- {
- Self { _foo: foo }
- }
-}
-
-fn main() -> Result<(), anyhow::Error>
-{
- let mut di_container = DIContainer::new();
-
- di_container.bind::<Foo>().to::<Foo>()?;
- di_container.bind::<Bar>().to::<Bar>()?;
-
- // The following won't work. Err will be returned.
- let _foo = di_container.get::<Foo>()?.transient()?;
-
- Ok(())
-}