Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inspirateur/majority
Rust crate to manage majority judgment polls
https://github.com/inspirateur/majority
crate majority-judgment majority-voting rust vote
Last synced: about 2 months ago
JSON representation
Rust crate to manage majority judgment polls
- Host: GitHub
- URL: https://github.com/inspirateur/majority
- Owner: Inspirateur
- License: unlicense
- Created: 2023-03-05T15:28:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-30T12:38:45.000Z (5 months ago)
- Last Synced: 2024-08-08T18:56:40.193Z (5 months ago)
- Topics: crate, majority-judgment, majority-voting, rust, vote
- Language: Rust
- Homepage: https://crates.io/crates/majority
- Size: 35.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# majority
Rust crate to manage Majority Judgment polls
https://electowiki.org/wiki/Majority_Judgment```rust
use majority::{Polls, Poll};
use anyhow::Result;fn poll_demo() -> Result<()> {
// variables for readability
let poll_id: u64 = 1;
let user_1: u64 = 1;
let user_2: u64 = 2;
let mut polls = Polls::new("polls.db")?;
// create a poll
polls.add_poll(
poll_id,
user_1,
"Where shall we eat tomorrow ?",
vec!["Mama's Pizza", "Mega Sushi", "The Borgir", "Mec Don Hald"],
)?;// user 2 assigns value 3 to "Mama's Pizza" (option 0)
polls.vote(poll_id, 0, user_2, 3)?;
// ... more votes ...
// get the poll results !
poll = polls.get_poll(poll_id)?;
}
```