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)?;
463 /// # Example
468 /// struct Example;
470 /// fn do_something(e: ArcBorrow<'_, Example>) -> Arc<Example> {
474 /// let obj = Arc::new(Example, GFP_KERNEL)?;
487 /// struct Example {
492 /// impl Example {
498 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
594 /// In the following example, we make changes to the inner object before turning it into an
601 /// struct Example {
606 /// fn test() -> Result<Arc<Example>> {
607 /// let mut x = UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
616 /// In the following example we first allocate memory for a refcounted `Example` but we don't
618 /// followed by a conversion to `Arc<Example>`. This is particularly useful when allocation happens
624 /// struct Example {
629 /// fn test() -> Result<Arc<Example>> {
631 /// Ok(x.write(Example { a: 10, b: 20 }).into())
637 /// In the last example below, the caller gets a pinned instance of `Example` while converting to
638 /// `Arc<Example>`; this is useful in scenarios where one needs a pinned reference during
639 /// initialisation, for example, when initialising fields that are wrapped in locks.
644 /// struct Example {
649 /// fn test() -> Result<Arc<Example>> {
650 /// let mut pinned = Pin::from(UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?);