File: vecdeque_pop_push.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (67 lines) | stat: -rw-r--r-- 1,462 bytes parent folder | download | duplicates (2)
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
//@ compile-flags: -O

#![crate_type = "lib"]

use std::collections::VecDeque;

#[no_mangle]
// CHECK-LABEL: @noop_back(
pub fn noop_back(v: &mut VecDeque<u8>) {
    // CHECK-NOT: grow
    // CHECK: tail call void @llvm.assume
    // CHECK-NOT: grow
    // CHECK: ret
    if let Some(x) = v.pop_back() {
        v.push_back(x);
    }
}

#[no_mangle]
// CHECK-LABEL: @noop_front(
pub fn noop_front(v: &mut VecDeque<u8>) {
    // CHECK-NOT: grow
    // CHECK: tail call void @llvm.assume
    // CHECK-NOT: grow
    // CHECK: ret
    if let Some(x) = v.pop_front() {
        v.push_front(x);
    }
}

#[no_mangle]
// CHECK-LABEL: @move_byte_front_to_back(
pub fn move_byte_front_to_back(v: &mut VecDeque<u8>) {
    // CHECK-NOT: grow
    // CHECK: tail call void @llvm.assume
    // CHECK-NOT: grow
    // CHECK: ret
    if let Some(x) = v.pop_front() {
        v.push_back(x);
    }
}

#[no_mangle]
// CHECK-LABEL: @move_byte_back_to_front(
pub fn move_byte_back_to_front(v: &mut VecDeque<u8>) {
    // CHECK-NOT: grow
    // CHECK: tail call void @llvm.assume
    // CHECK-NOT: grow
    // CHECK: ret
    if let Some(x) = v.pop_back() {
        v.push_front(x);
    }
}

#[no_mangle]
// CHECK-LABEL: @push_back_byte(
pub fn push_back_byte(v: &mut VecDeque<u8>) {
    // CHECK: call {{.*}}grow
    v.push_back(3);
}

#[no_mangle]
// CHECK-LABEL: @push_front_byte(
pub fn push_front_byte(v: &mut VecDeque<u8>) {
    // CHECK: call {{.*}}grow
    v.push_front(3);
}