Functional Weave
Code in Rust

todo.list@1.0.0

impl/rust/clear_completed.rs

418 bytes · the Rust implementation · view raw

Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.

use super::funejson::Value;  ← the fune runtime: the JSON value the test vectors use; fune build keeps it only where a signature takes one
use super::todo_item::Todo;  ← from todo.item ^1.0.0 · built alongside by fune
use super::todo_item_validate_todo::{todos_from_value, todos_to_value};

/// Every done todo removed, the rest untouched and in order.
pub fn clear_completed(todos: &[Todo]) -> Vec<Todo> {
    todos.iter().filter(|t| !t.done).cloned().collect()
}

pub fn fune_vector(args: &[Value]) -> Value {
    todos_to_value(&clear_completed(&todos_from_value(&args[0])))
}