summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoniEx2 <endermoneymod@gmail.com>2022-06-16 21:13:37 -0300
committerSoniEx2 <endermoneymod@gmail.com>2022-06-16 21:14:16 -0300
commit2dfa1fba89de316e197402c4ebb9b794e774d42c (patch)
treeb8645408988682fc3858bd8567d78f992c2efb32
parent98a44fd2ee3e0b4c62265969ec61703817841d92 (diff)
Fix example
-rw-r--r--Cargo.toml2
-rw-r--r--src/lib.rs108
2 files changed, 55 insertions, 55 deletions
diff --git a/Cargo.toml b/Cargo.toml
index d3af4fe..a689fc8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "selfref"
-version = "0.1.0"
+version = "0.1.1"
 authors = ["SoniEx2 <endermoneymod@gmail.com>"]
 edition = "2021"
 description = "Pain-free self-referential pinned types"
diff --git a/src/lib.rs b/src/lib.rs
index 33b6f19..265cd17 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -23,60 +23,60 @@
 //!
 //! # Example
 //!
-/// ```rust
-/// #![feature(generic_associated_types)]
-/// #![feature(pin_macro)]
-///
-/// use core::cell::Cell;
-/// use core::marker::PhantomData;
-/// use core::pin::Pin;
-/// use core::pin::pin;
-/// 
-/// use selfref::Holder;
-/// use selfref::NewWith;
-/// use selfref::OperateIn;
-/// use selfref::SelfRef;
-/// use selfref::opaque;
-///
-/// struct Foo<'a, 'b: 'a> {
-///     foo: Cell<Option<&'a Foo<'a, 'b>>>,
-///     t: &'b str,
-/// }
-/// impl<'a, 'b> SelfRef<'a> for Foo<'a, 'b> {}
-///
-/// struct FooKey<'b>(PhantomData<&'b str>);
-/// opaque! {
-///     impl['b] Opaque for FooKey<'b> {
-///         type Kind<'a> = Foo<'a, 'b>;
-///     }
-/// }
-///
-/// fn main() {
-///     struct FooBuilder<'b>(&'b str);
-///     impl<'k, 'b: 'k> NewWith<'k, FooKey<'b>> for FooBuilder<'b> {
-///         fn new_with<'a>(self) -> Foo<'a, 'b> where 'k: 'a {
-///             Foo {
-///                 foo: Default::default(),
-///                 t: self.0,
-///             }
-///         }
-///     }
-///     let stack_array: [u8; 5] = *b"hello";
-///     // a non-'static &str
-///     let stack_str = core::str::from_utf8(&stack_array).unwrap();
-///     let holder = pin!(Holder::new_with(FooBuilder(stack_str)));
-///     // Actually making our Foo refer to itself.
-///     struct SetFooRef;
-///     impl<'k, 'b: 'k> OperateIn<'k, FooKey<'b>> for SetFooRef {
-///         type Out = ();
-///         fn operate_in<'a>(self, foo: Pin<&'a Foo<'a, 'b>>)
-///         where 'k: 'a {
-///             foo.foo.set(Some(foo.get_ref()));
-///         }
-///     }
-///     holder.as_ref().operate_in(SetFooRef);
-/// }
-/// ```
+//! ```rust
+//! #![feature(generic_associated_types)]
+//! #![feature(pin_macro)]
+//!
+//! use core::cell::Cell;
+//! use core::marker::PhantomData;
+//! use core::pin::Pin;
+//! use core::pin::pin;
+//! 
+//! use selfref::Holder;
+//! use selfref::NewWith;
+//! use selfref::OperateIn;
+//! use selfref::SelfRef;
+//! use selfref::opaque;
+//!
+//! struct Foo<'a, 'b: 'a> {
+//!     foo: Cell<Option<&'a Foo<'a, 'b>>>,
+//!     t: &'b str,
+//! }
+//! impl<'a, 'b> SelfRef<'a> for Foo<'a, 'b> {}
+//!
+//! struct FooKey<'b>(PhantomData<&'b str>);
+//! opaque! {
+//!     impl['b] Opaque for FooKey<'b> {
+//!         type Kind<'a> = Foo<'a, 'b>;
+//!     }
+//! }
+//!
+//! fn main() {
+//!     struct FooBuilder<'b>(&'b str);
+//!     impl<'k, 'b: 'k> NewWith<'k, FooKey<'b>> for FooBuilder<'b> {
+//!         fn new_with<'a>(self) -> Foo<'a, 'b> where 'k: 'a {
+//!             Foo {
+//!                 foo: Default::default(),
+//!                 t: self.0,
+//!             }
+//!         }
+//!     }
+//!     let stack_array: [u8; 5] = *b"hello";
+//!     // a non-'static &str
+//!     let stack_str = core::str::from_utf8(&stack_array).unwrap();
+//!     let holder = pin!(Holder::new_with(FooBuilder(stack_str)));
+//!     // Actually making our Foo refer to itself.
+//!     struct SetFooRef;
+//!     impl<'k, 'b: 'k> OperateIn<'k, FooKey<'b>> for SetFooRef {
+//!         type Out = ();
+//!         fn operate_in<'a>(self, foo: Pin<&'a Foo<'a, 'b>>)
+//!         where 'k: 'a {
+//!             foo.foo.set(Some(foo.get_ref()));
+//!         }
+//!     }
+//!     holder.as_ref().operate_in(SetFooRef);
+//! }
+//! ```
 
 use core::marker::PhantomPinned;
 use core::pin::Pin;