Lines Matching full:example

56 /// struct Example {
61 /// // Create a refcounted instance of `Example`.
62 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
86 /// struct Example {
91 /// impl Example {
101 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
107 /// Coercion from `Arc<Example>` to `Arc<dyn MyTrait>`:
120 /// struct Example;
121 /// impl MyTrait for Example {}
123 /// // `obj` has type `Arc<Example>`.
124 /// let obj: Arc<Example> = Arc::new(Example, GFP_KERNEL)?;
515 /// struct Example;
517 /// fn do_something(e: ArcBorrow<'_, Example>) -> Arc<Example> {
521 /// let obj = Arc::new(Example, GFP_KERNEL)?;
534 /// struct Example {
539 /// impl Example {
545 /// let obj = Arc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
641 /// In the following example, we make changes to the inner object before turning it into an
648 /// struct Example {
653 /// fn test() -> Result<Arc<Example>> {
654 /// let mut x = UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?;
663 /// In the following example we first allocate memory for a refcounted `Example` but we don't
665 /// followed by a conversion to `Arc<Example>`. This is particularly useful when allocation happens
671 /// struct Example {
676 /// fn test() -> Result<Arc<Example>> {
678 /// Ok(x.write(Example { a: 10, b: 20 }).into())
684 /// In the last example below, the caller gets a pinned instance of `Example` while converting to
685 /// `Arc<Example>`; this is useful in scenarios where one needs a pinned reference during
686 /// initialisation, for example, when initialising fields that are wrapped in locks.
691 /// struct Example {
696 /// fn test() -> Result<Arc<Example>> {
697 /// let mut pinned = Pin::from(UniqueArc::new(Example { a: 10, b: 20 }, GFP_KERNEL)?);