summary refs log tree commit diff
path: root/src/libstd/path/posix.rs
AgeCommit message (Collapse)AuthorLines
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-2/+2
value
2014-03-23auto merge of #13090 : thestinger/rust/iter, r=Aatchbors-10/+10
This has been rendered obsolete by partial type hints. Since the `~[T]` type is in the process of being removed, it needs to go away.
2014-03-23iter: remove `to_owned_vec`Daniel Micay-10/+10
This needs to be removed as part of removing `~[T]`. Partial type hints are now allowed, and will remove the need to add a version of this method for `Vec<T>`. For now, this involves a few workarounds for partial type hints not completely working.
2014-03-23use TotalEq for HashMapDaniel Micay-1/+3
Closes #5283
2014-03-20rename std::vec -> std::sliceDaniel Micay-8/+8
Closes #12702
2014-03-12std: allow io::File* structs to be hashableErick Tryzelaar-3/+3
2014-03-12Use generic impls for `Hash`Erick Tryzelaar-4/+4
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-1/+1
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-35/+35
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-27std: Small cleanup and test improvementAlex Crichton-2/+2
This weeds out a bunch of warnings building stdtest on windows, and it also adds a check! macro to the io::fs tests to help diagnose errors that are cropping up on windows platforms as well. cc #12516
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-4/+4
2014-02-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-07Rewrite path::Display to reduce unnecessary allocationKevin Ballard-12/+4
2014-02-06Remove std::conditionAlex Crichton-74/+12
This has been a long time coming. Conditions in rust were initially envisioned as being a good alternative to error code return pattern. The idea is that all errors are fatal-by-default, and you can opt-in to handling the error by registering an error handler. While sounding nice, conditions ended up having some unforseen shortcomings: * Actually handling an error has some very awkward syntax: let mut result = None; let mut answer = None; io::io_error::cond.trap(|e| { result = Some(e) }).inside(|| { answer = Some(some_io_operation()); }); match result { Some(err) => { /* hit an I/O error */ } None => { let answer = answer.unwrap(); /* deal with the result of I/O */ } } This pattern can certainly use functions like io::result, but at its core actually handling conditions is fairly difficult * The "zero value" of a function is often confusing. One of the main ideas behind using conditions was to change the signature of I/O functions. Instead of read_be_u32() returning a result, it returned a u32. Errors were notified via a condition, and if you caught the condition you understood that the "zero value" returned is actually a garbage value. These zero values are often difficult to understand, however. One case of this is the read_bytes() function. The function takes an integer length of the amount of bytes to read, and returns an array of that size. The array may actually be shorter, however, if an error occurred. Another case is fs::stat(). The theoretical "zero value" is a blank stat struct, but it's a little awkward to create and return a zero'd out stat struct on a call to stat(). In general, the return value of functions that can raise error are much more natural when using a Result as opposed to an always-usable zero-value. * Conditions impose a necessary runtime requirement on *all* I/O. In theory I/O is as simple as calling read() and write(), but using conditions imposed the restriction that a rust local task was required if you wanted to catch errors with I/O. While certainly an surmountable difficulty, this was always a bit of a thorn in the side of conditions. * Functions raising conditions are not always clear that they are raising conditions. This suffers a similar problem to exceptions where you don't actually know whether a function raises a condition or not. The documentation likely explains, but if someone retroactively adds a condition to a function there's nothing forcing upstream users to acknowledge a new point of task failure. * Libaries using I/O are not guaranteed to correctly raise on conditions when an error occurs. In developing various I/O libraries, it's much easier to just return `None` from a read rather than raising an error. The silent contract of "don't raise on EOF" was a little difficult to understand and threw a wrench into the answer of the question "when do I raise a condition?" Many of these difficulties can be overcome through documentation, examples, and general practice. In the end, all of these difficulties added together ended up being too overwhelming and improving various aspects didn't end up helping that much. A result-based I/O error handling strategy also has shortcomings, but the cognitive burden is much smaller. The tooling necessary to make this strategy as usable as conditions were is much smaller than the tooling necessary for conditions. Perhaps conditions may manifest themselves as a future entity, but for now we're going to remove them from the standard library. Closes #9795 Closes #8968
2014-02-02std,extra: remove use of & support for @[].Huon Wilson-8/+0
2014-02-02libextra: Remove `@str` from all the librariesPatrick Walton-2/+0
2014-01-29auto merge of #11893 : Armavica/rust/copyable-cloneable, r=huonwbors-3/+3
I found awkward to have `MutableCloneableVector` and `CloneableIterator` on the one hand, and `CopyableVector` etc. on the other hand. The concerned traits are: * `CopyableVector` --> `CloneableVector` * `OwnedCopyableVector` --> `OwnedCloneableVector` * `ImmutableCopyableVector` --> `ImmutableCloneableVector` * `CopyableTuple` --> `CloneableTuple`
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-2/+2
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-1/+1
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-2/+2
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-3/+3
behavior
2014-01-21[std::vec] Rename .pop_opt() to .pop(), drop the old .pop() behaviorSimon Sapin-1/+1
2014-01-18Expose platform independent path separatorsErick Tryzelaar-19/+21
2014-01-18Rename iterators for consistencyPalmer Cox-11/+11
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-3/+10
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-3/+2
2014-01-07std: Fill in all missing importsAlex Crichton-1/+2
Fallout from the previous commits
2013-12-30Add more benchmark tests to path/posixg3xzh-0/+41
Benchmark testing `is_ancestor_of` and `path_relative_from`
2013-12-11Make 'self lifetime illegal.Erik Price-7/+7
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-171/+171
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-12-04std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter.Huon Wilson-3/+3
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-171/+171
2013-11-27Add benchmark tests to path/posixg3xzh-0/+86
I have written some benchmark tests to `push`, `push_many`, `join`, `join_many` and `ends_with_path`.
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-23/+22
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-33/+33
2013-11-24Remove linked failure from the runtimeAlex Crichton-1/+0
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-1/+1
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-69/+0
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-10-22Remove thread-blocking call to `libc::stat` in `Path::stat`Ziad Hatahet-49/+19
Fixes #9958
2013-10-16path2: Update for privacy changesKevin Ballard-6/+0
Remove redundant `contains_nul` definition. Make `parse_prefix` private.
2013-10-16path2: Update for latest masterKevin Ballard-2/+2
Also fix some issues that crept into earlier commits during the conflict resoution for the rebase.
2013-10-16path2: Remove Path.into_str()Kevin Ballard-7/+0
2013-10-16path2: Remove some API functionsKevin Ballard-218/+27
Delete the following API functions: - set_dirname() - with_dirname() - set_filestem() - with_filestem() - add_extension() - file_path() Also change pop() to return a boolean instead of an owned copy of the old filename.
2013-10-16path2: Update based on more review feedbackKevin Ballard-80/+51
Standardize the is_sep() functions to be the same in both posix and windows, and re-export from path. Update extra::glob to use this. Remove the usage of either, as it's going away. Move the WindowsPath-specific methods out of WindowsPath and make them top-level functions of path::windows instead. This way you cannot accidentally write code that will fail to compile on non-windows architectures without typing ::windows anywhere. Remove GenericPath::from_c_str() and just impl BytesContainer for CString instead. Remove .join_path() and .push_path() and just implement BytesContainer for Path instead. Remove FilenameDisplay and add a boolean flag to Display instead. Remove .each_parent(). It only had one caller, so just inline its definition there.
2013-10-15path2: Remove .with_display_str and friendsKevin Ballard-44/+47
Rewrite these methods as methods on Display and FilenameDisplay. This turns do path.with_display_str |s| { ... } into do path.display().with_str |s| { ... }
2013-10-15path2: Adjust the API to remove all the _str mutation methodsKevin Ballard-318/+300
Add a new trait BytesContainer that is implemented for both byte vectors and strings. Convert Path::from_vec and ::from_str to one function, Path::new(). Remove all the _str-suffixed mutation methods (push, join, with_*, set_*) and modify the non-suffixed versions to use BytesContainer.
2013-10-15path2: Remove Path::normalize()Kevin Ballard-1/+1
There are no clients of this API, so just remove it. Update the module docstring to mention normalization.
2013-10-15path2: Update for loop -> continueKevin Ballard-1/+1
2013-10-15path2: Update asserts for new format!() styleKevin Ballard-10/+12
2013-10-15path2: Replace the path module outrightKevin Ballard-0/+1668
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.