Write map as for? have for return iterator?


#1
  1. In IntelliJ/Rust, when I’m writing a rust for, everything is very responsive + helpful + on the fly type inference / etc …

  2. In IntelliJ/Rust, when I’m writing a rust map ( |a, b| { ... } ), IntelliJ often freezes, for NO OBVIOUS REASON whatsoever. This is not some occasional thing, it happens with probability > 50%. (I’ve been observing this alot lately).

  3. Now, when using a Rust for, I often have to do the “collect” myself, i.e.

let mut ans = Vec::new()
for blahblah in foobar.iter() {
  ans.push(blahblahblah);
}
  1. Now, my question is: is there a way to get afor to return an iterator ?

#2

See this recent thread:


#3

I have never had IntelliJ/Rust freeze on me at any time, whether I’m using map() or not. What are you running? I’m on macOS High Sierra with 16 GB RAM using IntelliJ Community 2018.3.4 built January 28, 2019, with all boxes suitable for stable checked in the IntelliJ Languages and Frameworks Rust preferences.


#4

I’ve seen (the IntelliJ-based) CLion get incredibly slow when showing Parameter Info (shows up automatically about a second after typing the opening parenthesis of a method call, or manually with Ctrl-P). I dismiss it with Esc regularly.

This is in a 43kloc workspace.


#5

Autocomplete can also be slow, but a few seconds slow. Not long enough for me to call it a freeze. Maybe it’s my 6x smaller workspace, or perhaps I’m just more patient than @ExpHP and @zeroexcuses :smiley:.


#6
  1. Sorry, I need to clarify: IntelliJ/Rust does not “freeze” in the sense of “xkill.” By “freexe” I just mean: for a few seconds, it ignores whatever keys I am typing, then suddenly, a bunch of things happen (I’m using Vim plugin, so 5-10 keystrokes is enough to nuke the entire file).

  2. I do not know if it’s caused by auto completion, type inference or whatever, but there’s definitely this 2-3 second lag inside of map() that do not happen in for ...

  3. My machine is: (refurbished server from ebay)

free -h
              total        used        free      shared  buff/cache   available
Mem:            94G        3.1G         64G        348M         27G         89G
Swap:          4.0G          0B        4.0G

cat /proc/cpuinfo | grep "model name" | wc -l
24

cat /proc/cpuinfo | grep "model name" | head -n 1
model name      : Intel(R) Xeon(R) CPU           X5675  @ 3.07GHz

There’s no hardware reason for it to lag. I must be misconfiguring some IntelliJ/Rust option.


#7

I was right; @zeroexcuses isn’t as patient as I am :smiley:. I see the same behavior, but I don’t use the Vim plugin, nor do I type ahead as aggressively. I made the choice to turn on “Use cargo check to analyze code” in spite of the slow down. It gives me immediate (a few seconds) feedback on compile errors. Try turning it off.