Debian Codegraph @

examples/sort.rs

raw symbols SCIP
1 // This is a buggy quick sort implementation, QuickCheck will find the bug for
2 // you.
3
4 use quickcheckrust-analyzer cargo quickcheck 1.1.0 crate/::quickcheckrust-analyzer cargo quickcheck 1.1.0 tester/quickcheck().;
5
6 fn smaller_thanrust-analyzer cargo quickcheck 1.1.0 smaller_than().<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(xs: &[T], pivot: &T) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> {
7 xs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|&x| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().pivot).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
8 }
9
10 fn larger_thanrust-analyzer cargo quickcheck 1.1.0 larger_than().<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(xs: &[T], pivot: &T) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> {
11 xs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|&x| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().x rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().pivot).clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().()
12 }
13
14 fn sortkrust-analyzer cargo quickcheck 1.1.0 sortk().<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(x: &T, xs: &[T]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> {
15 let mut result: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> = sortrust-analyzer cargo quickcheck 1.1.0 sort().(&smaller_thanrust-analyzer cargo quickcheck 1.1.0 smaller_than().(xs, x));
16 let last_part = sortrust-analyzer cargo quickcheck 1.1.0 sort().(&larger_thanrust-analyzer cargo quickcheck 1.1.0 larger_than().(xs, x));
17 result.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(x.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().());
18 result.extendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Extend<T>`]extend().(last_part.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().());
19 result
20 }
21
22 fn sortrust-analyzer cargo quickcheck 1.1.0 sort().<T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#>(list: &[T]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T> {
23 if list.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
24 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]
25 } else {
26 sortkrust-analyzer cargo quickcheck 1.1.0 sortk().(&list[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()., &list[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().)
27 }
28 }
29
30 fn mainrust-analyzer cargo quickcheck 1.1.0 main().() {
31 fn is_sortedrust-analyzer cargo quickcheck 1.1.0 is_sorted().(xs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<isize>) -> bool {
32 for win in sortrust-analyzer cargo quickcheck 1.1.0 sort().(&xs).windowsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]windows().(2) {
33 if win[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]gt().win[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). {
34 return false;
35 }
36 }
37 true
38 }
39
40 fn keeps_lengthrust-analyzer cargo quickcheck 1.1.0 keeps_length().(xs: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<isize>) -> bool {
41 xs.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().sortrust-analyzer cargo quickcheck 1.1.0 sort().(&xs).lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()
42 }
43 quickcheckrust-analyzer cargo quickcheck 1.1.0 tester/quickcheck().(keeps_lengthrust-analyzer cargo quickcheck 1.1.0 keeps_length(). as fn(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<isize>) -> bool);
44
45 quickcheckrust-analyzer cargo quickcheck 1.1.0 tester/quickcheck().(is_sortedrust-analyzer cargo quickcheck 1.1.0 is_sorted(). as fn(Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<isize>) -> bool);
46 }