File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,30 @@ module! {
15
15
16
16
struct RustPrint ;
17
17
18
+ fn arc_print ( ) -> Result {
19
+ use kernel:: sync:: * ;
20
+
21
+ let a = Arc :: try_new ( 1 ) ?;
22
+ let b = UniqueArc :: try_new ( "hello, world" ) ?;
23
+
24
+ // Prints the value of data in `a`.
25
+ pr_info ! ( "{}" , a) ;
26
+
27
+ // Uses ":?" to print debug fmt of `b`.
28
+ pr_info ! ( "{:?}" , b) ;
29
+
30
+ let a: Arc < & str > = b. into ( ) ;
31
+ let c = a. clone ( ) ;
32
+
33
+ // Uses `dbg` to print, will move `c` (for temporary debugging purposes).
34
+ dbg ! ( c) ;
35
+
36
+ // Pretty-prints the debug formatting with lower-case hexadecimal integers.
37
+ pr_info ! ( "{:#x?}" , a) ;
38
+
39
+ Ok ( ( ) )
40
+ }
41
+
18
42
impl kernel:: Module for RustPrint {
19
43
fn init ( _module : & ' static ThisModule ) -> Result < Self > {
20
44
pr_info ! ( "Rust printing macros sample (init)\n " ) ;
@@ -43,6 +67,8 @@ impl kernel::Module for RustPrint {
43
67
pr_cont ! ( " is {}" , "continued" ) ;
44
68
pr_cont ! ( " with {}\n " , "args" ) ;
45
69
70
+ arc_print ( ) ?;
71
+
46
72
Ok ( RustPrint )
47
73
}
48
74
}
You can’t perform that action at this time.
0 commit comments