about summary refs log tree commit diff
path: root/src/libstd/path/mod.rs
AgeCommit message (Collapse)AuthorLines
2014-02-14Add c_str::CString.as_bytes_no_nul()Kevin Ballard-2/+1
2014-02-07Rewrite path::Display to reduce unnecessary allocationKevin Ballard-20/+12
2014-02-07Implement BytesContainer for MaybeOwnedKevin Ballard-0/+17
2014-02-07Tweak from_utf8_lossy to return a new MaybeOwned enumKevin Ballard-2/+2
MaybeOwned allows from_utf8_lossy to avoid allocation if there are no invalid bytes in the input.
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-2/+2
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-07auto merge of #12062 : kballard/rust/from_utf8_lossy, r=huonwbors-25/+2
`from_utf8_lossy()` takes a byte vector and produces a `~str`, converting any invalid UTF-8 sequence into the U+FFFD REPLACEMENT CHARACTER. The replacement follows the guidelines in §5.22 Best Practice for U+FFFD Substitution from the Unicode Standard (Version 6.2)[1], which also matches the WHATWG rules for utf-8 decoding[2]. [1]: http://www.unicode.org/versions/Unicode6.2.0/ch05.pdf [2]: http://encoding.spec.whatwg.org/#utf-8 Closes #9516.
2014-02-06Hoist path::Display on top of from_utf8_lossy()Kevin Ballard-25/+2
2014-02-06Remove std::conditionAlex Crichton-62/+23
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-03Fixing remaining warnings and errors throughoutAlex Crichton-1/+1
2014-02-03std: Remove io::io_errorAlex Crichton-1/+1
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-02-02std: rename fmt::Default to `Show`.Huon Wilson-3/+3
This is a better name with which to have a #[deriving] mode. Decision in: https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-01-28
2014-02-02std,extra: remove use of & support for @[].Huon Wilson-7/+0
2014-02-02libextra: Remove `@str` from all the librariesPatrick Walton-13/+0
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-1/+1
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-6/+6
behavior
2014-01-21[std::path] Rename .container_as_str_opt() to .container_as_str(), drop the ↵Simon Sapin-26/+5
old .container_as_str() behavior
2014-01-20auto merge of #11673 : omasanori/rust/sep-doc, r=alexcrichtonbors-2/+2
2014-01-19auto merge of #11643 : kballard/rust/path-root-path, r=ericktbors-1/+1
2014-01-20Fix misuse of character/byte in std::path.OGINO Masanori-2/+2
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-18Expose platform independent path separatorsErick Tryzelaar-0/+14
2014-01-17Make WindowsPath::new("C:foo").root_path() return Some("C:")Kevin Ballard-1/+1
2014-01-18Rename iterators for consistencyPalmer Cox-8/+8
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-07stdtest: Fix all leaked trait importsAlex Crichton-0/+1
2013-12-23std: Fix all code examplesAlex Crichton-4/+3
2013-12-11Make 'self lifetime illegal.Erik Price-8/+8
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-13/+13
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-7/+7
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-13/+13
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-3/+1
2013-11-26Removed unneccessary `_iter` suffixes from various APIsMarvin Löbel-1/+1
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-1/+1
2013-10-22Remove thread-blocking call to `libc::stat` in `Path::stat`Ziad Hatahet-223/+1
Fixes #9958
2013-10-22Drop the '2' suffix from logging macrosAlex Crichton-3/+3
Who doesn't like a massive renaming?
2013-10-16path2: Remove Path.into_str()Kevin Ballard-3/+0
2013-10-16path2: Remove some API functionsKevin Ballard-152/+4
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-105/+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-56/+63
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-247/+222
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-0/+4
There are no clients of this API, so just remove it. Update the module docstring to mention normalization.
2013-10-15path2: Write a few paragraphs of module documentationKevin Ballard-1/+54
2013-10-15path2: Update asserts for new format!() styleKevin Ballard-1/+1
2013-10-15path2: Replace the path module outrightKevin Ballard-0/+1094
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.