{"id":13648591,"url":"https://github.com/oli-obk/rust-si","last_synced_at":"2025-05-15T04:06:20.606Z","repository":{"id":30505235,"uuid":"34059620","full_name":"oli-obk/rust-si","owner":"oli-obk","description":"a rusty `scanf` (`scan!`) and inverse of `print!` (`read!`)","archived":false,"fork":false,"pushed_at":"2025-03-11T16:14:11.000Z","size":77,"stargazers_count":193,"open_issues_count":12,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-07T22:57:19.906Z","etag":null,"topics":["io","macros","rust","scan"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oli-obk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.Apache-2.0","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-04-16T14:09:54.000Z","updated_at":"2025-04-15T00:17:39.000Z","dependencies_parsed_at":"2024-01-14T10:59:28.134Z","dependency_job_id":"ea568adc-8811-41f3-827c-6affb60182da","html_url":"https://github.com/oli-obk/rust-si","commit_stats":{"total_commits":94,"total_committers":20,"mean_commits":4.7,"dds":0.7659574468085106,"last_synced_commit":"a296156ae690cb334f26011f78a58756286d9d25"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oli-obk%2Frust-si","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oli-obk%2Frust-si/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oli-obk%2Frust-si/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oli-obk%2Frust-si/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oli-obk","download_url":"https://codeload.github.com/oli-obk/rust-si/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254270646,"owners_count":22042859,"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":["io","macros","rust","scan"],"created_at":"2024-08-02T01:04:22.504Z","updated_at":"2025-05-15T04:06:15.586Z","avatar_url":"https://github.com/oli-obk.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"![Build Status](https://github.com/oli-obk/rust-si/actions/workflows/rust.yml/badge.svg)\n[![Latest Version](https://img.shields.io/crates/v/text_io.svg)](https://crates.io/crates/text_io)\n\n\nYou can use either the `read!` macro to read a single value and return it, or\nthe `scan!` macro to read one or more values into variables. Both macros can\nalso read from a file or from memory. The `read!` macro can take any type that\nimplements `Iterator\u003cItem=u8\u003e` as an optional third argument, and the `scan!`\nmacro's arguments can be prefixed with `iter =\u003e ` where `iter` implements\n`Iterator\u003cItem=u8\u003e`.\n\n# Examples\n\n## scan! macro\n\n```rust\nuse text_io::scan;\n\n// reading from a string source\nlet i: i32;\nscan!(\"\u003cb\u003e12\u003c/b\u003e\".bytes() =\u003e \"\u003cb\u003e{}\u003c/b\u003e\", i);\nassert_eq!(i, 12);\n\n// reading multiple values from stdio\nlet a: i32;\nlet b: \u0026mut u8 = \u0026mut 5;\nscan!(\"{}, {}\", a, *b);\n```\n\n## read! macro\n\n```rust\nuse text_io::read;\n\n// read until a whitespace and try to convert what was read into an i32\nlet i: i32 = read!();\n\n// read until a whitespace (but not including it)\nlet word: String = read!(); // same as read!(\"{}\")\n\n// read until a newline (but not including it)\nlet line: String = read!(\"{}\\n\");\n\n// expect the input \"\u003cb\u003e\u003ci\u003e\" or panic\n// read until the next \"\u003c\" and return that.\n// expect the input \"/i\u003e\u003c/b\u003e\"\nlet stuff: String = read!(\"\u003cb\u003e\u003ci\u003e{}\u003c/i\u003e\u003c/b\u003e\");\n\n// reading from files\nuse std::io::Read;\nlet mut file = std::fs::File::open(\"tests/answer.txt\").unwrap().bytes().map(|ch| ch.unwrap());\nlet val: i32 = read!(\"The answer is {}!!!11einself\\n\", file);\n\n// reading from strings\nlet val: i32 = read!(\"Number: {}\", \"Number: 99\".bytes());\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foli-obk%2Frust-si","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foli-obk%2Frust-si","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foli-obk%2Frust-si/lists"}