#voting #poll #vote #judgment

majority

A crate to manage majority judgment polls

16 releases

0.1.15 Jul 30, 2024
0.1.14 Mar 2, 2024
0.1.13 Jul 16, 2023
0.1.12 Mar 29, 2023

#2 in #vote

Download history 1/week @ 2024-06-27 22/week @ 2024-07-04 183/week @ 2024-07-25 41/week @ 2024-08-01 11/week @ 2024-09-12 26/week @ 2024-09-19 15/week @ 2024-09-26 1/week @ 2024-10-03

53 downloads per month

Unlicense

16KB
370 lines

majority

Rust crate to manage Majority Judgment polls
https://electowiki.org/wiki/Majority_Judgment

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)?;
}

Dependencies

~22MB
~427K SLoC