From 0d81887e0b448598d35e20e557ec1916a3352b7c Mon Sep 17 00:00:00 2001 From: mfrischknecht Date: Sun, 28 Apr 2024 01:22:18 +0200 Subject: [PATCH] Fix ambiguous call to `constraints.as_ref()` (#22) If `fast-ssh` is built with an up-to-date version of `rustc`, the compiler complains about `constraints.as_ref()` being ambiguous, demanding the types involved in the `.constraints()` call be clarified with a `::<&[Constraint]>` turbofish annotation: ``` Compiling fast-ssh v0.3.1 (/build/source) error[E0283]: type annotations needed --> src/layout.rs:60:10 | 60 | .constraints(constraints.as_ref()) | ^^^^^^^^^^^ ------ type must be known at this point | | | cannot infer type of the type parameter `C` declared on the method `constraints` | = note: multiple `impl`s satisfying `Vec: AsRef<_>` found in the `alloc` crate: - impl AsRef> for Vec where A: Allocator; - impl AsRef<[T]> for Vec where A: Allocator; help: consider specifying the generic argument | 60 | .constraints::<&T>(constraints.as_ref()) | ++++++ For more information about this error, try `rustc --explain E0283`. error: could not compile `fast-ssh` (bin "fast-ssh") due to previous error ``` Luckily, if we use `constraints.as_slice()` instead, the types involved are still apparent to the compiler, and the resulting code still remains about as readable as before. --- src/layout.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/layout.rs b/src/layout.rs index d12dffb..68eb54c 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -57,7 +57,7 @@ pub fn create_layout(app: &App, frame: &mut Frame>) -> .direction(Direction::Horizontal) .margin(1) .horizontal_margin(0) - .constraints(constraints.as_ref()) + .constraints(constraints.as_slice()) .split(base_chunk[1]); AppLayout {