-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathmain.rs
More file actions
79 lines (66 loc) · 1.26 KB
/
main.rs
File metadata and controls
79 lines (66 loc) · 1.26 KB
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
use std::ops::*;
#[derive(Debug, Copy, Clone)]
struct S;
mod lib;
impl Neg for S {
type Output = Self;
fn neg(self) -> Self {
S
}
}
impl Add for S {
type Output = Self;
fn add(self, rhs: Self) -> Self {
S
}
}
impl Index<usize> for S {
type Output = S;
fn index(&self, index: usize) -> &Self::Output {
&S
}
}
mod M1 {
pub mod M2 {
pub struct S;
impl S {
pub fn method(self) -> Self {
S
}
}
}
pub struct S2<T>(T);
impl<T> S2<T> {
pub fn new(x: T) -> Self {
S2(x)
}
}
}
fn main() {
let width = 4;
let precision = 2;
let value = 10;
println!("Value {value:#width$.precision$}", value = 10.5);
println!("Value {0:#1$.2$}", value, width, precision);
println!("Value {} {}", value, width);
let people = "Rustaceans";
println!("Hello {people}!");
println!("{1} {} {0} {}", 1, 2);
assert_eq!(format!("Hello {:<5}!", "x"), "Hello x !");
let x = S;
let s = M1::M2::S;
s.method();
M1::S2::<S>::new(S);
-S;
S + S;
#[rustfmt::skip]
let x = S+S;
#[rustfmt::skip]
let x = S
+S;
#[rustfmt::skip]
let x = S
+
S;
S[0];
}