Skip to content

small feature request for foldmap #75367

@zhibo501

Description

@zhibo501

Hi guys,

Is it possible to implement foldmap function for Iterator?

Like this:

fn funny(v: Vec<i32>) -> Vec<i32> {
	v.iter()
		.foldmap(0, |acc, x| acc + x)
		.collect()
}

which is equals to :

fn funny(v: Vec<i32>) -> Vec<i32> {
        let mut total = 0;
	v.iter()
		.map(|x| {total = total + x; total})
		.collect()
}

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions