Commit Graph

50 Commits

Author SHA1 Message Date
Simon Sapin
b8c4149293 [std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() behavior 2014-01-21 15:48:48 -08:00
Palmer Cox
3fd8c8b330 Rename iterators for consistency
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-18 01:15:15 -05:00
Alex Crichton
bcb1c381a3 stdtest: Fix all leaked trait imports 2014-01-07 23:51:38 -08:00
Alex Crichton
9f1739a8e1 std: Fix all code examples 2013-12-23 09:10:36 -08:00
Huon Wilson
c00104f36a std: silence warnings when compiling test. 2013-12-20 01:26:03 +11:00
Huon Wilson
17ac2aa523 std::str: replace .as_imm_buf with .as_ptr. 2013-12-19 10:18:02 +11:00
Huon Wilson
9177f7ecb4 std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len. 2013-12-19 10:18:02 +11:00
Huon Wilson
4c79b22ef2 std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.
There's no need for the restrictions of a closure with the above methods.
2013-12-19 09:26:13 +11:00
Huon Wilson
164f7a290e std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut []. 2013-12-15 23:37:41 +11:00
Huon Wilson
f97040a93b std::vec: remove unnecessary count parameter on {bytes,
raw}::copy_memory.

Slices carry their length with them, so we can just use that
information.
2013-12-15 22:23:11 +11:00
Erik Price
5731ca3078 Make 'self lifetime illegal.
Also remove all instances of 'self within the codebase.

This fixes #10889.
2013-12-11 10:54:06 -08:00
Huon Wilson
b0426edc0a std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter. 2013-12-04 22:35:53 +11:00
Patrick Walton
1eca34de7d libstd: Remove all non-proc uses of do from libstd 2013-11-26 08:23:57 -08:00
Patrick Walton
1946265e1a libstd: Change all uses of &fn(A)->B over to |A|->B in libstd 2013-11-19 12:40:19 -08:00
Alex Crichton
7755ffd013 Remove #[fixed_stack_segment] and #[rust_stack]
These two attributes are no longer useful now that Rust has decided to leave
segmented stacks behind. It is assumed that the rust task's stack is always
large enough to make an FFI call (due to the stack being very large).

There's always the case of stack overflow, however, to consider. This does not
change the behavior of stack overflow in Rust. This is still normally triggered
by the __morestack function and aborts the whole process.

C stack overflow will continue to corrupt the stack, however (as it did before
this commit as well). The future improvement of a guard page at the end of every
rust stack is still unimplemented and is intended to be the mechanism through
which we attempt to detect C stack overflow.

Closes #8822
Closes #10155
2013-11-11 10:40:34 -08:00
Huon Wilson
da43676e39 docs: Replace std::iterator with std::iter. 2013-11-04 10:01:00 +11:00
Alex Crichton
b46f60a729 Remove IoFactoryObject for ~IoFactory
This involved changing a fair amount of code, rooted in how we access the local
IoFactory instance. I added a helper method to the rtio module to access the
optional local IoFactory. This is different than before in which it was assumed
that a local IoFactory was *always* present. Now, a separate io_error is raised
when an IoFactory is not present, yet I/O is requested.
2013-10-24 14:21:57 -07:00
Alex Crichton
9110a38cbf Remove rt::io::support
This removes the PathLike trait associated with this "support module". This is
yet another "container of bytes" trait, so I didn't want to duplicate what
already exists throughout libstd. In actuality, we're going to pass of C strings
to the libuv APIs, so instead the arguments are now bound with the 'ToCStr'
trait instead.

Additionally, a layer of complexity was removed by immediately converting these
type-generic parameters into CStrings to get handed off to libuv apis.
2013-10-24 14:21:57 -07:00
Alex Crichton
daf5f5a4d1 Drop the '2' suffix from logging macros
Who doesn't like a massive renaming?
2013-10-22 08:09:56 -07:00
Alex Crichton
a8ba31dbf3 std: Remove usage of fmt! 2013-09-30 23:21:18 -07:00
Erick Tryzelaar
b1ee87f402 std: simplify vec.with_c_str
This also fixes a bug in `vec.with_c_str_unchecked` where we
were not calling `.to_c_str_unchecked()` for long strings.
2013-09-26 22:49:10 -07:00
Erick Tryzelaar
2d878033fd std: add micro optimization to vec.with_c_str_unchecked
before:

test c_str::bench::bench_with_c_str_unchecked_long ... bench: 361 ns/iter (+/- 9)
test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 75 ns/iter (+/- 2)
test c_str::bench::bench_with_c_str_unchecked_short ... bench: 60 ns/iter (+/- 9)

after:

test c_str::bench::bench_with_c_str_unchecked_long ... bench: 362 ns/iter (+/-
test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 30 ns/iter (+/- 7)
test c_str::bench::bench_with_c_str_unchecked_short ... bench: 12 ns/iter (+/- 4)
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
4868273d97 std: Up vec.with_c_str's stack buffer to 128
This matches @graydon's recommendation.
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
ca66b81283 std: Remove an unnecessary comment from c_str
The documentation for `.with_c_str()` already says that the pointer
will be deallocated before returning from the function.
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
e02d1eb171 std: Micro-optimize vec.with_c_str for short vectors
This now makes it unsafe to save the pointer returned by .with_c_str
as that pointer now may be pointing at a stack allocated array.

I arbitrarily chose 32 bytes as the length of the stack vector, and
so it might not be the most optimal size.

before:

test c_str::bench::bench_with_c_str_long ... bench: 539 ns/iter (+/- 91)
test c_str::bench::bench_with_c_str_medium ... bench: 97 ns/iter (+/- 2)
test c_str::bench::bench_with_c_str_short ... bench: 70 ns/iter (+/- 5)

after:

test c_str::bench::bench_with_c_str_long ... bench: 542 ns/iter (+/- 13)
test c_str::bench::bench_with_c_str_medium ... bench: 53 ns/iter (+/- 6)
test c_str::bench::bench_with_c_str_short ... bench: 19 ns/iter (+/- 0)
2013-09-26 22:20:40 -07:00
Erick Tryzelaar
410a96cc79 std: Add benchmarks to c_str 2013-09-26 22:20:40 -07:00
Erick Tryzelaar
2a9e763304 std: implement Container for CString 2013-09-26 22:20:39 -07:00
Alex Crichton
3585c64d09 rustdoc: Change all code-blocks with a script
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
    find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
    find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
2013-09-25 14:27:42 -07:00
bors
a95604fcaa auto merge of #9276 : alexcrichton/rust/dox, r=brson
Hopefull this will make our libstd docs appear a little more "full".
2013-09-20 14:11:08 -07:00
Alex Crichton
817576ee70 Register new snapshots 2013-09-18 11:07:22 -07:00
Alex Crichton
88bc11e646 Document a few undocumented modules in libstd
Hopefull this will make our libstd docs appear a little more "full".
2013-09-17 20:50:23 -07:00
Daniel Micay
4e161a4d40 switch Drop to &mut self 2013-09-16 22:19:23 -04:00
Kevin Ballard
51470f3b97 c_str: Add new method .as_str() -> Option<&str>
Also rustify .as_bytes(), so it no longer calls libc::strlen() and is
inlineable.
2013-09-15 20:30:03 -07:00
Daniel Micay
6919cf5fe1 rename std::iterator to std::iter
The trait will keep the `Iterator` naming, but a more concise module
name makes using the free functions less verbose. The module will define
iterables in addition to iterators, as it deals with iteration in
general.
2013-09-09 03:21:46 -04:00
Felix S. Klock II
83e19d2ead Added explicit pub to several conditions. Enables completion of #6009. 2013-09-04 10:03:47 +02:00
jmgrosen
4a18d46130 Fixes #8881. condition! imports parent's pub identifiers 2013-09-03 16:11:00 -07:00
Alex Crichton
e3662b1880 Remove offset_inbounds for an unsafe offset function 2013-08-27 23:22:52 -07:00
Vadim Chugunov
12ecdb6381 Enabled unit tests in std and extra. 2013-08-22 20:02:20 -07:00
Niko Matsakis
0479d946c8 Add externfn macro and correctly label fixed_stack_segments 2013-08-19 07:13:15 -04:00
Kevin Ballard
f744cf157e Make CString.iter() public 2013-08-15 01:33:10 -07:00
Kevin Ballard
03ef71e262 Add ToCStr method .with_c_str()
.with_c_str() is a replacement for the old .as_c_str(), to avoid
unnecessary boilerplate.

Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15 01:33:10 -07:00
Kevin Ballard
48265b779f Check for interior nulls in .to_c_str()
Previous dicussions about CString suggested that interior nulls should
throw an error. This was never implemented. Add this now, using a
condition (named null_byte) to allow for recovery.

Add method .to_c_str_unchecked() that skips this check.
2013-08-15 01:32:10 -07:00
Kevin Ballard
1e4f13f95f Clarify docs on CString.unwrap()
CString.unwrap() drops ownership of the buffer on the floor. Put this in
the docs.
2013-08-14 19:18:24 -07:00
Erick Tryzelaar
aababbba8e std: fix a bad type cast for in str.to_c_str() 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
72688eaa13 std: Make CString::new unsafe b/c it can mutate a *T ptr 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
d6257b315b std: remove unnecessary test from c_str.drop and use safer transmute 2013-08-07 14:06:50 -07:00
Erick Tryzelaar
e053bff5d0 std: Fix c_str.iter() and add test 2013-08-07 14:06:45 -07:00
Erick Tryzelaar
fb9b27910b std: c_str should use regions on methods 2013-08-05 19:55:07 -07:00
Erick Tryzelaar
986ba9c3c1 std: Update the c_str docs, and support CString not owning the pointer 2013-08-04 18:37:55 -07:00
Erick Tryzelaar
3102b1797e std: replace str::as_c_str with std::c_str 2013-08-04 14:13:17 -07:00