{"id":21595182,"url":"https://github.com/euank/take_while_with_failure.rs","last_synced_at":"2025-04-11T00:06:11.837Z","repository":{"id":36440779,"uuid":"40745810","full_name":"euank/take_while_with_failure.rs","owner":"euank","description":"A rust iterator akin to `take_while` but with the failing element","archived":false,"fork":false,"pushed_at":"2015-08-15T05:15:39.000Z","size":140,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T20:51:09.169Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/euank.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-08-15T03:55:20.000Z","updated_at":"2019-04-20T13:33:49.000Z","dependencies_parsed_at":"2022-08-18T00:45:33.337Z","dependency_job_id":null,"html_url":"https://github.com/euank/take_while_with_failure.rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euank%2Ftake_while_with_failure.rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euank%2Ftake_while_with_failure.rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euank%2Ftake_while_with_failure.rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/euank%2Ftake_while_with_failure.rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/euank","download_url":"https://codeload.github.com/euank/take_while_with_failure.rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125592,"owners_count":21051771,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T17:33:35.728Z","updated_at":"2025-04-11T00:06:11.817Z","avatar_url":"https://github.com/euank.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Take While with Failure\n\nThis library implements an additional iterator for rust.\n\nCreates an iterator that yields elements as long as the predicate returns true.\nAdditionally, it includes the first element that returns false, after which no further\nelements will be yielded.\n\nThis can be useful if, for example, you would like to read a stream until the first error\nand then stop processing immediately without losing the error.\n\n## But what about itertools fold\\_results?\n\nRight after implementing this I found out that that package exists. Oops.\n\nI highly recommend using itertools'\n[fold\\_results](https://bluss.github.io/rust-itertools/doc/itertools/trait.Itertools.html#method.fold_results)\nif it is relevant.\n\n## Naming\n\nI couldn't think of a better one. If you can, feel free to pull request.\n\n## This is dumb\n\nAww, shucks, thanks. You too :heart:\n\nReally though, I'm a neophyte with rust and it's possible I overlooked something when I made this and it's in fact utterly dumb and useless. Open an issue and tell me!\n\nOh, and I do know I could have used a for loop to replace this fairly trivially. That doesn't count :grin:\n\n## Example\n\n```\nlet a = [1, 2, 3, 4, 5];\nlet mut it = a.iter().take_while_with_failure(|\u0026a| *a \u003c 2);\nassert_eq!(it.next(), Some(\u00261));\nassert_eq!(it.next(), Some(\u00262));\nassert!(it.next().is_none());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuank%2Ftake_while_with_failure.rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feuank%2Ftake_while_with_failure.rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feuank%2Ftake_while_with_failure.rs/lists"}