Uh oh!
There was an error while loading. Please reload this page.
Implement fileinput - #5202
Conversation
huonw
commented
Mar 4, 2013
@graydon I think I fixed the build failure. (Edit: I see you're already on top of it.) |
huonw
commented
Mar 4, 2013
Sorry :( (Last attempt before I give up and stop attempting to contribute while I can't test.) |
huonw
commented
Mar 9, 2013
@graydon I've finally got a computer that compiles rust in less than 2 hours, and so I've sorted out all the problems with this patch. |
graydon
commented
Mar 11, 2013
Great! I will approve it for landing, but I did actually start poking at it as promised, just ... I got side tracked and started fussing with the actual implementation. In particular I started trying to make improvements, but each one led to a more-general one:
Around that point I got sidetracked and didn't finish. Sorry. If you want to make any or all of those changes in followup patches I'd certainly appreciate it. Otherwise it'll just go on the "more refactoring to the io modules" pile-o-bugs. |
huonw
commented
Mar 11, 2013
Sorry for stepping on your toes! Do you have the partial code in a branch somewhere that I could continue off? |
graydon
commented
Mar 12, 2013
No worries. Unfortunately not, I kept deleting and restarting what I was doing. It wasn't terribly deep; the comment I wrote above is more informative than any of the half-sketch work I had done. |
huonw
commented
Mar 13, 2013
Hm, some quick questions/comments.
Do you mean
I see two useful methods: a plain In summary: I can't see a good way of designing this that allows it to be reused for
I thought about doing this before, but discarded it without actually trying (not quite sure why), but it's clearly a better solution than renaming methods; although it likely comes a performance cost due to having to scan for |
graydon
commented
Mar 15, 2013
I'm not sure why there'd be a performance cost to implementing Reader, can you elaborate? Yes on returning |
huonw
commented
Mar 15, 2013
The performance cost is just having to scan everything for Hmm, ok, not sure why I didn't follow the convention with the (with slices) letmut lines = ~[];for fileinput::input |slice :&str| {
lines.push(str::from_slice(slice))}vs. (as it is now) letmut lines = ~[];for fileinput::input |owned : ~str| {
lines.push(owned)}(Similar reasoning could be used for many of the |
graydon
commented
Mar 18, 2013
The underlying (In general, any time it seems like we're using (Also also: sorry for being picky on this and/or trying to use it as some kind of teachable moment. Your patch is good and any time you get frustrated with this conversation just say so and I'm happy to merge it in the state it's in. Any module doing something |
huonw
commented
Mar 18, 2013
Ok, I understand about I'm not getting frustrated: it's not my project and I completely understand being picky and trying to get things as you would prefer, and anyway, I really appreciate that you (and the rest of the core team) are so willing to spend the time to help me get my contributions into shape. (And, the longer the conversation goes now, the more I'll learn about the design decisions etc, so (hopefully) the shorter it'll be next time.) |
huonw
commented
Mar 25, 2013
@graydon, I've implemented I had an abortive attempt at moving away from mutable fields in Also: I've had to add 2
|
Iterate over lines in a series of files. API (mostly) adopted from Python's fileinput module.
As per https://github.com/mozilla/rust/wiki/Note-wanted-libraries. Iterates over lines in a series of files, e.g. a basic `cat` ```rust use std::fileinput; fn main() { for fileinput::input |line| { io::println(line); } } ``` The API is essentially a subset of [Python's fileinput module](http://docs.python.org/3.3/library/fileinput.html), although the lack of default arguments and global mutable state means that there are extra functions to handle a few different cases (files from command line arguments, files from a vector, accessing current filename/line number). A few points that possibly require adjustment: - Most functions take vectors of `Path` (well, `Option<Path>`) rather than just `~str`, since this seems safer, and allows finer control without the number of different functions/methods increasing exponentially. - `pathify` has a stupid name. - I'm not quite sure how to mock tests that require external files: the tests in `libcore/io.rs` seem to indicate using a `tmp` subdirectory, so that's what I did, but I can't reliably build rust on this computer to test (sorry! although I have run the tests in just `fileinput.rs` after creating `./tmp/` manually). - The documentation I've written seems pretty crappy and not particularly clear. - Only UTF8 files are supported.
…sy-float-literal-restriction, r=flip1995 Move check for lossy whole-number floats out of `excessive_precision` changelog: Add new lint `lossy_float_literal` to detect lossy whole number float literals and move it out of `excessive_precision` again. Fixesrust-lang#5201
5202: Runnable env r=matklad a=vsrs
This PR adds on option to specify (in the settings.json) environment variables passed to the runnable.
The simplest way for all runnables in a bunch:
```jsonc
"rust-analyzer.runnableEnv": {
"RUN_SLOW_TESTS": "1"
}
```
Or it is possible to specify vars more granularly:
```jsonc
"rust-analyzer.runnableEnv": [
{
// "mask": null, // null mask means that this rule will be applied for all runnables
env: {
"APP_ID": "1",
"APP_DATA": "asdf"
}
},
{
"mask": "test_name",
"env": {
"APP_ID": "2", // overwrites only APP_ID
}
}
]
```
You can use any valid RegExp as a mask. Also note that a full runnable name is something like *run bin_or_example_name*, *test some::mod::test_name* or *test-mod some::mod*, so it is possible to distinguish binaries, single tests, and test modules with this masks: `"^run"`, `"^test "` (the trailing space matters!), and `"^test-mod"` respectively.
Fixesrust-lang#4450
I suppose this info should be somewhere in the docs, but unsure where is the best place.
Co-authored-by: vsrs <vit@conrlab.com>
As per https://github.com/mozilla/rust/wiki/Note-wanted-libraries.
Iterates over lines in a series of files, e.g. a basic
catThe API is essentially a subset of Python's fileinput module, although the lack of default arguments and global mutable state means that there are extra functions to handle a few different cases (files from command line arguments, files from a vector, accessing current filename/line number).
A few points that possibly require adjustment:
Path(well,Option<Path>) rather than just~str, since this seems safer, and allows finer control without the number of different functions/methods increasing exponentially.pathifyhas a stupid name.libcore/io.rsseem to indicate using atmpsubdirectory, so that's what I did, but I can't reliably build rust on this computer to test (sorry! although I have run the tests in justfileinput.rsafter creating./tmp/manually).