Skip to content

Instantly share code, notes, and snippets.

@Daomephsta
Created October 17, 2019 04:18
Show Gist options
  • Save Daomephsta/b2326d2dfecb1b7c20d2be9eb859dcd4 to your computer and use it in GitHub Desktop.
Save Daomephsta/b2326d2dfecb1b7c20d2be9eb859dcd4 to your computer and use it in GitHub Desktop.
error[E0382]: use of moved value: `t`
--> src\main.rs:12:71
|
12 | let f = |t: BigRational| (num::pow::pow(t.mul(&two), 2).sub(&two)+t.mul(two)) / (num::pow::pow(t, 2).sub(BigInt::one()));
| - - ^ value used here after move
| | |
| | value moved here
| move occurs because `t` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `t`
--> src\main.rs:12:100
|
12 | let f = |t: BigRational| (num::pow::pow(t.mul(&two), 2).sub(&two)+t.mul(two)) / (num::pow::pow(t, 2).sub(BigInt::one()));
| - - ^ value used here after move
| | |
| | value moved here
| move occurs because `t` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
error[E0382]: use of moved value: `b`
--> src\main.rs:17:19
|
9 | let b = BigRational::from_i64(3).unwrap();
| - move occurs because `b` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
17 | let dx = (b-a) / n;
| ^ value used here after move
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| - value moved here, in previous iteration of loop
error[E0382]: use of moved value: `a`
--> src\main.rs:17:21
|
8 | let a = BigRational::from_i64(2).unwrap();
| - move occurs because `a` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
17 | let dx = (b-a) / n;
| ^ value used here after move
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| - value moved here, in previous iteration of loop
error[E0382]: use of moved value: `a`
--> src\main.rs:21:46
|
8 | let a = BigRational::from_i64(2).unwrap();
| - move occurs because `a` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
17 | let dx = (b-a) / n;
| - value moved here
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| ^ value used here after move
error[E0382]: use of moved value: `b`
--> src\main.rs:21:52
|
9 | let b = BigRational::from_i64(3).unwrap();
| - move occurs because `b` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
17 | let dx = (b-a) / n;
| - value moved here
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| ^ value used here after move
error[E0382]: use of moved value: `dx`
--> src\main.rs:21:55
|
17 | let dx = (b-a) / n;
| -- move occurs because `dx` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| -- ^^ value used here after move
| |
| value moved here
error[E0382]: use of moved value: `dx`
--> src\main.rs:23:32
|
17 | let dx = (b-a) / n;
| -- move occurs because `dx` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
...
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| -- value moved here
22 | {
23 | let avg_t = (t_i - dx + t_i).div(two);
| ^^ value moved here, in previous iteration of loop
error[E0382]: use of moved value: `t_i`
--> src\main.rs:23:37
|
21 | for t_i in num::range_step_inclusive(a+dx, b, dx)
| --- move occurs because `t_i` has type `num_rational::Ratio<num_bigint::bigint::BigInt>`, which does not implement the `Copy` trait
22 | {
23 | let avg_t = (t_i - dx + t_i).div(two);
| --- ^^^ value used here after move
| |
| value moved here
error[E0382]: use of moved value: `two`
--> src\main.rs:23:46
|
11 | let two = BigInt::from(2);
| --- move occurs because `two` has type `num_bigint::bigint::BigInt`, which does not implement the `Copy` trait
12 | let f = |t: BigRational| (num::pow::pow(t.mul(&two), 2).sub(&two)+t.mul(two)) / (num::pow::pow(t, 2).sub(BigInt::one()));
| ---------------- --- variable moved due to use in closure
| |
| value moved into closure here
...
23 | let avg_t = (t_i - dx + t_i).div(two);
| ^^^ value moved here, in previous iteration of loop
error[E0382]: use of moved value: `f`
--> src\main.rs:24:23
|
24 | result += f(avg_t);
| ^ value moved here, in previous iteration of loop
|
note: closure cannot be invoked more than once because it moves the variable `two` out of its environment
--> src\main.rs:12:77
|
12 | let f = |t: BigRational| (num::pow::pow(t.mul(&two), 2).sub(&two)+t.mul(two)) / (num::pow::pow(t, 2).sub(BigInt::one()));
| ^^^
error[E0382]: borrow of moved value: `n`
--> src\main.rs:27:75
|
16 | let n = num::pow::pow(BigInt::from(10), k);
| - move occurs because `n` has type `num_bigint::bigint::BigInt`, which does not implement the `Copy` trait
17 | let dx = (b-a) / n;
| - value moved here
...
27 | println!("For k={} ({} subintervals) the approximation is {}", k, n, result)
| ^ value borrowed here after move
error: aborting due to 12 previous errors
For more information about this error, try `rustc --explain E0382`.
error: Could not compile `riemann`.
To learn more, run the command again with --verbose.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment