blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
179b314e7a1c9f658c9620111a09dbefec7921e3 | Rust | atwupack/shooter | /src/text.rs | UTF-8 | 342 | 2.515625 | 3 | [] | no_license | use crate::entity::EntityType::Text;
use geemu_engine::draw::Graphics;
const GLYPH_HEIGHT: u32 = 28;
const GLYPH_WIDTH: u32 = 18;
pub(crate) fn init_fonts(graphics: &mut Graphics) {
graphics.load_texture(Text, "gfx\\font.png");
}
pub(crate) fn draw_text(x: u32, y :u32, r: u8, g: u8, b: u8, text: &str, graphics:... | true |
bd3192bb462daeddee58243e1c2f56ec4db7ef5a | Rust | Gigoteur/UnicornConsole | /unicorn-rs/src/api.rs | UTF-8 | 1,952 | 2.78125 | 3 | [
"MIT"
] | permissive | use crate::raw;
pub(crate) fn bool_to_i32(val: bool) -> i32 {
match val {
true => 1,
false => 0,
}
}
fn make_wasm_text_ptr(text: &str) -> (i32, i32) {
(text.as_ptr() as i32, text.len() as i32)
}
pub fn mode_height() -> u32 {
unsafe { raw::mode_height() }
}
pub fn mode_width() -> u32 ... | true |
a83583af9365f770be1ed1c2ce82b2a1f96311be | Rust | fixrtm/diffy | /src/apply.rs | UTF-8 | 10,173 | 3.171875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::{
patch::{Hunk, Line, Patch},
utils::LineIter,
};
use std::collections::VecDeque;
use std::{fmt, iter};
/// An error returned when [`apply`]ing a `Patch` fails
///
/// [`apply`]: fn.apply.html
#[derive(Debug)]
pub struct ApplyError(usize);
impl fmt::Display for ApplyError {
fn fmt(&self, f: &mu... | true |
386dca6cecefbc15965c65690b2f9e7e8fc263ba | Rust | pearzl/leetcode_rust | /src/answer/q0040_combination_sum_ii.rs | UTF-8 | 1,442 | 3.375 | 3 | [] | no_license | // q0040_combination_sum_ii
struct Solution;
impl Solution {
pub fn combination_sum2(candidates: Vec<i32>, target: i32) -> Vec<Vec<i32>> {
let mut candidates = candidates;
candidates.sort_unstable();
let mut ret = vec![];
let mut tmp = vec![];
Solution::solve(&candidates, t... | true |
91d0cc7258bb2705f645c5e057d1549943fd22f7 | Rust | toasty-toast/advent-of-code-2020 | /src/day-13.rs | UTF-8 | 1,152 | 2.75 | 3 | [] | no_license | mod utils;
fn main() {
let input_lines = utils::read_puzzle_input();
let earliest_departure = input_lines[0].parse::<i32>().unwrap();
let bus_ids: Vec<i32> = input_lines[1]
.split(",")
.map(|id| match id {
"x" => -1,
_ => id.parse::<i32>().unwrap(),
})
... | true |
f3d06ef768acc39ac96b71be2be7b2e11dee719c | Rust | DougLau/earthwyrm | /earthwyrm/src/layer.rs | UTF-8 | 8,777 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // layer.rs
//
// Copyright (c) 2019-2022 Minnesota Department of Transportation
//
use crate::config::LayerCfg;
use crate::error::{Error, Result};
use mvt::GeomType;
use osmpbfreader::Tags;
/// Max zoom level
const ZOOM_MAX: u32 = 30;
/// Layer rule definition
pub struct LayerDef {
/// Layer name
name: Stri... | true |
ace0767ccbf76014cfdc3312b8b31294df1e42a5 | Rust | pk-codebox-evo/rust-rosetta | /src/lib.rs | UTF-8 | 4,921 | 3.25 | 3 | [
"Unlicense"
] | permissive | //! Library that contains utility functions for tests.
//!
//! It also contains a test module, which checks if all source files are covered by `Cargo.toml`
extern crate hyper;
extern crate regex;
extern crate rustc_serialize;
pub mod rosetta_code;
use std::fmt::Debug;
/// Implementation detail of the `test_sort` ma... | true |
1b0a4055a4d4d00fd433a93e9a64d943de84c1a0 | Rust | Richard70NL/rich_lib | /src/tests/lines_for_string_tests.rs | UTF-8 | 6,861 | 3.046875 | 3 | [
"MIT"
] | permissive | /************************************************************************************************/
/************************************************************************************************/
/************************************************************************************************/
use crate::lines::*;
u... | true |
9480eebc49b53114ea8b68b738a93b0fcd3c3692 | Rust | Shizcow/emoji-rs | /generate/src/gen_lib.rs | UTF-8 | 2,280 | 2.578125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::group_subgroup::Group;
use std::process::Command;
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
use proc_macro2::TokenStream;
use quote::quote;
use crate::sanitize;
pub fn dump(groups: &Vec<Group>, annotation_langs: &Vec<&str>, version: f32, date: String) {
let mut fs = String::... | true |
c8388944eca02040b6052ccef88a3671ac5e258c | Rust | TannerRogalsky/tension | /client/src/states/lobby.rs | UTF-8 | 4,408 | 2.640625 | 3 | [] | no_license | use super::StateContext;
use shared::viewer::*;
use shared::CustomMessage;
use solstice_2d::Stroke;
#[derive(Debug)]
pub struct Lobby {
local_user: shared::viewer::User,
room: InitialRoomState,
}
impl Lobby {
pub fn new(local_user: User, room: InitialRoomState) -> Self {
Self { local_user, room }
... | true |
e2aa66959a45500e441dde0772dce8e80d2549f7 | Rust | grubertw/dds-omg | /src/rtps/messages/submessage/heartbeat.rs | UTF-8 | 1,952 | 2.75 | 3 | [] | no_license | // Copyright © Travis Gruber 2017, All Rights Reserved.
/*!
This (sub) message is sent from the RTPS writer to communicate
the changes in sequence numbers that it has available, to the reader.
*/
use rtps::messages::submessage::header::*;
use rtps::messages::submessage::element::*;
pub struct Heartbeat {
header: ... | true |
68014ebedf0c31374f492e7583060c7580a132aa | Rust | kalleakerblom/AdventOfCode2019 | /src/day15.rs | UTF-8 | 4,839 | 3.109375 | 3 | [] | no_license | use super::int_code::Program;
use std::collections::{HashMap, HashSet, VecDeque};
#[derive(Debug, PartialEq)]
enum Tile {
Floor,
Wall,
Oxygen,
}
#[derive(Copy, Clone)]
enum Dir {
N,
E,
S,
W,
}
struct Robot {
program: Program,
pos: (i32, i32),
}
impl Robot {
fn move_dir(&mut self,... | true |
de19ffdb8f886b20d16c8cbd87c58fea3e2eaf98 | Rust | ddmin/CodeSnippets | /Project-Euler/euler09.rs | UTF-8 | 1,571 | 3.6875 | 4 | [] | no_license | enum Loop {
Within,
Looped,
}
#[derive(Copy, Clone)]
struct LoopedInt {
curr: i32,
lower: i32,
upper: i32,
}
impl LoopedInt {
fn new(curr: i32, lower: i32, upper: i32) -> LoopedInt {
LoopedInt { curr, lower, upper }
}
fn get(self) -> i32 {
self.curr
}
fn next(... | true |
27984f8908d9606625526ac89c6ef38acf8d1108 | Rust | tpayne84/proxide | /src/ui/sub_views/table_view.rs | UTF-8 | 9,181 | 2.6875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crossterm::event::KeyModifiers;
use std::borrow::Cow;
use tui::backend::Backend;
use tui::layout::Constraint;
use tui::style::{Modifier, StyleDiff};
use tui::widgets::{Row, Table, TableState};
use uuid::Uuid;
use super::super::prelude::*;
use crate::session::IndexedVec;
use crate::ui::filters::{FilterState, Filter... | true |
65a07a544f8041604864ecd9b8dd9ded50ab5af7 | Rust | RamiHg/soundio-rs | /src/lib.rs | UTF-8 | 8,604 | 3.515625 | 4 | [
"MIT"
] | permissive | //! # soundio-rs
//!
//! The soundio-rs crate is a wrapper for [libsoundio](http://libsound.io/).
//!
//! The API closely follows the libsoundio so it is fairly low level but much safer.
//! Most of the libsoundio API is exposed.
//!
//! Some examples are included that are roughly equivalent to the examples in libsound... | true |
bee554a17ead9e1db0842aa64fa44372a6801122 | Rust | niranjana687/30-days-of-rust | /vowel-recognition/src/main.rs | UTF-8 | 1,343 | 3.09375 | 3 | [] | no_license | // use std::io;
// fn main() {
// let mut num = String::new();
// io::stdin().read_line(&mut num).unwrap();
// let num = num.trim().parse::<u32>().expect("invalid input");
// let mut user_input = String::new();
// let mut adder = String::new();
// for i in 0..num {
// user_input.a... | true |
f4cd51685a541d32fda88c6dabb5adbb07904b98 | Rust | royswale/leetcode | /src/bin/symmetric-tree.rs | UTF-8 | 2,851 | 3.59375 | 4 | [
"MIT"
] | permissive | fn main() {
let root = Some(Rc::new(RefCell::new(TreeNode {
val: 1,
left: Some(Rc::new(RefCell::new(TreeNode {
val: 2,
left: Some(Rc::new(RefCell::new(TreeNode {
val: 3,
left: None,
right: None,
}))),
rig... | true |
e74ac5ce2ee223f0184652c9cd66bcf5203d47cd | Rust | oc-soft/glrs | /src/wasm/vector.rs | UTF-8 | 3,832 | 2.796875 | 3 | [] | no_license | use js_sys::Float32Array;
use js_sys::Float64Array;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
/// create vector
#[allow(dead_code)]
pub fn vector_create_from_vec(v: Vec<f64>) -> *const Vec<f64> {
let result = Rc::new(v);
Rc::into_raw(result)
}
/// create vector
#[allow(dead_code)]
pub fn vector_create_fr... | true |
87e6c2855055528dee7713b810003df4a764d9c2 | Rust | kim/gitoxide | /git-ref/tests/file/mod.rs | UTF-8 | 7,852 | 2.984375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use git_ref::file;
fn store() -> crate::Result<file::Store> {
let path = git_testtools::scripted_fixture_repo_read_only("make_ref_repository.sh")?;
Ok(file::Store::from(path.join(".git")))
}
mod store {
mod find_one {
use crate::file::store;
use std::path::Path;
mod existing {
... | true |
2c28cab7d8ff646fa65449bfca109964f6568150 | Rust | lfordyce/salt_utxo_rust | /src/handler/utxo.rs | UTF-8 | 4,052 | 2.703125 | 3 | [] | no_license | use crate::entity::utxo::Utxo;
use crate::utils;
use serde::{Deserialize, Serialize};
use tide::{Body, StatusCode};
#[derive(Default, Debug, Clone, PartialEq, Deserialize, Serialize)]
pub struct ErrorResponse {
pub message: String,
}
impl From<Box<dyn std::error::Error>> for ErrorResponse {
fn from(item: Box<... | true |
b1a3c28b32b1b0ff191dc2ec3d0b11c75360f237 | Rust | danjordan/aoc2020 | /five/src/main.rs | UTF-8 | 1,886 | 3.640625 | 4 | [] | no_license | use std::env;
fn get_seat_id(input: &str) -> usize {
let characters: Vec<char> = input.chars().collect();
let mut row_min: usize = 0;
let mut row_max: usize = 127;
let mut column_min: usize = 0;
let mut column_max: usize = 7;
for character in characters {
let row_difference: usize = (r... | true |
1bcfff6f8b656b7d72ca635c8c64009e8ef81bcb | Rust | Aehmlo/insteon-serial | /src/command.rs | UTF-8 | 3,861 | 3.453125 | 3 | [] | no_license | //! Commands to be executed by the recipient.
/// An ALL-Link group number.
///
/// This structure and `message::Group` will be consolidated into a better structure at a later point.
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub struct GroupNumber(pub u8);
/// The "on level" associated with an on command.
//... | true |
6c1e2a6999872077d47652976b50eca6a3f9a923 | Rust | jawest/rust-kdb | /src/dict.rs | UTF-8 | 6,138 | 2.515625 | 3 | [
"MIT"
] | permissive | use crate::any::KAny;
use crate::atoms::KItem;
use crate::error::ConversionError;
use crate::mixed_list::KMixedList;
use crate::raw::kapi;
use crate::raw::types::{KType, DICT, K, MIXED_LIST};
use crate::unowned::Unowned;
use std::convert::TryFrom;
use std::iter::FromIterator;
use std::mem;
use std::ops::Index;
#[repr(... | true |
d887e071132e3e6644bf8658fbf662fd94faf9c1 | Rust | woubuc/postage-rs | /src/sync/notifier.rs | UTF-8 | 1,478 | 2.875 | 3 | [
"MIT"
] | permissive | use atomic::Ordering;
use crossbeam_queue::SegQueue;
use std::{sync::atomic::AtomicUsize, task::Waker};
#[derive(Debug)]
pub struct Notifier {
generation: AtomicUsize,
wakers: SegQueue<Waker>,
}
impl Notifier {
pub fn new() -> Self {
Self {
generation: AtomicUsize::new(0),
... | true |
d9b799db1db28bec36f30663af73a53b9b8ce07e | Rust | volfco/conqwest | /src/http.rs | UTF-8 | 1,357 | 2.65625 | 3 | [] | no_license | use consul;
use reqwest;
use log::{warn, debug, trace};
use rand::{thread_rng};
use rand::seq::SliceRandom;
use consul::health::Health;
pub fn get<S: Into<String>>(service: S, url: S, tag: Option<&str>) -> Result<reqwest::Result<reqwest::blocking::Response>, String>{
/// method to quickly look up a service, select... | true |
adb417c7e1128772394a3aa05e48185a85bdb04d | Rust | tx991020/rust-exercise | /a72/src/main.rs | UTF-8 | 2,348 | 2.6875 | 3 | [] | no_license | use chrono::Local;
extern crate chan_signal;
use chan_signal::Signal;
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
#[macro_use]
extern crate log;
extern crate env_logger;
use std::pin;
use std::thread;
use std::time::Duration;
fn main() {
// let time = Local::now().format("%Y-%m-%d %H:%M:%S").to_st... | true |
648d264c1cd9387aeaabfc197efae1eb329cad81 | Rust | PsypherPunk/advent-of-code | /2021/25/src/main.rs | UTF-8 | 511 | 2.5625 | 3 | [
"BSD-3-Clause"
] | permissive | use std::fs;
use argh::FromArgs;
use ::day25::*;
#[derive(FromArgs)]
#[argh(description = "Advent of Code 2021, day 25")]
struct Args {
#[argh(switch, short = 'd', description = "whether to display animation")]
display: bool,
}
fn main() {
let args: Args = argh::from_env();
let input = fs::read_to_s... | true |
81a16f669c3f7a63075af201f160b8a9469244d3 | Rust | duchu89/design_patterns | /factory_method/src/factory.rs | UTF-8 | 745 | 2.734375 | 3 | [
"MIT"
] | permissive | use crate::phone::{Phone, IPhone11Max, IPhoneSE, Pixel4XL,Pixel4a};
use crate::specification::Specification;
pub trait Factory {
fn new_phone(&self, spec: Specification) -> Box<dyn Phone>;
}
pub struct AppleFactory;
impl Factory for AppleFactory {
fn new_phone(&self, spec: Specification) -> Box<dyn Phone> {
... | true |
32123c6ca8385f64f53aaf577079b2157806fe2e | Rust | sria91-rlox/loxr-2 | /src/vm.rs | UTF-8 | 6,490 | 3.21875 | 3 | [] | no_license | use crate::chunk::{Chunk, Opcode};
use crate::compiler::compile;
use crate::value::{Value, Obj};
pub const DEBUG: bool = false;
// TODO: contrain VM::stack somehow?
const STACK_MAX: usize = 256;
pub enum InterpretError {
CompileError,
RuntimeError,
}
pub struct VM {
ip: usize,
stack: Vec<Value>,
}
i... | true |
3ee352290e9ef09eb411e5c2240a2b290b209c24 | Rust | jprando/tepe | /src/lib/file_ext.rs | UTF-8 | 1,369 | 3.046875 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::ffi::OsStr;
/// Common types of file groups Telegram can send through a specific API.
#[derive(Debug, Eq, PartialEq)]
pub enum FileGroup {
Animation,
Video,
Photo,
Audio,
/// The default file group
Document,
}
// TODO: look at Telegram's docs to properly... | true |
29525ba6803806c19402dcb672847a690f5303f7 | Rust | IThawk/rust-project | /rust-master/src/test/run-pass/structs-enums/tuple-struct-destructuring.rs | UTF-8 | 176 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // run-pass
struct Foo(isize, isize);
pub fn main() {
let x = Foo(1, 2);
let Foo(y, z) = x;
println!("{} {}", y, z);
assert_eq!(y, 1);
assert_eq!(z, 2);
}
| true |
745cbf9315f3c29a7aea0f8433a35854f4652e1d | Rust | AtsukiTak/atom-asm | /atom-macho/src/load_command/symtab.rs | UTF-8 | 2,174 | 3.3125 | 3 | [] | no_license | use crate::io::{Endian, ReadExt as _, WriteExt as _};
use std::io::{Read, Write};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SymtabCommand {
pub cmd: u32,
pub cmdsize: u32,
/// the byte offset from the start of the file to the location of the
/// symbol table entries
pub symoff: u32,
///... | true |
1d5a2faed9f91e17d80d9f877957a30b04930a51 | Rust | lukealvarez/rtmp-switcher | /src/mixer/error.rs | UTF-8 | 611 | 2.640625 | 3 | [
"MIT"
] | permissive | #[derive(thiserror::Error, Debug)]
pub enum Error {
#[error("a {0} with the name '{1}' already exists")]
Exists(String, String),
#[error("unknown error")]
Unknown,
#[error("{0}")]
System(String),
#[error("a {0} with the name '{1}' was not found")]
NotFound(String, String),
#[erro... | true |
ed2133e5bc067184802e67f65030e67bdcf20c53 | Rust | ryanzidago/leetcode | /running-sum/src/main.rs | UTF-8 | 429 | 3.703125 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
}
fn running_sum(nums: Vec<i32>) -> Vec<i32> {
let mut sum = 0;
nums.iter()
.map(|num| {
sum += num;
sum
})
.collect()
}
#[test]
fn running_sum_test() {
let nums: Vec<i32> = vec![1, 2, 3, 4];
let expected: Vec<i... | true |
488758da85bce20de53acf795fc26e5f66847de4 | Rust | dai1975/rusttest | /nettest/src/mioco_test.rs | UTF-8 | 1,246 | 2.578125 | 3 | [
"MIT"
] | permissive | use std;
use mioco;
use std::str::FromStr;
use std::io::Read;
pub fn bind() -> Result<mioco::tcp::TcpListener, String> {
let addr = try!(std::net::SocketAddr::from_str("127.0.0.1:10000").map_err(|e| format!("parse: {}", e)));
let listener = try!(mioco::tcp::TcpListener::bind(&addr).map_err(|e| form... | true |
51c02b92052196d8ede8e0dc44e6afe3a816a4e1 | Rust | motorlatitude/MotorBot | /src/db/db_client.rs | UTF-8 | 1,625 | 2.71875 | 3 | [] | permissive | use std::env;
use mongodb::{bson::{doc}, options::{ClientOptions, FindOneOptions, UpdateOptions}, Client, Collection, results::UpdateResult};
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct UserScore {
pub user_id: String,
pub score: i32,
}
pub struct DBClient {
clie... | true |
77e205c3f9b4b0f0a01463430e5c1c28652a6f77 | Rust | koboriakira/exercism-rust | /rust/two-bucket/src/lib.rs | UTF-8 | 2,906 | 3.578125 | 4 | [] | no_license | use std::collections::HashSet;
#[derive(PartialEq, Eq, Debug)]
pub enum Bucket {
One,
Two,
}
/// A struct to hold your results in.
#[derive(PartialEq, Eq, Debug)]
pub struct BucketStats {
/// The total number of "moves" it should take to reach the desired number of liters, including
/// the first fill... | true |
99bcb7277bd7cb52cb4469b7050a69f24b041ef0 | Rust | ngtkana/aribook | /crates/chap3_3/a_simple_problem_with_integers/src/main.rs | UTF-8 | 2,316 | 3.09375 | 3 | [] | no_license | use proconio::input;
#[allow(clippy::many_single_char_names)]
fn main() {
input!(n: usize, q: usize);
// セグメント木
let mut data = vec![0; 3 * n + 5];
let mut datb = vec![0; 3 * n + 5];
// [a, b) に x を加算する
// kは節点の番号で、区間[l, r)に対応する
#[allow(clippy::many_single_char_names, clippy::too_many_argu... | true |
09a9b056fcd47662460dbc022fa25e0bb19405c8 | Rust | michaelmelanson/advent-of-code-2019 | /src/day24.rs | UTF-8 | 7,451 | 3.296875 | 3 | [] | no_license |
use core::ops::RangeInclusive;
use std::collections::{BTreeSet, HashSet};
#[derive(Clone, Debug, Hash, Ord, Eq, PartialEq, PartialOrd)]
pub struct Point(u8, u8, isize);
impl Point {
pub const fn north_edge(&self) -> bool { self.1 == 0 }
pub const fn south_edge(&self) -> bool { self.1 == 4 }
pub const fn ... | true |
889ea87871196cdc39e2ba0167fad263868419db | Rust | doytsujin/yew | /examples/boids/src/slider.rs | UTF-8 | 2,451 | 2.78125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::cell::Cell;
use web_sys::HtmlInputElement;
use yew::events::InputEvent;
use yew::{html, Callback, Component, Context, Html, Properties, TargetCast};
thread_local! {
static SLIDER_ID: Cell<usize> = Cell::default();
}
fn next_slider_id() -> usize {
SLIDER_ID.with(|cell| cell.replace(cell.get() + 1))
}
... | true |
de0e95292da124008f8ec5ba6ecb7d70b773be1e | Rust | JimFawcett/IdiomsAndPatterns | /CreateObject/RustObject/src/main.rs | UTF-8 | 835 | 2.984375 | 3 | [] | no_license | // CreateObject::main.rs
/*---------------------------------------------------------
- Declare DemoObj struct, used like C++ class
- Request compiler implement traits Debug and Clone
*/
#[derive(Debug, Clone)]
pub struct DemoObj {
name : String
}
/*-- implement functions new and name --*/
impl DemoObj {
pu... | true |
6b271bb0471a291e134b1bdbaa8df75f6c030db2 | Rust | rodrimati1992/type_level | /type_level_values/docs/guide_09.rs | UTF-8 | 6,347 | 3.34375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | doc_code_snippets! {
mod "guide_09",
type_ident=Guide09,
template=r##"
This chapter demonstrates using TypeFn_ to represent type constructors,
allowing a function to construct a type with different type parameters .
Say that we need to parse a bunch of names (some of which have surnames)
from a ';' separ... | true |
1ff1bb5b4c35f49ae64b930ea539cc6897cc12a3 | Rust | TheRenegadeCoder/sample-programs | /archive/r/rust/josephus-problem.rs | UTF-8 | 1,174 | 3.75 | 4 | [
"MIT"
] | permissive | use std::env::args;
use std::process::exit;
use std::str::FromStr;
fn usage() -> ! {
println!("Usage: please input the total number of people and number of people to skip.");
exit(0);
}
fn parse_int<T: FromStr>(s: &str) -> Result<T, <T as FromStr>::Err> {
s.trim().parse::<T>()
}
// Reference: https://en.... | true |
c96143741f206f7c64ecfe7df9cb507846e56130 | Rust | joonazan/lcl-viz | /src/necklace.rs | UTF-8 | 2,722 | 2.890625 | 3 | [] | no_license | mod neighborhoods;
mod utils;
mod with_ids;
use utils::*;
use web_sys::HtmlElement;
use yew::prelude::*;
pub struct Necklace {
link: ComponentLink<Self>,
container: NodeRef,
section: usize,
}
impl Necklace {
fn set_css_var(&mut self, name: &str, value: &str) {
self.container
.cast:... | true |
101917c4688d0996a0880cd7889b28a8f278bb10 | Rust | wisest30/AlgoStudy | /source/leetcode/2125/dontpanic.rs | UTF-8 | 865 | 3.34375 | 3 | [] | no_license | #![allow(unused)]
struct Solution {}
impl Solution {
pub fn number_of_beams(bank: Vec<String>) -> i32 {
let it = bank
.iter()
.map(|s| s.as_bytes().iter().filter(|&&x| x == b'1').count())
.filter(|&x| x > 0);
let it2 = it.clone().skip(1);
let itzip = it.... | true |
a43dbefeb018938afc051ef1fdfcf52c7c7b6258 | Rust | transparencies/speedrun-api | /src/api/platforms.rs | UTF-8 | 2,676 | 3.1875 | 3 | [] | no_license | //! # Platforms
//!
//! Endpoints available for platforms.
use std::{borrow::Cow, fmt::Display};
use http::Method;
use serde::{Deserialize, Serialize};
use super::{endpoint::Endpoint, Direction, Pageable};
/// Sorting options for platforms
#[derive(Debug, Serialize, Clone, Copy)]
#[serde(rename_all = "kebab-case")]
... | true |
0abc526ddcd0a1e518b9c42a75e6a6821779d44c | Rust | bevyengine/bevy | /crates/bevy_reflect/bevy_reflect_derive/src/type_uuid.rs | UTF-8 | 3,694 | 2.6875 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | extern crate proc_macro;
use bevy_macro_utils::BevyManifest;
use quote::quote;
use syn::parse::{Parse, ParseStream};
use syn::token::Comma;
use syn::*;
use uuid::Uuid;
/// Parses input from a derive of `TypeUuid`.
pub(crate) fn type_uuid_derive(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
// Const... | true |
d99d62d27d54c728cdef1f7fcb1ac837f929d8f9 | Rust | ciaran2/feo3boy | /feo3boy/src/gbz80core/executor.rs | UTF-8 | 1,978 | 3.21875 | 3 | [
"MIT"
] | permissive | //! Defines the basic types needed to implement a GBZ80 Exeuctor.
use std::fmt::Debug;
use crate::gbz80core::ExecutorContext;
/// Trait for types which represent the state of a microcode executor.
pub trait ExecutorState: Clone + Debug + Eq + PartialEq {}
impl ExecutorState for () {}
/// Trait for an executor which... | true |
e8f66d630c82d287ee730bd2c2f1c8142368a544 | Rust | declanvk/dancing-links | /src/solver.rs | UTF-8 | 7,682 | 3.171875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
grid::{Column, Grid, Node},
ExactCover,
};
use core::iter;
use std::collections::VecDeque;
/// Solver that iteratively returns solutions to exact cover problems.
#[derive(Debug)]
pub struct Solver<'e, E: ExactCover> {
problem: &'e E,
// Values used to track the state of solving
grid: ... | true |
1e45ce9f5828786f5f759389d77c64732bc568d4 | Rust | inghamn/asteroids | /src/renderer.rs | UTF-8 | 1,094 | 2.5625 | 3 | [] | no_license | extern crate sdl2;
use crate::components::renderable::*;
use crate::entities::asteroid::Asteroid;
use crate::entities::ship::Ship;
use sdl2::pixels::Color;
use sdl2::render::{WindowCanvas};
use sdl2::gfx::primitives::DrawRenderer;
pub fn render(canvas: &mut WindowCanvas, ship: &Ship, asteroids: &Vec<Asteroid>) -> Res... | true |
09fa39670a12a59e87dd535ff7f4c035e956dfa6 | Rust | PacktPublishing/Rust-Standard-Library-Cookbook | /Chapter05/src/bin/conversion.rs | UTF-8 | 3,059 | 3.953125 | 4 | [
"MIT"
] | permissive | use std::ops::MulAssign;
use std::fmt::Display;
// This structure doubles all elements it stores
#[derive(Debug)]
struct DoubleVec<T>(Vec<T>);
// Allowing conversion from a Vec<T>,
// where T is multipliable with an integer
impl<T> From<Vec<T>> for DoubleVec<T>
where
T: MulAssign<i32>,
{
fn from(mut vec: Vec... | true |
174f48f904f487484131b0215318c4589a1c3c5b | Rust | pengqi245/actix_web_test | /src/controller/user_controller.rs | UTF-8 | 2,277 | 2.875 | 3 | [] | no_license | use crate::entity::test_entity::MyObj;
use crate::entity::user_entity::UserEntity;
use crate::RB;
use actix_web::{delete, get, post, put, web, HttpResponse};
use chrono::prelude::*;
use serde_json::json;
#[get("/test")]
pub async fn test() -> HttpResponse {
HttpResponse::Ok().json(MyObj {
name: String::fro... | true |
ac7e063c28748db8e388b42d9a330cb47c15670d | Rust | archshift/llama | /libllama/src/dbgcore.rs | UTF-8 | 6,737 | 2.59375 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | use std::sync;
use cpu::{self, v5, v6};
pub use cpu::irq::{IrqType9, IrqClient};
use cpu::caches::Ops;
use hwcore;
use io;
#[derive(Clone)]
pub struct DbgCore {
hw: sync::Arc<sync::Mutex<hwcore::HwCore>>
}
impl DbgCore {
pub fn bind(hw: hwcore::HwCore) -> DbgCore {
DbgCore {
hw: sync::Arc... | true |
51ea5772ef4e510fe60eb551da4a14a8af9998d8 | Rust | dmitris/advent-of-code-rust | /src/day3_2.rs | UTF-8 | 744 | 3 | 3 | [] | no_license | use std::io::BufRead;
fn check_slope(forest_pattern: &Vec<Vec<bool>>, slope: (usize, usize)) -> usize {
forest_pattern
.iter()
.step_by(slope.0)
.enumerate()
.filter(|(column, v)| v[(column * slope.1) % v.len()])
.count()
}
fn main() {
let forest_pattern: Vec<Vec<_>> = ... | true |
36d1115e9c26e787cb8fb26602bb9c2519596153 | Rust | hojjatabdollahi/aiml_rs | /libaiml/tests/integration_tests.rs | UTF-8 | 1,167 | 2.734375 | 3 | [] | no_license | use libaiml::logic::bot::Bot;
use libaiml::storage::loader;
use test_env_log::test;
use std::path::PathBuf;
//
//
//
// To run the tests
// cargo test --package=libaiml -- --nocapture
//
//
//
//
#[test]
fn integration_test() {
let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
test_dir.push("../... | true |
53dc226a55afdcc92656961dceb83b1f33090fc8 | Rust | ndbaker1/BONK | /server/src/ws.rs | UTF-8 | 7,172 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::{data_types, game_engine, session_types};
use futures::{FutureExt, StreamExt};
use tokio::sync::mpsc;
use warp::ws::{Message, WebSocket};
/// The Initial Setup for a WebSocket Connection
pub async fn client_connection(
ws: WebSocket,
id: String,
clients: data_types::SafeClients,
se... | true |
6a9c0a90a48592e28761ef3284be89ab573bc5cb | Rust | otrho/fizzbuzz | /tests/00_print.rs | UTF-8 | 686 | 2.9375 | 3 | [
"MIT"
] | permissive | mod common;
use common::test_str;
#[test]
fn test_print_simple_numbers() {
test_str(r#"print(0);"#, " 0\n");
test_str(r#"print(1);"#, " 1\n");
test_str(r#"print(10);"#, " 10\n");
test_str(r#"print(100);"#, "100\n");
test_str(r#"print(555);"#, "555\n");
test_str(r#"print(999);"#, "999\n");
... | true |
8ddc4ed471d399891f9be788e419f3eba446b7b6 | Rust | tirust/msp432e4 | /src/usb0/dmactl5.rs | UTF-8 | 14,555 | 2.828125 | 3 | [
"BSD-3-Clause"
] | permissive | #[doc = r"Value read from the register"]
pub struct R {
bits: u16,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u16,
}
impl super::DMACTL5 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, ... | true |
856f5dad4c33e085b2ea23999cae3312dfa5c4bc | Rust | shengLin-alex/rust-exercise | /enum/match.rs | UTF-8 | 1,367 | 4 | 4 | [] | no_license | #[derive(Debug)]
enum UsState {
Alabama,
Alaska,
// etc
}
enum Coin {
Penny,
Nickel,
Dime,
Quarter(UsState),
}
fn value_in_coin(coin: &Coin) -> u32 {
match coin {
Coin::Penny => 1,
Coin::Nickel => 5,
Coin::Dime => 10,
Coin::Quarter(state) => {
... | true |
8bc50adbebcbc6727ceca7c12bd53ba600f9c7fc | Rust | prz23/zinc | /zinc-compiler/src/bundler/error.rs | UTF-8 | 946 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | //!
//! The Zinc compiler bundler error.
//!
use thiserror::Error;
///
/// The Zinc compiler bundler error.
///
#[derive(Debug, Error)]
pub enum Error {
/// A dependency cycle between some projects has been detected.
#[error("projects `{parent}` and `{child}` depend on each other")]
DependencyCycle {
... | true |
d5503ae8de4d5600efb118bc345a7201c2622e5a | Rust | wusyong/troika | /src/ftroika.rs | UTF-8 | 9,479 | 2.875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use super::constants::{
Trit, COLUMNS, FROUND_CONSTANTS, NUM_ROUNDS, ROWS, SLICES, SLICESIZE, TROIKA_RATE,
};
use crate::{Result, Sponge};
use core::fmt;
#[derive(Clone, Copy)]
struct T27 {
pub p: u32,
pub n: u32,
}
impl fmt::Debug for T27 {
fn fmt(&self, f: &mut fmt::Formatter) ... | true |
c30563c1666d299433e2c98eb11f37245fe384c4 | Rust | csvsoft/rust-note | /src/data_structure.rs | UTF-8 | 2,228 | 3.53125 | 4 | [] | no_license | #![allow(dead_code)]
//use std::box::Box;
const MAX_PLAYERS:u32 = 10;
struct s_named{
x:u32,
y:u32,
}
struct s_numbered(i32);
impl Copy for s_numbered{
}
impl Clone for s_numbered {
fn clone(&self) -> s_numbered {
*self
}
}
struct s_unit;
/*
Enum variants could be different data types:... | true |
859d2aa910635e85696c8cb2ccf00148711afa86 | Rust | kjempelodott/adventofcode | /aoc2022/src/bin/day6.rs | UTF-8 | 541 | 2.609375 | 3 | [] | no_license | extern crate aoc2022;
use aoc2022::read_from_stdin;
use std::collections::HashSet;
fn main() {
let signals: Vec<_> = read_from_stdin().chars().collect();
let (n, _) = signals.windows(4)
.enumerate()
.find(|(_, w)| w.into_iter().collect::<HashSet<&char>>().len() == 4)
.unwrap();
pri... | true |
e743a0f661c648c76f15d592a0388d63375cd507 | Rust | zacharydenton/rtchallenge | /src/tuple.rs | UTF-8 | 8,502 | 3.984375 | 4 | [] | no_license | use std::ops;
/// A 4-element tuple, used for representing points and vectors.
#[derive(Copy, Clone, Debug, PartialEq)]
pub struct Tuple4 {
pub x: f32,
pub y: f32,
pub z: f32,
pub w: f32,
}
/// Constructs a Tuple4.
pub fn tuple4(x: f32, y: f32, z: f32, w: f32) -> Tuple4 {
Tuple4 { x, y, z, w }
}
... | true |
344162814f41539ae72ab8e15dfb2fadc3864c78 | Rust | nstoddard/webgl-gui | /src/assets.rs | UTF-8 | 6,124 | 2.578125 | 3 | [
"MIT"
] | permissive | use collect_mac::*;
use futures::future::*;
use js_sys::*;
use std::cell::RefCell;
use std::collections::*;
use std::mem;
use std::ops::*;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen_futures::JsFuture;
use web_sys::*;
/// Stores assets that have been loaded. Currently, a U... | true |
9d0251a3c889430bdc6a4c0790769fd6b603dbfd | Rust | Bingwen-Hu/hackaway | /books/RBE/quicklearn/compounds.rs | UTF-8 | 929 | 3.84375 | 4 | [
"BSD-2-Clause"
] | permissive | /* when I say compound I means list, tuple, array and so and so on */
fn show_tuple(message: &'static str){
println!("{}", message);
let tuple: (i32, f64, char) = (42, 3.14, 'A');
// Warning: Rust love snake case name?
let (secret, pi, a) = tuple;
println!("{} {} {} ", secret, pi, a);
prin... | true |
62f836197517f6cfe638c7d10fc84c47ad2936b7 | Rust | lcnja/docktape-rs | /src/network.rs | UTF-8 | 373 | 3.34375 | 3 | [
"MIT"
] | permissive | /// Struct representing a Docker network with some of its fields
pub struct Network{
pub id: String,
pub name: String
}
impl Network{
/// Returns the network ID
pub fn id(&self) -> String{
self.id.clone().replace("\"", "")
}
/// Returns the network name
pub fn name(&self) -> String... | true |
aa107dda3521a51dafb1d26a35c1e1f6c0203ae9 | Rust | makers-for-life/makair-control-ui | /src/chip/settings/mode.rs | UTF-8 | 3,879 | 2.65625 | 3 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | // MakAir Control UI
//
// Copyright: 2020, Makers For Life
// License: Public Domain License
use makair_telemetry::control::{ControlMessage, ControlSetting};
use makair_telemetry::structures::VentilationMode;
use crate::chip::settings::SettingActionRange;
const INSPIRATORY_TIME_STEP: usize = 10;
const CYCLES_PER_MI... | true |
d6f879c0d3052b2102846fa9ed953ef8ad4c34c2 | Rust | MichaelHe1125/rust-leetcode | /src/lcof_45_ba_shu_zu_pai_cheng_zui_xiao_de_shu.rs | UTF-8 | 3,881 | 3.953125 | 4 | [] | no_license | pub struct Solution {}
use std::cmp::Ordering;
impl Solution {
pub fn min_number(nums: Vec<i32>) -> String {
let mut result: Vec<(usize, String)> = vec![];
for (index, &num) in nums.iter().enumerate() {
result.push((index, num.to_string()));
}
result.sort_by(|a, b| Solut... | true |
fa483a4c5c2f6e084b8c602a1231fd2ac08913f6 | Rust | lynch829/telium | /src/numeric/interpolate.rs | UTF-8 | 2,730 | 2.90625 | 3 | [] | no_license | use numeric::function::{Domain, Eval};
use numeric::piecewise::Piecewise;
use numeric::polynomial::Polynomial;
use std::ops::{Sub, Mul, Add};
use std::fmt::Debug;
extern crate nalgebra;
use self::nalgebra::{DMat, DVec, Inv};
extern crate num;
use self::num::traits::{Zero, CheckedAdd};
use self::num::iter::range;
//... | true |
d78166eb8eafc62b2d0f1b0b2961a6567c6983d0 | Rust | kentfredric/grease | /src/macros/compare.rs | UTF-8 | 608 | 2.53125 | 3 | [] | no_license | #[macro_export]
macro_rules! chain_cmp {
($cmp:expr) => {
$cmp
};
($cmp:expr, $res:expr) => {{
use std::cmp::Ordering::Equal;
match $cmp {
Some(Equal) => $res,
e => e,
}
}};
($cmp:expr, $res:expr, $resb:expr) => {
chain_cmp!($cmp, chain... | true |
90bad6857e2f6c7a68e480c36a18873acb100e00 | Rust | jwilm/log4rs | /src/priv_serde.rs | UTF-8 | 956 | 2.53125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use serde::de;
use log::LogLevelFilter;
use std::time::Duration;
#[derive(PartialEq, Debug)]
pub struct DeLogLevelFilter(pub LogLevelFilter);
impl de::Deserialize for DeLogLevelFilter {
fn deserialize<D>(d: &mut D) -> Result<DeLogLevelFilter, D::Error>
where D: de::Deserializer
{
struct V;
... | true |
77d245a24fda5b914af59d0b0d7705dc6d36a8ed | Rust | TianTianForever/Rust-Tutorial | /test24.rs | UTF-8 | 518 | 3.46875 | 3 | [] | no_license | fn main() {
// Declare a variable binding
let a_binding;
{
let x = 2;
// Initialize the binding.
a_binding = x * x;
}
println!("a_binding: {}", a_binding);
let another_binding;
// Error! Use of uninitialized binding.
// The compiler fobids use of unintialized vari... | true |
989a6a01dfbff2a9a2466340be19722c2cb49352 | Rust | betta-cyber/aegis | /src/waf.rs | UTF-8 | 1,184 | 2.640625 | 3 | [] | no_license | #![allow(unused_imports)]
extern crate regex;
use std::io::{self, Read};
use std::sync::Arc;
use std::thread;
use hyper::{Body, Method, Request, Response, Server};
macro_rules! regex {
($re:expr) => {
::regex::Regex::new($re).unwrap()
};
}
pub fn req_check<T>(req: &Request<T>) {
let variants = ve... | true |
4b048d860c74a34f344ea83ab8360a4df8b8948c | Rust | sigp/lighthouse | /testing/ef_tests/src/bls_setting.rs | UTF-8 | 648 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use self::BlsSetting::*;
use crate::error::Error;
use serde_repr::Deserialize_repr;
#[derive(Deserialize_repr, Debug, Clone, Copy, Default)]
#[repr(u8)]
pub enum BlsSetting {
#[default]
Flexible = 0,
Required = 1,
Ignored = 2,
}
impl BlsSetting {
/// Check the BLS setting and skip the test if it i... | true |
30876bf33fdc8e6c587d4a45dcb5ac24ce5a350a | Rust | LPGhatguy/shunting-rust | /src/repl.rs | UTF-8 | 813 | 3.25 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Unlicense"
] | permissive | use std::io::{self, BufRead, Write};
use lexer::lex;
use parser::parse_expression;
use evaluate::evaluate;
/// Start the REPL (read-eval-print loop) to prompt the user for input and
/// attempt to process it.
pub fn start() {
let stdin = io::stdin();
loop {
print!("> ");
io::stdout().flush().... | true |
625643b903c0fc43080705943e636ceca50f57c0 | Rust | eldruin/embedded-hal | /embedded-hal-async/src/serial.rs | UTF-8 | 1,066 | 3.359375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Serial interface
pub use embedded_hal::serial::{Error, ErrorKind, ErrorType};
/// Write half of a serial interface
pub trait Write<Word: 'static + Copy = u8>: ErrorType {
/// Writes a slice, blocking until everything has been written.
///
/// An implementation can choose to buffer the write, returning... | true |
78565f76de8e1c446df8107d749e0db9ac0d0059 | Rust | Logicalshift/flo_curves | /tests/bezier/deform.rs | UTF-8 | 3,091 | 3.09375 | 3 | [
"Apache-2.0"
] | permissive | use flo_curves::*;
use flo_curves::bezier;
#[test]
fn deform_line_upwards() {
let curve = bezier::Curve::from_points(Coord2(0.0, 0.0), (Coord2(2.5, 0.0), Coord2(7.5, 0.0)), Coord2(10.0, 0.0));
let deformed = bezier::move_point::<_, _, bezier::Curve<_>>(&curve, 0.5, &Coord2(0.0, 4.0));
let origina... | true |
1a1b8d61adff8865b3dfd10fd5c62ef1300acceb | Rust | damienstanton/rfg | /examples/traits/src/main.rs | UTF-8 | 1,168 | 3.96875 | 4 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A look at `traits` compared to `interfaces`
/// Anything that has a way to be summarized
pub trait Summary {
fn summarize_author(&self) -> String;
fn summarize(&self) -> String {
format!("(Read more from {}...)", self.summarize_author())
}
}
/// A tweet.
#[derive(Debug)]
pub struct Tweet {
... | true |
e0e5135eaa43257b2169b8afc22163b474d85795 | Rust | Peritract/adventofcode | /2021/day_13.rs | UTF-8 | 2,728 | 3.421875 | 3 | [] | no_license | use std::fs;
fn load_data(filepath:&str) -> String {
let file = fs::read_to_string(filepath);
if file.is_ok() {
return file.unwrap();
}
panic!("File not found or unreadable");
}
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
struct Point{x:i32, y:i32}
impl Point {
fn new(s:&str) -> Self {
let c:Ve... | true |
aac11c2523b9844923efb8eef858a8f8caf4d1a4 | Rust | snoword/arwen | /src/kernel/arch-x86_64/memory.rs | UTF-8 | 962 | 2.53125 | 3 | [
"MIT"
] | permissive | use memory::{self, MemoryRegion};
// TODO: add proper treatment of reserved memory regions
fn detect_memory<'a>(buf: &'a mut [MemoryRegion]) -> &'a [MemoryRegion] {
use arch::multiboot;
let kreg = memory::kernel_memory_region();
let mut len = 0;
for reg in multiboot::MemoryMapIter::new() {
if... | true |
42a312114349da4428cb5dcbec98d25ee2c174f2 | Rust | wg/rusoto | /rusoto/core/src/proto/xml/error.rs | UTF-8 | 1,665 | 2.84375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use log::*;
use super::util::{characters, end_element, peek_at_name, skip_tree, start_element, string_field};
use super::util::{Next, Peek, XmlParseError};
#[derive(Default, Debug)]
pub struct XmlError {
pub error_type: String,
pub code: String,
pub message: String,
pub detail: Option<String>,
}
pub ... | true |
76df277293c8b881b257a8d44c2cabe8cbcf73f8 | Rust | tarrows/learn-rust | /rustbook/blog/src/bin/main.rs | UTF-8 | 589 | 2.921875 | 3 | [] | no_license | extern crate blog;
use blog::Post;
use blog::Post2;
fn main() {
let mut post = Post::new();
post.add_text("I ate a salad for lunch today");
assert_eq!("", post.content());
post.request_review();
assert_eq!("", post.content());
post.approve();
assert_eq!("I ate a salad for lunch today", post.content())... | true |
d8de0d53170c42831cf98b14eeebbb6f1b8d7ea1 | Rust | minghu6/rust-minghu6 | /coll_heap/src/fib.rs | UTF-8 | 19,645 | 3.1875 | 3 | [] | no_license | //! Fibonacci Heap (decent impl)
//!
use std::{
borrow::Borrow,
cmp::Ordering::*,
collections::{hash_map::Entry::*, HashMap},
fmt::{Debug, Display},
hash::Hash, mem::replace,
};
use common::hashmap;
use coll::*;
////////////////////////////////////////////////////////////////////////////////
//... | true |
d8be78194a7c7153d7231bffceb2dec75baf9da3 | Rust | jeremyletang/rust-sfml | /src/window/style.rs | UTF-8 | 791 | 3 | 3 | [
"Zlib"
] | permissive | //! Available styles applicable to windows.
bitflags::bitflags! {
/// Available styles applicable to windows.
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Style: u32 {
/// No decorations (cannot be combined with other flags).
const NONE = 0;
/// Title bar and fixed border... | true |
61ade8b0e79ba53b7772b9cb965667ffa0d6647e | Rust | knezes1/Chip8Emulator | /src/chip_8_emulator.rs | UTF-8 | 25,046 | 3.1875 | 3 | [] | no_license | use std::fs::File;
use std::io::prelude::*;
use rand::Rng;
type BYTE = u8; // 8bit -> 1 byte
type WORD = u16; // 16 bit -> 1 word
pub struct Chip8Hardware {
pub keyboard: [bool; 16],
address_i: WORD,
program_counter: WORD,
registers: [BYTE; 16],
memory: [BYTE; 0xFFF],
stack: [WORD; 16],... | true |
6ad100fd35d58ac79dc688072990ac240854d3ce | Rust | bryanburgers/advent-of-code-2019 | /day-03/src/segment.rs | UTF-8 | 4,568 | 3.59375 | 4 | [] | no_license | use super::command::Command;
use std::cmp::{max, min};
pub type Point = (isize, isize);
#[derive(Debug, Eq, PartialEq)]
pub enum Segment {
Vertical { x: isize, y0: isize, y1: isize },
Horizontal { y: isize, x0: isize, x1: isize },
}
impl Segment {
pub fn intersection(&self, other: &Self) -> Option<Point>... | true |
eeaa4d47d306bd7098ff66d663b580a8aa2da2ca | Rust | yijie37/DaQiao | /bridge/parity-ethereum/util/journaldb/src/refcounteddb.rs | UTF-8 | 11,067 | 2.515625 | 3 | [
"Unlicense"
] | permissive | // Copyright 2015-2019 Parity Technologies (UK) Ltd.
// This file is part of Parity Ethereum.
// Parity Ethereum is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at yo... | true |
bda2a0fc872ca1d09791bf35f5ca0b575ddd5082 | Rust | hyperium/hyper | /src/client/conn/mod.rs | UTF-8 | 1,951 | 3.21875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Lower-level client connection API.
//!
//! The types in this module are to provide a lower-level API based around a
//! single connection. Connecting to a host, pooling connections, and the like
//! are not handled at this level. This module provides the building blocks to
//! customize those things externally.
//!... | true |
8befa0fd20d7299f2403c7d1d4989a57b04cb21c | Rust | zandeck/aoc-2020 | /src/challenges/day4.rs | UTF-8 | 1,966 | 3.265625 | 3 | [] | no_license | use itertools::Itertools;
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::str::FromStr;
pub struct Validator;
impl Validator {
pub fn byr(data: &str) -> bool {
if let Ok(parsed) = data.parse::<u32>() {
1920 <= p... | true |
a746a11e2d230844d952d36fe1d66f2aff961cf4 | Rust | henrytill/pwclip-rs | /src/lib.rs | UTF-8 | 9,092 | 2.796875 | 3 | [] | no_license | extern crate clear_on_drop;
#[cfg(test)]
extern crate data_encoding;
extern crate hmac_drbg;
extern crate rust_scrypt;
extern crate serde;
extern crate sha2;
#[cfg(test)]
extern crate toml;
extern crate typenum;
extern crate unicode_segmentation;
use clear_on_drop::clear::Clear;
use hmac_drbg::HmacDRBG;
use rust_scryp... | true |
53dbd7ac7976b6b7e09476b1ebd1309bcb53dac2 | Rust | lgvier/rust-tracer | /src/tuple.rs | UTF-8 | 7,485 | 3.21875 | 3 | [] | no_license | use core::ops::{Add, Div, Mul, Neg, Sub};
use std::fmt;
use crate::{approx_eq, matrix::Matrix};
#[macro_export]
macro_rules! point {
() => {
$crate::tuple::Tuple::point(0, 0, 0)
};
($x:expr, $y:expr, $z:expr) => {
$crate::tuple::Tuple::point($x, $y, $z)
};
}
#[macro_export]
macro_rules... | true |
994359e983233d2098cb717aa849d16614bd0f6f | Rust | jonfk/utility-belt | /rust/cmd-queue/src/cli_util.rs | UTF-8 | 1,068 | 2.859375 | 3 | [
"MIT"
] | permissive | use cli_table::{print_stdout, Table};
use crate::Task;
#[derive(Table)]
struct TaskCliTable<'t> {
id: &'t str,
destination: &'t str,
command: String,
tries: usize,
last_attempt: String,
}
impl<'t> TaskCliTable<'t> {
fn from(task: &'t Task) -> Self {
let last_attempt_since = task
... | true |
11bd4265599093838c52339499120a1666d4d8c4 | Rust | majkcramer/imageproc | /src/contrast.rs | UTF-8 | 6,447 | 3.375 | 3 | [
"MIT"
] | permissive | //! Functions for manipulating the contrast of images.
use image::{GenericImage, GrayImage, ImageBuffer, Luma};
/// Returns the Otsu threshold level of an 8bpp image.
/// This threshold will optimally binarize an image that
/// contains two classes of pixels which have distributions
/// with equal variances. For deta... | true |
637942669c12c16513823256682fcfeae657f05d | Rust | thrombe/Elorts | /rust/src/dweet.rs | UTF-8 | 7,567 | 3.1875 | 3 | [] | no_license | use reqwest;
use std::collections::HashMap;
// use serde_json::{json, to_string, from_str, from_value};
use serde_json::{from_str, from_value, to_string};
use serde::{Serialize, Deserialize};
use serde_derive::{Serialize, Deserialize};
use std::fmt::Debug;
use super::printdebug;
#[derive(Serialize, Deserialize, Debug... | true |
a0280e31d77aa1003c19b56f3accc1efb52368b4 | Rust | Nouzan/my-algo-rs | /src/ch2/linked_list/singly.rs | UTF-8 | 6,358 | 3.359375 | 3 | [
"MIT"
] | permissive | use super::*;
impl<T, L> SinglyLinkedListExt<T> for L where L: SinglyLinkedList<T> {}
pub trait SinglyLinkedListExt<T>: SinglyLinkedList<T> {
/// 就地逆置.
// 习题 2.3.5
fn reverse(&mut self) {
// a -> b -> c
// a, b -> c
// b -> a, c
// c -> b -> a
if !self.is_empty() {
... | true |
0f67ed4f38ad9cbf2b6c03850504a3142c437c36 | Rust | MetroWind/wishlist | /src/data.rs | UTF-8 | 13,201 | 2.9375 | 3 | [
"WTFPL"
] | permissive | use std::time;
use rusqlite as sql;
use rusqlite::OptionalExtension;
use chrono::prelude::*;
use serde::{Deserialize, Serialize};
use crate::error;
use crate::error::Error as Error;
use crate::store::ItemInfo;
use crate::utils;
pub enum SqliteFilename { InMemory, File(std::path::PathBuf) }
#[derive(Deserialize, Ser... | true |
20ed77b65955427dad590ea841a3cc1f7bd30f9e | Rust | rust-chainblock/blockchain_Rust3 | /core/src/account.rs | UTF-8 | 1,594 | 3.140625 | 3 | [] | no_license | use crate::transaction;
use serde::{Deserialize, Serialize};
use utils::coder;
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq)]
pub struct Account {
pub nonce: u64,
pub balance: u64,
pub address: [u8; 32],
pub hash: [u8; 32],
private: [u8; 32],
}
impl Account {
pub fn new(address: [u8; ... | true |
ff877a6737fcaa527db7ad057e845c4461d5faac | Rust | AlexanderJohnston/JavaScript.Eval | /src/native/JavaScript_Eval_Native/tests/functionparameter_tests.rs | UTF-8 | 4,780 | 3.109375 | 3 | [
"MIT"
] | permissive | #[cfg(test)]
mod functionparameter_tests {
use std::{ffi::CString, ptr};
use javascript_eval_native::{function_parameter::FunctionParameter, Primitive};
#[test]
fn it_can_create_from_string_value() {
let string = CString::new(String::from("Hello World"))
.unwrap()
.into... | true |
0f8a83a0a85d1f0d99a1cc6344cd34faf5ee3efc | Rust | shoegaze/raster_rs | /src/math/vectors/double3.rs | UTF-8 | 1,856 | 3.34375 | 3 | [] | no_license | use std::ops::{Add, Sub, Mul, Div};
use crate::math::{
scalars::{
scalar::ScalarTrait,
double::ScalarDouble
},
vectors::{
vector3::Vector3,
ops3::Vector3Ops
}
};
#[derive(Debug, Default, Copy, Clone, PartialEq)]
pub struct Double3 {
pub(self) x: ScalarDouble,
pub(self) y: Sca... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.