Решение на (Floating) Points and Vectors от Антонио Миндов
Обратно към всички решения
Към профила на Антонио Миндов
Резултати
- 0 точки от тестове
- 0 бонус точки
- 0 точки общо
- 0 успешни тест(а)
- 0 неуспешни тест(а)
Код
Лог от изпълнението
Compiling solution v0.1.0 (/tmp/d20190123-22631-xgzx05/solution)
warning: unused variable: `target`
--> src/lib.rs:143:28
|
143 | pub fn distance(&self, target: Point) -> f64 {
| ^^^^^^ help: consider using `_target` instead
|
= note: #[warn(unused_variables)] on by default
warning: function is never used: `main`
--> src/lib.rs:155:1
|
155 | fn main() {
| ^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
warning: function `eqF64` should have a snake case name such as `eq_f64`
--> src/lib.rs:8:1
|
8 | / fn eqF64(a: f64, b: f64) -> bool {
9 | | (a - b).abs() < std::f64::EPSILON
10 | | }
| |_^
|
= note: #[warn(non_snake_case)] on by default
warning: unused variable: `target`
--> src/lib.rs:143:28
|
143 | pub fn distance(&self, target: Point) -> f64 {
| ^^^^^^ help: consider using `_target` instead
|
= note: #[warn(unused_variables)] on by default
warning: function `eqF64` should have a snake case name such as `eq_f64`
--> src/lib.rs:8:1
|
8 | / fn eqF64(a: f64, b: f64) -> bool {
9 | | (a - b).abs() < std::f64::EPSILON
10 | | }
| |_^
|
= note: #[warn(non_snake_case)] on by default
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:110:20
|
110 | assert_eq!(2.0 * v!(1.0, 2.0, 3.0), v!(2.0, 4.0, 6.0));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:111:24
|
111 | assert_eq!(1.0/2.0 * v!(1.0, 2.0, 3.0), v!(0.5, 1.0, 1.5));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:112:20
|
112 | assert_eq!(0.0 * v!(13.5, 3.333333, PI), v!(0.0, 0.0, 0.0));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error[E0308]: mismatched types
--> tests/solution_test.rs:11:51
|
11 | macro_rules! v { ($x:expr, $y:expr, $z:expr) => { Vector::new($x, $y, $z) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
...
119 | assert_eq!(v!(1.0, 1.0, 1.0) * v!(2.0, 2.0, 2.0), 6.0);
| ----------------- in this macro invocation
|
= note: expected type `f64`
found type `solution::Vector`
error[E0308]: mismatched types
--> tests/solution_test.rs:119:5
|
119 | assert_eq!(v!(1.0, 1.0, 1.0) * v!(2.0, 2.0, 2.0), 6.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `solution::Vector`, found floating-point variable
|
= note: expected type `solution::Vector`
found type `{float}`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:11:51
|
11 | macro_rules! v { ($x:expr, $y:expr, $z:expr) => { Vector::new($x, $y, $z) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
...
120 | assert_eq!(v!(1.0, 2.0, 3.0) * v!(1.0, 2.0, 3.0), 14.0);
| ----------------- in this macro invocation
|
= note: expected type `f64`
found type `solution::Vector`
error[E0308]: mismatched types
--> tests/solution_test.rs:120:5
|
120 | assert_eq!(v!(1.0, 2.0, 3.0) * v!(1.0, 2.0, 3.0), 14.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `solution::Vector`, found floating-point variable
|
= note: expected type `solution::Vector`
found type `{float}`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:11:51
|
11 | macro_rules! v { ($x:expr, $y:expr, $z:expr) => { Vector::new($x, $y, $z) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
...
121 | assert_eq!(v!(0.0, 0.0, 0.0) * v!(1.0, 2.0, 3.0), 0.0);
| ----------------- in this macro invocation
|
= note: expected type `f64`
found type `solution::Vector`
error[E0308]: mismatched types
--> tests/solution_test.rs:121:5
|
121 | assert_eq!(v!(0.0, 0.0, 0.0) * v!(1.0, 2.0, 3.0), 0.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `solution::Vector`, found floating-point variable
|
= note: expected type `solution::Vector`
found type `{float}`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:11:51
|
11 | macro_rules! v { ($x:expr, $y:expr, $z:expr) => { Vector::new($x, $y, $z) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
...
122 | assert_eq!(v!(1.0, -1.5, 0.0) * v!(-1.0, 1.5, 0.0), -3.25);
| ------------------ in this macro invocation
|
= note: expected type `f64`
found type `solution::Vector`
error[E0308]: mismatched types
--> tests/solution_test.rs:122:5
|
122 | assert_eq!(v!(1.0, -1.5, 0.0) * v!(-1.0, 1.5, 0.0), -3.25);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `solution::Vector`, found floating-point variable
|
= note: expected type `solution::Vector`
found type `{float}`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:11:51
|
11 | macro_rules! v { ($x:expr, $y:expr, $z:expr) => { Vector::new($x, $y, $z) } }
| ^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
...
123 | assert_eq!(v!(1.0, -1.0, 0.0) * v!(-1.0, -1.0, 0.0), 0.0);
| ------------------- in this macro invocation
|
= note: expected type `f64`
found type `solution::Vector`
error[E0308]: mismatched types
--> tests/solution_test.rs:123:5
|
123 | assert_eq!(v!(1.0, -1.0, 0.0) * v!(-1.0, -1.0, 0.0), 0.0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `solution::Vector`, found floating-point variable
|
= note: expected type `solution::Vector`
found type `{float}`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:131:5
|
131 | assert_eq!(v!(1.0, -1.0, 0.0) ^ v!(-1.0, 1.0, 0.0), v!(0.0, 0.0, 0.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
|
= note: expected type `f64`
found type `solution::Vector`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:133:5
|
133 | assert_eq!(v!(1.0, -1.0, 0.0) ^ v!(2.0, -2.0, 0.0), v!(0.0, 0.0, 0.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
|
= note: expected type `f64`
found type `solution::Vector`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:136:5
|
136 | assert_eq!(v!(1.0, 2.0, 3.0) ^ v!(3.0, 2.0, 1.0), v!(-4.0, 8.0, -4.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
|
= note: expected type `f64`
found type `solution::Vector`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:137:5
|
137 | assert_eq!(v!(1.0, 1.0, 0.0) ^ v!(1.0, 2.0, 0.0), v!(0.0, 0.0, 1.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
|
= note: expected type `f64`
found type `solution::Vector`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0308]: mismatched types
--> tests/solution_test.rs:138:5
|
138 | assert_eq!(v!(-1.0, 1.0, 0.0) ^ v!(-1.0, 2.0, 0.0), v!(0.0, 0.0, -1.0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected f64, found struct `solution::Vector`
|
= note: expected type `f64`
found type `solution::Vector`
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:145:29
|
145 | assert_eq!((EPS/1000.0) * v!(1.0, 1.0, 1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:146:29
|
146 | assert_ne!((EPS*1000.0) * v!(1.0, 1.0, 1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:148:29
|
148 | assert_eq!((EPS/1000.0) * v!(-1.0, -1.0, -1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:149:29
|
149 | assert_ne!((EPS*1000.0) * v!(-1.0, -1.0, -1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:151:30
|
151 | assert_eq!((-EPS/1000.0) * v!(1.0, 1.0, 1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:152:30
|
152 | assert_ne!((-EPS*1000.0) * v!(1.0, 1.0, 1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:154:30
|
154 | assert_eq!((-EPS/1000.0) * v!(-1.0, -1.0, -1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `f64`
--> tests/solution_test.rs:155:30
|
155 | assert_ne!((-EPS*1000.0) * v!(-1.0, -1.0, -1.0), v!(0.0, 0.0, 0.0));
| ^ no implementation for `f64 * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `f64`
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:226:58
|
226 | assert_eq!(Line::from_pv(p, v), Line::from_pv(p, 2.0 * v));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:227:64
|
227 | assert_eq!(Line::from_pv(p, v), Line::from_pv(p, (1.0/3.0) * v));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error[E0277]: cannot multiply `solution::Vector` to `{float}`
--> tests/solution_test.rs:245:61
|
245 | assert_eq!(Line::from_pp(p1, p2), Line::from_pv(p1, 2.0 * (p1 - p2)));
| ^ no implementation for `{float} * solution::Vector`
|
= help: the trait `std::ops::Mul<solution::Vector>` is not implemented for `{float}`
error: aborting due to 29 previous errors
Some errors occurred: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
error: Could not compile `solution`.
To learn more, run the command again with --verbose.
История (1 версия и 2 коментара)
Антонио качи първо решение на 26.11.2018 16:55 (преди почти 7 години)
Това трябваше да е векторно произведение, не скаларно. Т.е.
v1 * v2 = f64
щеше да еimpl Mul for Vector { Output = f64 }
, неBitXor
. Заv1 ^ v2 = v3
, искахме векторно произведение.