Lines Matching full:example

54 /// struct Example {
59 /// // Create a refcounted instance of `Example`.
60 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
84 /// struct Example {
89 /// impl Example {
99 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
105 /// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`:
118 /// struct Example;
119 /// impl MyTrait for Example {}
121 /// // `obj` has type `Arc<Example>`.
122 /// let obj: Arc<Example> = Arc::new(Example, GFP_KERNEL)?;
492 /// # Example
497 /// struct Example;
499 /// fn do_something(e: ArcBorrow<'_, Example>) -> Arc<Example> {
503 /// let obj = Arc::new(Example, GFP_KERNEL)?;
516 /// struct Example {
521 /// impl Example {
527 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
623 /// In the following example, we make changes to the inner object before turning it into an
630 /// struct Example {
635 /// fn test() -> Result<Arc<Example>> {
636 /// let mut x = UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
645 /// In the following example we first allocate memory for a refcounted `Example` but we don't
647 /// followed by a conversion to `Arc<Example>`. This is particularly useful when allocation happens
653 /// struct Example {
658 /// fn test() -> Result<Arc<Example>> {
660 /// Ok(x.write(Example { a: 10, b: 20 }).into())
666 /// In the last example below, the caller gets a pinned instance of `Example` while converting to
667 /// `Arc<Example>`; this is useful in scenarios where one needs a pinned reference during
668 /// initialisation, for example, when initialising fields that are wrapped in locks.
673 /// struct Example {
678 /// fn test() -> Result<Arc<Example>> {
679 /// let mut pinned = Pin::from(UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?);