all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
blob 06cde0e79e2fc82a67e3ce1c508187b804da82f0 1809 bytes (raw)
name: test/manual/etags/rs-src/test.rs 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
 
mod test;

use std::collections::hash_map::{self, HashMap};

use std::path::{self, Path, PathBuf};  // good: std is a crate name
use crate::foo::baz::foobaz;    // good: foo is at the root of the crate

enum IpAddrKind {
    V4,
    V6,
}

fn test1() {
   println!("Testing");
}

fn main() {
   test::test1();
}

fn eat_box_i32(boxed_i32: Box<i32>) {
    println!("Destroying box that contains {}", boxed_i32);
}

// This function borrows an i32
fn borrow_i32(borrowed_i32: &i32) {
    println!("This int is: {}", borrowed_i32);
}

struct Val {
    val: f64,
}

struct GenVal<T> {
    gen_val: T,
}

// impl of Val
impl Val {
    fn value(&self) -> &f64 {
        &self.val
    }
}

// impl of GenVal for a generic type `T`
impl<T> GenVal<T> {
    fn value(&self) -> &T {
        &self.gen_val
    }
}

fn main() {
    let x = Val { val: 3.0 };
    let y = GenVal { gen_val: 3i32 };

    println!("{}, {}", x.value(), y.value());
}

fn main() {
    // Create a boxed i32, and a stacked i32
    let boxed_i32 = Box::new(5_i32);
    let stacked_i32 = 6_i32;

    // Borrow the contents of the box. Ownership is not taken,
    // so the contents can be borrowed again.
    borrow_i32(&boxed_i32);
    borrow_i32(&stacked_i32);

    {
        // Take a reference to the data contained inside the box
        let _ref_to_i32: &i32 = &boxed_i32;

        // Error!
        // Can't destroy `boxed_i32` while the inner value is borrowed later in scope.
        eat_box_i32(boxed_i32);
        // FIXME ^ Comment out this line

        // Attempt to borrow `_ref_to_i32` after inner value is destroyed
        borrow_i32(_ref_to_i32);
        // `_ref_to_i32` goes out of scope and is no longer borrowed.
    }

    // `boxed_i32` can now give up ownership to `eat_box` and be destroyed
    eat_box_i32(boxed_i32);
}

debug log:

solving 06cde0e79e2 ...
found 06cde0e79e2 in https://yhetil.org/emacs/2a710b11-4e3c-3103-19ee-cf313526ad63@yandex.ru/
found 081d0d7d4df in https://git.savannah.gnu.org/cgit/emacs.git
preparing index
index prepared:
100644 081d0d7d4df4463409adcaead7926980d0207d92	test/manual/etags/rs-src/test.rs

applying [1/1] https://yhetil.org/emacs/2a710b11-4e3c-3103-19ee-cf313526ad63@yandex.ru/
diff --git a/test/manual/etags/rs-src/test.rs b/test/manual/etags/rs-src/test.rs
index 081d0d7d4df..06cde0e79e2 100644

Checking patch test/manual/etags/rs-src/test.rs...
Applied patch test/manual/etags/rs-src/test.rs cleanly.

index at:
100644 06cde0e79e2fc82a67e3ce1c508187b804da82f0	test/manual/etags/rs-src/test.rs

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.