These are chat archives for rust-lang/rust

6th
Oct 2018
trsh
@trsh
Oct 06 2018 11:44
path_string.replace(format!("{{}}", idx)
How to escape outer {} ?
red75prime
@red75prime
Oct 06 2018 11:45
format!("{{{}}}", idx)
trsh
@trsh
Oct 06 2018 11:46
mkay
btw replace is not working for string, not impl
Sylwester Rąpała
@xoac
Oct 06 2018 11:48
Add '&' before format
D'Silva
@evnix
Oct 06 2018 11:54
Does anyone know how to use a BufReader in a struct
85 | pub fileReader: BufReader,
| ^^^^^^^^^ expected 1 type argument
Lyle Mantooth
@IslandUsurper
Oct 06 2018 11:57
@evnix, a BufReader is really called BufReader<R>, so in the same way you'd put an Option in a struct, you need to say what type of BufReader it is.
Sylwester Rąpała
@xoac
Oct 06 2018 11:57
BufReader<T>
Lyle Mantooth
@IslandUsurper
Oct 06 2018 11:58
Specifically, R must implement Read, too. Since you're calling it fileReader, BufReader<File> is probably what you want.
You can make it a generic BufReader, but then your struct must be generic too and take that type parameter.
D'Silva
@evnix
Oct 06 2018 12:00
Thanks for explaining the reasoning behind, Now I understand!
trsh
@trsh
Oct 06 2018 12:19
@xoac string doesn't impl replace
path_string = String
Lyle Mantooth
@IslandUsurper
Oct 06 2018 12:20
But str has a replace(), so String automatically does too.
trsh
@trsh
Oct 06 2018 12:26
ahh
tnx