Lines Matching full:example
55 /// struct Example {
60 /// // Create a refcounted instance of `Example`.
61 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
85 /// struct Example {
90 /// impl Example {
100 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
106 /// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`:
119 /// struct Example;
120 /// impl MyTrait for Example {}
122 /// // `obj` has type `Arc<Example>`.
123 /// let obj: Arc<Example> = Arc::new(Example, GFP_KERNEL)?;
439 /// # Example
444 /// struct Example;
446 /// fn do_something(e: ArcBorrow<'_, Example>) -> Arc<Example> {
450 /// let obj = Arc::new(Example, GFP_KERNEL)?;
463 /// struct Example {
468 /// impl Example {
474 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
570 /// In the following example, we make changes to the inner object before turning it into an
577 /// struct Example {
582 /// fn test() -> Result<Arc<Example>> {
583 /// let mut x = UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
592 /// In the following example we first allocate memory for a refcounted `Example` but we don't
594 /// followed by a conversion to `Arc<Example>`. This is particularly useful when allocation happens
600 /// struct Example {
605 /// fn test() -> Result<Arc<Example>> {
607 /// Ok(x.write(Example { a: 10, b: 20 }).into())
613 /// In the last example below, the caller gets a pinned instance of `Example` while converting to
614 /// `Arc<Example>`; this is useful in scenarios where one needs a pinned reference during
615 /// initialisation, for example, when initialising fields that are wrapped in locks.
620 /// struct Example {
625 /// fn test() -> Result<Arc<Example>> {
626 /// let mut pinned = Pin::from(UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?);