question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support type inference for fold, method and array

See original GitHub issue

example: fold

let a = vec![1, 2, 3];

// the sum of all of the elements of a
let sum = a.iter().fold(0, |acc/*: {int} (should be)*/, &x| acc + x);

assert_eq!(sum, 6);

example: method

let a = vec!["1", "2", "4"];

// the sum of all of the elements of a
let as_strings = a.iter().map(ToString::to_string);
    //^ Map<Iter<&str>, ToString::to_string> (should be)

example: array

let a = ["1", "2", "4"];

// the sum of all of the elements of a
let iter = a.iter();
    //^ Iter<&str> (should be)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
vlad20012commented, Sep 23, 2017

“array” issue was fixed by #1664 “method” will be fixed by #1767 “fold” seems to work now, but I don’t completely know what commit fixed it

1reaction
vlad20012commented, Aug 12, 2017

@farodin91 Uh, now understand. Your example was too ambigous =) Yes, acc inference faild. Ok

Read more comments on GitHub >

github_iconTop Results From Across the Web

A type inference pattern · Issue #91 · gcanti/fp-ts - GitHub
The current implementation of foldMap has some type inference issues. import * as option from 'fp-ts/lib/Option' import * as array from ...
Read more >
Type Inference by Example, Part 7 | by Joakim Ahnfelt-Rønne
The first thing we need to do is to create an environment recursiveEnvironment that's only for checking the mutually recursive functions. In ...
Read more >
Generic type inference in function from lists - dart
This is basically Dart List.fold vs List.reduce type inference, but in your case you could sidestep the problem by making your function an ......
Read more >
Documentation - Type Inference - TypeScript
This kind of inference takes place when initializing variables and members, setting parameter default values, and determining function return types.
Read more >
Type inference - Swift by Sundell
An introduction to Swift's type inference system, how it makes the syntax of the language so lightweight, and how to work around some...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found