Skip to content

Tuple elements #6590

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 17 commits into from
Closed

Tuple elements #6590

wants to merge 17 commits into from

Conversation

brendanzab
Copy link
Member

This commit implements methods for accessing elements for for n-tuples, where n ranges from 2 to 12. The traits are re-exported in core::prelude so you can use them from regular Rust code.

Here is an example of one of the methods in use:

assert_eq!((2, "hi", 75.0)._1(), "hi");

crabtw and others added 17 commits May 7, 2013 13:17
It uses the private field of TCB head to store stack limit. I tested on my Raspberry PI. A simple hello world program ran without any problem. However, for a more complex program, it segfaulted as rust-lang#6231.
This pull request adds following methods and traits.
```rust
pub trait IteratorUtil {
(snip)
    fn filter_map<'r,  B>(self, f: &'r fn(A) -> Option<B>) -> FilterMapIterator<'r, A, B, Self>;
(snip)
    fn to_vec(self) -> ~[A];
    fn nth(&mut self, n: uint) -> A;
    fn first(&mut self) -> A;
    fn last(&mut self) -> A;
    fn fold<B>(&mut self, start: B, f: &fn(B, A) -> B) -> B;
    fn count(&mut self) -> uint;
    fn all(&mut self, f: &fn(&A) -> bool) -> bool;
    fn any(&mut self, f: &fn(&A) -> bool) -> bool;
}

pub trait AdditiveIterator<A> {
    fn sum(&mut self) -> A;
}

pub trait MultiplicativeIterator<A> {
    fn product(&mut self) -> A;
}

pub trait OrdIterator<A> {
    fn max(&mut self) -> Option<A>;
    fn min(&mut self) -> Option<A>;
}
```
@brendanzab brendanzab closed this May 18, 2013
@brendanzab
Copy link
Member Author

woops, PRed this on master

flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 6, 2025
Counting in bytes for a pointer to `u8` is legitimate and must not
trigger the lint. Also, this prevents linting the
`{std,core}::ptr::write_bytes` as it manipulates bytes.

Fix rust-lang#6590

changelog: [`size_of_in_element_count`]: do not lint if the pointee type
is `u8`
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants