summary refs log tree commit diff
path: root/src/libstd/c_str.rs
AgeCommit message (Collapse)AuthorLines
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-4/+3
2013-12-23std: Fix all code examplesAlex Crichton-3/+7
2013-12-20std: silence warnings when compiling test.Huon Wilson-2/+1
2013-12-19std::str: replace .as_imm_buf with .as_ptr.Huon Wilson-8/+7
2013-12-19std::vec: remove .as_muf_buf, replaced by .as_mut_ptr & .len.Huon Wilson-6/+5
2013-12-19std::vec: remove .as_imm_buf, replaced by .as_ptr & .len.Huon Wilson-9/+8
There's no need for the restrictions of a closure with the above methods.
2013-12-15std::vec: convert to(_mut)_ptr to as_... methods on &[] and &mut [].Huon Wilson-1/+1
2013-12-15std::vec: remove unnecessary count parameter on {bytes,Huon Wilson-1/+1
raw}::copy_memory. Slices carry their length with them, so we can just use that information.
2013-12-11Make 'self lifetime illegal.Erik Price-5/+5
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-04std::str: s/from_utf8_slice/from_utf8/, to make the basic case shorter.Huon Wilson-1/+1
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-54/+42
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-10/+10
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-8/+3
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-04docs: Replace std::iterator with std::iter.Huon Wilson-1/+1
2013-10-24Remove IoFactoryObject for ~IoFactoryAlex Crichton-1/+3
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-24Remove rt::io::supportAlex Crichton-0/+43
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-22Drop the '2' suffix from logging macrosAlex Crichton-4/+4
Who doesn't like a massive renaming?
2013-09-30std: Remove usage of fmt!Alex Crichton-4/+4
2013-09-26std: simplify vec.with_c_strErick Tryzelaar-28/+20
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-26std: add micro optimization to vec.with_c_str_uncheckedErick Tryzelaar-0/+47
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-26std: Up vec.with_c_str's stack buffer to 128Erick Tryzelaar-1/+1
This matches @graydon's recommendation.
2013-09-26std: Remove an unnecessary comment from c_strErick Tryzelaar-3/+0
The documentation for `.with_c_str()` already says that the pointer will be deallocated before returning from the function.
2013-09-26std: Micro-optimize vec.with_c_str for short vectorsErick Tryzelaar-14/+52
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-26std: Add benchmarks to c_strErick Tryzelaar-0/+103
2013-09-26std: implement Container for CStringErick Tryzelaar-2/+10
2013-09-25rustdoc: Change all code-blocks with a scriptAlex Crichton-4/+4
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-20auto merge of #9276 : alexcrichton/rust/dox, r=brsonbors-0/+52
Hopefull this will make our libstd docs appear a little more "full".
2013-09-18Register new snapshotsAlex Crichton-3/+1
2013-09-17Document a few undocumented modules in libstdAlex Crichton-0/+52
Hopefull this will make our libstd docs appear a little more "full".
2013-09-16switch Drop to `&mut self`Daniel Micay-1/+1
2013-09-15c_str: Add new method .as_str() -> Option<&str>Kevin Ballard-3/+74
Also rustify .as_bytes(), so it no longer calls libc::strlen() and is inlineable.
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-2/+2
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-04Added explicit pub to several conditions. Enables completion of #6009.Felix S. Klock II-3/+3
2013-09-03Fixes #8881. condition! imports parent's pub identifiersjmgrosen-0/+2
2013-08-27Remove offset_inbounds for an unsafe offset functionAlex Crichton-2/+2
2013-08-22Enabled unit tests in std and extra.Vadim Chugunov-2/+0
2013-08-19Add externfn macro and correctly label fixed_stack_segmentsNiko Matsakis-0/+8
2013-08-15Make CString.iter() publicKevin Ballard-1/+1
2013-08-15Add ToCStr method .with_c_str()Kevin Ballard-0/+23
.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-15Check for interior nulls in .to_c_str()Kevin Ballard-12/+99
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-14Clarify docs on CString.unwrap()Kevin Ballard-0/+1
CString.unwrap() drops ownership of the buffer on the floor. Put this in the docs.
2013-08-07std: fix a bad type cast for in str.to_c_str()Erick Tryzelaar-1/+1
2013-08-07std: Make CString::new unsafe b/c it can mutate a *T ptrErick Tryzelaar-2/+2
2013-08-07std: remove unnecessary test from c_str.drop and use safer transmuteErick Tryzelaar-2/+2
2013-08-07std: Fix c_str.iter() and add testErick Tryzelaar-3/+20
2013-08-05std: c_str should use regions on methodsErick Tryzelaar-3/+3
2013-08-04std: Update the c_str docs, and support CString not owning the pointerErick Tryzelaar-138/+63
2013-08-04std: replace str::as_c_str with std::c_strErick Tryzelaar-0/+291