{"id":27928657,"url":"https://github.com/canop/rand-select","last_synced_at":"2025-05-07T02:41:11.178Z","repository":{"id":288115911,"uuid":"966914437","full_name":"Canop/rand-select","owner":"Canop","description":"A tiny, not interesting, random choice selector","archived":false,"fork":false,"pushed_at":"2025-04-15T16:36:37.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-02T14:57:20.091Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Canop.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-15T16:35:33.000Z","updated_at":"2025-04-15T18:57:06.000Z","dependencies_parsed_at":"2025-04-20T04:47:28.646Z","dependency_job_id":null,"html_url":"https://github.com/Canop/rand-select","commit_stats":null,"previous_names":["canop/rand-select"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Frand-select","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Frand-select/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Frand-select/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Frand-select/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Canop","download_url":"https://codeload.github.com/Canop/rand-select/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252802464,"owners_count":21806509,"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":"2025-05-07T02:41:10.734Z","updated_at":"2025-05-07T02:41:11.169Z","avatar_url":"https://github.com/Canop.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MIT][s2]][l2] [![Latest Version][s1]][l1] [![docs][s3]][l3] [![Chat on Miaou][s4]][l4]\n\n[s1]: https://img.shields.io/crates/v/lrand-select.svg\n[l1]: https://crates.io/crates/lrand-select\n\n[s2]: https://img.shields.io/badge/license-MIT-blue.svg\n[l2]: LICENSE\n\n[s3]: https://docs.rs/lrand-select/badge.svg\n[l3]: https://docs.rs/lrand-select/\n\n[s4]: https://miaou.dystroy.org/static/shields/room.svg\n[l4]: https://miaou.dystroy.org/3\n\nThe RandomSelector selects among weighted choices, without bias.\n\n```\nuse rand_select::RandomSelector;\nlet selector = RandomSelector::default()\n   .with(1.0, 'A')\n   .with(1.5, 'B')\n   .with_none(3.0);\nlet l = selector.select();\n// l has half a chance to be None, and is 50% more likely to be 'B' than 'A'\n```\n\nIf you set a value and call neither `with_none` nor `with_none_up_to`, the selector will always return a value.\n\nIf you have already normalized weight, `with_none_up_to` is a convenient way to set the total weight of the selector:\n\n```\nuse rand_select::RandomSelector;\nlet selector = RandomSelector::default()\n   .with(0.1, 'A')\n   .with(0.2, 'B')\n   .with_none_up_to(1.0);\n```\nThe RandomSelector is designed for reuse, and can use the RNG of your choice.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanop%2Frand-select","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanop%2Frand-select","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanop%2Frand-select/lists"}