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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
28d42223336630b512a851db3c451a3f5add4569 | Rust | RutgerMoons/ggez_snake | /src/renderer/renderer.rs | UTF-8 | 974 | 2.515625 | 3 | [] | no_license | use super::{grid_renderer,color_palette::ColorPalette};
use crate::game_entity::grid::Grid;
use ggez::{Context,GameResult,graphics};
pub struct Renderer {
pub grid_renderer: grid_renderer::GridRenderer,
palette: ColorPalette,
}
impl Renderer {
pub fn new() -> Self {
Self {
grid_renderer: grid_renderer... | true |
e5bcf351bde2fa41cc21640d1bf425e7ee938b89 | Rust | EKULibraries/rexp | /src/parse/quote.rs | UTF-8 | 1,444 | 2.90625 | 3 | [
"BSD-3-Clause"
] | permissive | use crate::{
expr::{
Quote,
Sexp,
},
parse,
};
use nom::{
branch,
sequence,
bytes::complete,
combinator,
error::{
VerboseError,
VerboseErrorKind,
},
IResult,
};
fn quote_bouncer<'a>(
mut parser: impl FnMut(&'a str) -> IResult<&'a str, Sexp, V... | true |
afa9b3fc90ff2a46c5164e7b96949a450c7d6fe7 | Rust | rustjson/LearningNote | /rust/cargo/syntax_and_semantics/src/lifetimes.rs | UTF-8 | 708 | 4.3125 | 4 | [] | no_license | pub fn main() {
println!("---------------------lifetimes-------------------");
let a = 14;
bar(&a);
foo(&a);
let y = &5;
let f = Foo{ x: y};
println!("x is :{}", f.x());
let some_string = "Hello, world";
let s = &some_string;
//some_string[0..1] = 'x';
println!("{}", &som... | true |
d77a038abfd3daefbe8e4c11b20aae6661aff5b5 | Rust | IThawk/rust-project | /rust-master/src/test/ui/error-codes/E0063.rs | UTF-8 | 766 | 2.90625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-other-permissive",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // ignore-tidy-linelength
struct SingleFoo {
x: i32
}
struct PluralFoo {
x: i32,
y: i32,
z: i32
}
struct TruncatedFoo {
a: i32,
b: i32,
x: i32,
y: i32,
z: i32
}
struct TruncatedPluralFoo {
a: i32,
b: i32,
c: i32,
x: i32,
y: i32,
z: i32
}
fn main() {
... | true |
7a26316a6a49f12455e95f7d4b29631f5f80f68e | Rust | azriel91/autexousious | /crate/team_model/src/play/team.rs | UTF-8 | 680 | 2.9375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use amethyst::ecs::{storage::VecStorage, Component};
use crate::play::{IndependentCounter, TeamCounter};
/// Represents the in-game grouping of player teams.
#[derive(Clone, Component, Copy, Debug, Hash, PartialEq, Eq, PartialOrd)]
#[storage(VecStorage)]
pub enum Team {
/// Independent team.
///
/// This ... | true |
f941e749ca3f20d1b7cba5d499bf0004a82f0871 | Rust | 1egoman/rustsweeper | /src/minefield.rs | UTF-8 | 2,410 | 3.328125 | 3 | [
"MIT"
] | permissive | use tile;
extern crate ncurses;
use ncurses::*;
pub type Minefield = [[tile::Tile; MAP_SIZE_HEIGHT]; MAP_SIZE_WIDTH];
// Assemble a minefield
pub const MAP_SIZE_WIDTH: usize = 60;
pub const MAP_SIZE_HEIGHT: usize = 30;
/// Is the given x and y coordinate a valid square in the minefield?
fn is_in_minefield(x: i32, y... | true |
c99eeaf98c436cf69f1d31f7273acde34b674240 | Rust | wolfgang/tetrs | /src/_tests/feature/vanishing_lines_test.rs | UTF-8 | 2,688 | 2.796875 | 3 | [] | no_license | use crate::_tests::helpers::testable_game::TestableGame;
use crate::game::brick_factory::{i_block, z_block};
#[test]
fn single_line_vanishes() {
let mut game = TestableGame::init()
.with_brick_type_encoding()
.with_brick_sequence(vec![i_block(), z_block()])
.with_field(vec![
"..... | true |
5fa2836335aad8aeec965d591675be4e5b07fb89 | Rust | gadomski/sbd-rs | /src/mo/message.rs | UTF-8 | 11,375 | 3.171875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::{
cmp::Ordering,
io::{Cursor, Read, Write},
path::Path,
};
use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt};
use chrono::{DateTime, Utc};
use crate::{
mo::{Header, InformationElement, SessionStatus},
Error,
};
/// The only valid protocol revision number.
pub const PROTOCOL_REVISIO... | true |
1dffffff93a1b7e03e15b3e183419e2fca79983e | Rust | Tiamat-Tech/wagyu | /ethereum/src/wordlist/spanish.rs | UTF-8 | 1,156 | 3.09375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::wordlist::EthereumWordlist;
use wagyu_model::{bip39::SPANISH, wordlist::Wordlist};
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Spanish;
impl Wordlist for Spanish {}
impl EthereumWordlist for Spanish {
/// The wordlist in original form.
const WORDLIST: &'static st... | true |
5d2e3b02167363d239c07049e477ac6de5b9626a | Rust | AfoHT/wayplover | /src/workers/serial.rs | UTF-8 | 3,967 | 2.8125 | 3 | [] | no_license | #[cfg(test)]
extern crate test_case;
use super::Config;
use log::{info, error};
use super::Worker;
use crate::steno::Chord;
use serial;
use std::io::Read;
use std::sync::mpsc;
use std::thread;
const BYTES_PER_STROKE: usize = 6;
const STENO_MAP: [&str; 42] = [
"Fn", "#", "#", "#", "#", "#", "#", "S-", "S-", "T-", ... | true |
77d8a912b21318c27b532cab2548a24c4e3be93d | Rust | mvdnes/nss-rs | /src/ffi/nspr.rs | UTF-8 | 1,529 | 2.515625 | 3 | [
"MIT"
] | permissive | use result::NSSError;
use libc::c_uint;
use std::ffi::CStr;
#[repr(C)]
#[allow(dead_code)] // List all available options
pub enum PRThreadPriority
{
PR_PRIORITY_LOW = 0,
PR_PRIORITY_NORMAL = 1,
PR_PRIORITY_HIGH = 2,
PR_PRIORITY_URGENT = 3,
}
#[repr(C)]
#[allow(dead_code)] // List all available options... | true |
f6c14bee502b98613005ecac9b1bc5e812553eab | Rust | Connicpu/pixel-arena-game | /src/tiled/tileset/mod.rs | UTF-8 | 4,887 | 2.828125 | 3 | [] | no_license | use crate::graphics::core::GraphicsCore;
use crate::tiled::map::LocalTileId;
use crate::tiled::raw;
use crate::tiled::tileset::tile::Tile;
use failure::{err_msg, Fallible, ResultExt};
use glium::texture::{ClientFormat, RawImage1d, SrgbTexture2d, Texture1d};
use math2d::Vector2f;
pub mod image;
pub mod tile;
#[derive... | true |
c744b423deed6164d8493cad2502cd5cd45049c4 | Rust | KonishchevDmitry/investments | /src/util.rs | UTF-8 | 5,612 | 3.140625 | 3 | [] | no_license | use std::borrow::Cow;
use std::ops::Neg;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use lazy_static::lazy_static;
use regex::Regex;
use rust_decimal::RoundingStrategy;
use crate::core::GenericResult;
use crate::currency::Cash;
use crate::types::Decimal;
#[derive(Clone, Copy)]
pub enum DecimalRestrictions... | true |
b37b797d25f1eb3d76010e940746cb0dcb82710c | Rust | immunant/c2rust | /tests/loops/src/test_loops.rs | UTF-8 | 872 | 2.71875 | 3 | [
"BSD-3-Clause",
"Apache-2.0"
] | permissive | use crate::break_continue::rust_entry;
use libc::{c_int, c_uint};
#[link(name = "test")]
extern "C" {
fn entry(_: c_uint, _: *mut c_int);
}
const BUFFER_SIZE: usize = 70;
pub fn test_buffer() {
let mut buffer = [0; BUFFER_SIZE];
let mut rust_buffer = [0; BUFFER_SIZE];
let expected_buffer = [
... | true |
fb80f8afce14fbb146603c54896a431e452b2c0f | Rust | Terkwood/antler | /legacy/src/run/thread.rs | UTF-8 | 3,395 | 2.8125 | 3 | [
"MIT"
] | permissive | //! Rendering thread control.
use crate::{
input::Shader,
output::Data,
parts::{Camera, Scene, Tracer},
run::engine::paint,
};
use arctk::{err::Error, math::Vec3, tools::ProgressBar};
use palette::LinSrgba;
use rand::thread_rng;
use rayon::prelude::*;
use std::{
fmt::Display,
sync::{Arc, Mutex}... | true |
c640e8fa6c731b1951fdabc18c0fbc5adb018139 | Rust | nyradr/godwin-bot | /src/main.rs | UTF-8 | 1,141 | 2.75 | 3 | [] | no_license | use discord::Discord;
use dotenv::dotenv;
use discord::model::Event;
/// Global bot configuration
mod config;
/// Manage answers
mod answer;
mod parsing;
fn main() {
dotenv::dotenv();
let config = config::Config::from_env();
let discord = Discord::from_bot_token(config.token()).expect("login failed");
... | true |
61d23b45c0f9eec810548ff5903a16eb3728877b | Rust | Wallacoloo/online_dag | /src/tests/testrcdag.rs | UTF-8 | 721 | 2.8125 | 3 | [] | no_license | use ::ondag::OnDag;
use ::rcdag::RcDag;
type MyDag = RcDag<u32, u32>;
// Declare tests for common OnDag functionality (inserting/removing nodes and edges).
def_ondag_tests!{MyDag}
#[test]
/// Graph should not allow cycles - should be an error when adding a cycle & structure should be
/// unmodified.
fn test_cycles... | true |
38e0b8349e1ba4dba4d39f91d511a70720b16335 | Rust | isgasho/argmin | /src/solver/quasinewton/sr1_trustregion.rs | UTF-8 | 8,148 | 2.59375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | // Copyright 2019-2020 argmin developers
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according... | true |
33bb35b53d689db5081ae08ca7a50705c179fb11 | Rust | Blugatroff/clone2 | /src/systems/remove_chunks.rs | UTF-8 | 1,536 | 2.609375 | 3 | [] | no_license | use crate::components::{Player, Position};
use crate::{chunk::Chunk, chunk_map::ChunkMap};
use cgmath::MetricSpace;
use specs::{Entities, Join, ReadStorage, System, Write, WriteStorage};
pub struct RemoveChunks;
impl<'a> System<'a> for RemoveChunks {
#[allow(clippy::type_complexity)]
type SystemData = (
... | true |
c98110b2c2115976f16efdafa121258231e9472b | Rust | maxmcc/aoc-2019 | /src/bin/day01.rs | UTF-8 | 1,830 | 3.46875 | 3 | [] | no_license | fn main() {
let input = include_str!("../../input/day01.in");
let masses = input
.lines()
.map(|line| line.parse::<isize>().unwrap())
.collect::<Vec<_>>();
part1(&masses);
part2(&masses);
}
fn part1<'a>(masses: impl IntoIterator<Item = &'a isize>) {
let sum = sum_masses(mass... | true |
d313cd0da6bab840fa605d2d84a39d0df241c1a0 | Rust | gensmusic/ooxml | /src/main.rs | UTF-8 | 11,201 | 3.109375 | 3 | [] | no_license | use anyhow::{Context, Result};
use std::cell::RefCell;
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use std::rc::{Rc, Weak};
use structopt::StructOpt;
use xml::{
attribute::OwnedAttribute,
name::OwnedName,
reader::{EventReader, XmlEvent},
};
#[derive(Debug, StructOpt)]
#[structopt(name ... | true |
0b8d53d511714c18d3223a47666c960957e4f840 | Rust | tatamiya/actix-web-tutorial | /middleware/src/main.rs | UTF-8 | 4,240 | 2.515625 | 3 | [] | no_license | use std::pin::Pin;
use std::task::{Context, Poll};
use actix_service::{Service, Transform};
use actix_session::{CookieSession, Session};
use actix_web::{http, web, App, dev::ServiceRequest, dev::ServiceResponse, Error, HttpResponse, HttpServer, Result};
use actix_web::middleware::{Logger, DefaultHeaders, errhandlers... | true |
d7cde4700834f6b31efe41a2f51b4f693cc7c361 | Rust | santiagoroca/OGLEngine | /old/src/Tokenizer.rs | UTF-8 | 3,334 | 3.84375 | 4 | [] | no_license | #[derive(Debug, PartialEq, Clone)]
pub struct Token {
pub _type: String,
pub _value: String
}
#[derive(Debug, PartialEq, Clone)]
pub struct Tokenizer {
pub _tokens: Vec<char>,
pub _pointer: usize
}
impl Tokenizer {
pub fn new (chars: Vec<char>) -> Tokenizer {
Tokenizer {
_toke... | true |
5a2ed4f9b0a9dacdb4ad63df38b48388145fa6f7 | Rust | Sorting/valve-server-info | /src/server.rs | UTF-8 | 8,512 | 2.734375 | 3 | [] | no_license | use crate::bytereader::ByteReader;
use crate::constants;
use chrono::Duration;
use std::net::UdpSocket;
pub enum Response<T> {
Ok(T),
Error(String),
}
pub struct Server {
socket: UdpSocket
}
#[derive(Debug, Clone)]
pub struct ServerInfo {
pub header: u8,
pub protocol: u8,
pub name: String... | true |
c545d10b4911cf5f57d135c52158bda3acc61ef2 | Rust | kairosswag/aoc | /2017/d02/src/main.rs | UTF-8 | 1,557 | 3.359375 | 3 | [] | no_license | fn main() {
solve1();
solve2();
}
fn solve2() {
let input = include_str!("../input/input");
let lines = input.split("\n");
let mut accumulator = 0;
for line in lines {
let mut numbers : Vec<i32> = line.split_whitespace().map(|s| i32::from_str_radix(s, 10).expect(&format!("Could not pars... | true |
0be204c236bb3e37a3e4c41af62c6b34b8e7bc12 | Rust | Nemo157/uom | /examples/si.rs | UTF-8 | 1,469 | 3.203125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Example showing how to use the pre-built SI system.
extern crate uom;
use uom::si::Unit;
use uom::si::f32::*;
use uom::si::length::{centimeter, kilometer, meter};
use uom::si::time::second;
use uom::si::velocity::{kilometer_per_second, meter_per_second};
fn main() {
let l1 = Length::new::<meter>(15.0);
l... | true |
559bcad3041919116883bb102ca2e6407ca677cf | Rust | leejw51/RustTutorial | /code/src/trait10.rs | UTF-8 | 824 | 3.546875 | 4 | [
"Apache-2.0"
] | permissive | use std::rc::Rc;
trait Food {
fn eat(&self);
}
#[derive(Default, Debug)]
struct Apple {
label: i32,
}
impl Food for Apple {
fn eat(&self) {
println!("eat apple {}", self.label);
}
}
#[derive(Default,Debug)]
struct Ramen {}
impl Food for Ramen {
fn eat(&self) {
println!("eat ramen"... | true |
bf0046f44355782a41fbe1bdc96d4dc929ae7d46 | Rust | srpelissier/hello_world | /src/main.rs | UTF-8 | 215 | 2.921875 | 3 | [] | no_license | extern crate color;
use color::{Rgb, ToHsv};
fn main() {
println!("Hello, world!");
println!("Conversion RGB to HSV!");
let red = Rgb::new(255u8, 0, 0);
println!("HSV: {:?}", red.to_hsv::<f32>());
}
| true |
1d6451ef8eb19e9165561407f6620b8c7bba23c3 | Rust | Ainevsia/Leetcode-Rust | /416. Partition Equal Subset Sum/src/main.rs | UTF-8 | 1,028 | 3.625 | 4 | [
"BSD-2-Clause"
] | permissive | fn main() {
Solution::can_partition(vec![1, 5, 11, 5]);
}
struct Solution {}
impl Solution {
/// cannot understand why this dp is so slow
pub fn can_partition(nums: Vec<i32>) -> bool {
let mut sum = nums.iter().sum::<i32>() as usize;
if sum % 2 == 1 { return false }
else { sum /= 2... | true |
fda3e0d3491d06b67665640c570aae6d4b6efe3c | Rust | asd153866714/learn_Rust | /05-struct/01-basic/02.rs | UTF-8 | 772 | 3.109375 | 3 | [] | no_license | struct User {
username: String,
email: String,
sign_in_count: u64,
active: bool
}
fn build_user(email: String, username: String) -> User {
User {
email,
username,
active: true,
sign_in_count: 1
}
}
fn main() {
let user1 = build_user(String::from("someone@exa... | true |
ac095244d46ec6e2102cd09e8cab93c43f7ad5db | Rust | dseevr/assassin | /src/assassin/position.rs | UTF-8 | 4,718 | 3.046875 | 3 | [
"BSD-3-Clause"
] | permissive | use std::rc::Rc;
use assassin::filled_order::FilledOrder;
use assassin::quote::Quote;
extern crate chrono;
use self::chrono::prelude::*;
extern crate greenback;
use greenback::Greenback as Money;
#[derive(Clone)]
pub struct Position {
name: Rc<str>,
symbol: Rc<str>,
quantity: i32,
expiration_date: D... | true |
6e37d5d8e41808b8c52fe03c47523115924cca43 | Rust | dougtq/rust-lang | /playground/result-fun/src/main.rs | UTF-8 | 420 | 3.703125 | 4 | [
"MIT"
] | permissive | use std::num::ParseIntError;
fn double_number(number_str: &str) -> Result<i32, ParseIntError> {
match number_str.parse::<i32>() {
Ok(n) => Ok(2 * n),
Err(err) => Err(err),
}
}
fn print(str: &str){
match double_number(str) {
Ok(n) => println!("OK: {} = {} * {}",n,n/2,n/2),
... | true |
800ee39cfcccebc043f2f776e772b6bf0a4a2fc1 | Rust | xfoxfu/SYSU-Homework | /DCS397/src/main.rs | UTF-8 | 1,003 | 2.71875 | 3 | [] | no_license | //! https://songlee24.github.io/2014/12/13/aes-encrypt/
use std::{
fs::File,
io::{stdin, stdout, Read, Write},
};
mod aes;
mod opt;
mod padding;
mod stream;
fn main() -> anyhow::Result<()> {
let opts = opt::Opts::parse();
let mut input = Vec::new();
if opts.input != "-" {
File::open(&opt... | true |
5ab65ae2518bdd2f7b684659ac9f065f3154afea | Rust | EduardoSantos7/Algorithms4fun | /Leetcode/1304. Find N Unique Integers Sum up to Zero/solution.rs | UTF-8 | 349 | 2.75 | 3 | [] | no_license | impl Solution {
pub fn sum_zero(n: i32) -> Vec<i32> {
let rem = n % 2;
let loops = n /2 + 1;
let mut res: Vec<i32> = Vec::new();
if rem == 1 {
res.push(0);
}
for i in 1..loops {
res.push(i);
res.push(-i);
}... | true |
8b20df7c84195950bec893639c7b7ec923f92a19 | Rust | DanielleB-R/advent-of-code | /advent-of-code-2020/src/bin/day1.rs | UTF-8 | 506 | 2.625 | 3 | [
"MIT"
] | permissive | use advent_of_code_2020::*;
fn main() {
let numbers = read_and_parse_from_file("day1-input.dat", |line| line.parse::<usize>().unwrap())
.expect("problem with file");
let pair = day1::find_2020_sum(&numbers, 2);
println!("{} * {} = {}", pair[0], pair[1], pair[0] * pair[1]);
let triplet = day1:... | true |
c40e53cba30d9b783e6378d8226e30c6681930e0 | Rust | etaloof/image | /src/libwebp/decoder.rs | UTF-8 | 3,241 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::convert::TryFrom;
use std::default::Default;
use std::io::{self, Cursor, Error, Read, Write};
use std::marker::PhantomData;
use std::mem;
use byteorder::{LittleEndian, ReadBytesExt};
use libwebp::*;
use crate::color;
use crate::error::{DecodingError, ImageError, ImageResult};
use crate::image::{ImageDecoder,... | true |
7903a1e03dc63e7b6f09eea4d36d59990a52f4ac | Rust | TheImaginaryOne/epic-interpreter | /src/compiler/error.rs | UTF-8 | 829 | 3 | 3 | [
"MIT"
] | permissive | use thiserror::Error;
use crate::compiler::lexer::Token;
use crate::compiler::utils::token_to_string;
// TODO rename
#[derive(Debug, PartialEq, Clone, Error)]
pub enum LexError {
#[error("unexpected token")]
UnexpectedToken,
#[error("unterminated string")]
UnterminatedString,
}
#[derive(Debug, Partia... | true |
b3c86a9575155427e9446c4f9c9c0cfb0f988f20 | Rust | Sequal32/msfs-rs | /msfs/src/nvg.rs | UTF-8 | 13,763 | 3.0625 | 3 | [
"MIT"
] | permissive | //! NanoVG is small antialiased vector graphics rendering library with a lean
//! API modeled after the HTML5 Canvas API. It can be used to draw gauge
//! instruments in MSFS. See `Gauge::create_nanovg`.
use crate::sys;
type Result = std::result::Result<(), Box<dyn std::error::Error>>;
/// A NanoVG render context.
p... | true |
25740c89dbeb5e8f5710873a41a98caa16df968a | Rust | DevonEJ/rust-exercism | /src/raindrops.rs | UTF-8 | 621 | 3.03125 | 3 | [] | no_license | use std::vec::Vec;
pub fn raindrops(n: u32) -> String {
let mut results = String::from("");
let mut holder = Vec::new();
if n % 3 == 0 {
holder.push(3);
};
if n % 5 == 0 {
holder.push(5);
};
if n % 7 == 0 {
holder.push(7);
};
if holder.is_empty() {
... | true |
777179553fdc284d4e485522a521e3baee4edf5b | Rust | pat2381/HEMTT | /hemtt-arma-config/src/linter/options.rs | UTF-8 | 538 | 2.90625 | 3 | [] | no_license | #[derive(Copy, Clone, Debug, Default)]
pub struct LinterOptions {
class_inheritance_style: InheritanceStyle,
}
#[derive(Copy, Clone, Debug)]
pub enum InheritanceStyle {
/// The colon is preceded by whitespace
///
///```cpp
///class my_class : parent_class;
///```
Space,
/// The colon is... | true |
e84f5bbf1329a4bae48db0daeea328649cd663f5 | Rust | AmiralBl3ndic/small-repl-in-rust | /src/symbol/parser/operator.rs | UTF-8 | 697 | 3.625 | 4 | [] | no_license | use std::fmt;
#[derive(Debug, Clone)]
pub struct OperatorParsingError;
impl fmt::Display for OperatorParsingError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Error parsing operator")
}
}
type Result<T> = std::result::Result<T, OperatorParsingError>;
/**
* Represents a finite set of poss... | true |
266cc738db0ad8553c12fb8be074e70de53d15dd | Rust | jchevertonwynne/zero2prod | /tests/api/newsletter.rs | UTF-8 | 5,470 | 2.765625 | 3 | [] | no_license | use actix_http::StatusCode;
use uuid::Uuid;
use wiremock::{
matchers::{any, method, path},
Mock, ResponseTemplate,
};
use crate::common::{spawn_app, ConfirmationLinks, TestApp};
#[actix_rt::test]
async fn newsletters_are_not_delivered_to_unconfirmed_subscribers() {
let app = spawn_app().await;
create_... | true |
3a433fc4e09e6decfa1ce42c53f05796174776c4 | Rust | kstep/rust-pb | /src/messages.rs | UTF-8 | 4,653 | 2.828125 | 3 | [] | no_license |
use std::borrow::Cow;
use rustc_serialize::{Encodable, Encoder};
use objects::{Iden, PushData};
#[cfg(test)]
use rustc_serialize::json;
pub trait PbMsg : Encodable {
type Obj: super::objects::PbObj;
}
#[derive(PartialEq, Debug)]
pub enum TargetIden {
CurrentUser,
DeviceIden(Iden),
ContactEmail(Strin... | true |
0392a00ace8e1745f57508febc537996230de5ac | Rust | softdevteam/ykbf | /src/main.rs | UTF-8 | 4,269 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{
env, fs,
io::{stderr, Bytes, Read, Stdin, Stdout, Write},
path::Path,
process,
};
use getopts::Options;
use ykrt::{Location, MTBuilder};
fn usage(prog: &str) -> ! {
let path = Path::new(prog);
let leaf = path
.file_name()
.map(|x| x.to_str().unwrap_or("ykbf"))
... | true |
98521cfde79cb30d00e685a86b02f2069210515a | Rust | joeftiger/rust-v | /src/integrator/path.rs | UTF-8 | 2,406 | 2.65625 | 3 | [
"MIT"
] | permissive | use crate::bxdf::Type;
use crate::integrator::{direct_illumination, Integrator};
use crate::objects::SceneObject;
use crate::samplers::Sampler;
use crate::scene::Scene;
use crate::sensor::pixel::Pixel;
use crate::Spectrum;
use color::Color;
use geometry::{offset_ray_towards, Ray};
use serde::{Deserialize, Serialize};
... | true |
81e470f39230269e2fddd3e448606e721ddee987 | Rust | enricobn/linux-console-games | /src/common/menu.rs | UTF-8 | 1,819 | 2.9375 | 3 | [] | no_license | use std::{io, thread};
use std::io::{Read, Write};
use std::time::Duration;
use termion::color;
use termion::event::Key;
use termion::input::TermRead;
pub fn choose<W: Write, R: Read>(stdout: &mut W, stdin: &mut R, menu: &Vec<&str>, x: u16, y: u16) -> io::Result<Option<u8>> {
let mut index: i8 = 0;
'outer: l... | true |
2e118d9e6436e4be761f10e891b388e0029d4c37 | Rust | Byron/gitoxide | /gix-tempfile/examples/delete-tempfiles-on-sigterm.rs | UTF-8 | 872 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[cfg(not(feature = "signals"))]
fn main() {
panic!("The `signals` feature needs to be set to compile this example");
}
#[cfg(feature = "signals")]
fn main() -> std::io::Result<()> {
use std::{
io::{stdout, Write},
path::PathBuf,
};
use gix_tempfile::{AutoRemove, ContainingDirectory};
... | true |
f1c1ecd5d10247bc99d612761b43fef97d0b448f | Rust | lauripiispanen/algorithms-coursera | /week0403/src/main.rs | UTF-8 | 1,647 | 2.9375 | 3 | [] | no_license | mod read_file;
extern crate clap;
use clap::{Arg, App};
fn main() {
let arg_matches = App::new("TSP with heuristics")
.arg(Arg::with_name("INPUT_FILE")
.help("Sets the input file to use")
.required(true)
.i... | true |
0e9dc9efb2205e3a804f57ceb08d9e23c9689a17 | Rust | logansquirel/rust-programming-language | /chapter03/programs/ftoc/src/main.rs | UTF-8 | 557 | 3.703125 | 4 | [
"MIT"
] | permissive | fn main() {
println!("Convert temperature from Fahrenheit to Celsius");
let fahr: f64 = loop {
println!("Please input your temperature in Fahrenheit");
let mut fahr = String::new();
std::io::stdin()
.read_line(&mut fahr)
.expect("failed to read line");
mat... | true |
bff3dca0a575bc98886830f127af3d9c0e77df06 | Rust | fourls/peas | /src/util/vec2.rs | UTF-8 | 2,578 | 3.390625 | 3 | [] | no_license | use cgmath::{num_traits::Num, AbsDiffEq};
use serde::{Deserialize, Serialize};
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Sub, SubAssign};
#[derive(Default, PartialEq, Eq, Clone, Copy, Hash, Debug, Serialize, Deserialize)]
pub struct Vec2<T>
where
T: Num + Copy,
{
pub x: T,
pub y: T,
}
... | true |
bf1706a76efb7c7407f36642d718af01f8376fc4 | Rust | murtyjones/birb | /crates/filing-parser/src/regexes/common/dividends_per_share.rs | UTF-8 | 1,295 | 2.90625 | 3 | [] | no_license | // regex
use regex::{Regex, RegexBuilder};
lazy_static! {
static ref PATTERN: &'static str = r"
^
\s* # sometimes there's whitespace before
(cash\s+)*
(dividends|distributions)
(\s+(declared|paid))*
\s+
per
\s+
(
... | true |
c4d1b05b213a864de7be3c474a6868a38ea64533 | Rust | sequenceplanner/sp-rust | /sp-formal/src/lib.rs | UTF-8 | 6,213 | 2.546875 | 3 | [
"MIT"
] | permissive | mod sp_fm_api;
use sp_fm_api::*;
pub mod planning;
use sp_domain::*;
use rayon::prelude::*;
use serde::{Serialize, Deserialize};
/// A "compiled" model that includes specifications generated by formal methods.
#[derive(Debug, PartialEq, Clone, Default, Serialize, Deserialize)]
pub struct CompiledModel {
pub model... | true |
a0737c2fab851b7f46ac8adbf458a6c05aa9a8ed | Rust | bgourlie/asm6502 | /src/tokens/mod.rs | UTF-8 | 1,339 | 2.703125 | 3 | [
"MIT"
] | permissive | #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum Mnemonic {
Adc,
And,
Asl,
Bcc,
Bcs,
Beq,
Bit,
Bmi,
Bne,
Bpl,
Brk,
Bvc,
Bvs,
Clc,
Cld,
Cli,
Clv,
Cmp,
Cpx,
Cpy,
Dec,
Dex,
Dey,
Eor,
Inc,
Inx,
Iny,
Jmp,
... | true |
38bebb2215061cb5dc1e2ef5ade428c9e3865013 | Rust | jacobian/advent2018-rust | /advent1_1/src/main.rs | UTF-8 | 590 | 3.25 | 3 | [] | no_license | use std::io::prelude::*;
use std::io::BufReader;
use utils;
fn main() {
let file = utils::open_argv1();
// use a buffer to read lines
// https://doc.rust-lang.org/std/fs/struct.File.html
// https://doc.rust-lang.org/std/io/trait.BufRead.html#method.lines
let buffer = BufReader::new(file);
let ... | true |
99a1ce61414d8d6e53bd189ee77037c95549755f | Rust | jeprojects/rust-headless-chrome | /src/protocol/mod.rs | UTF-8 | 8,366 | 2.765625 | 3 | [] | no_license | //! For (de)serializing method calls and events from the Chrome DevTools Protocol.
use std::fmt::Debug;
use crate::protocol::types::{JsInt, JsUInt};
use failure::{Fail, Fallible};
use serde;
use serde::{Deserialize, Serialize};
use serde_json::Value;
pub mod browser;
pub mod debugger;
pub mod dom;
pub mod fetch;
pub... | true |
5a8dcf3ea643fa8ed7c39bb9d893614c490a3ac8 | Rust | Drakulix/smithay | /src/backend/mod.rs | UTF-8 | 755 | 2.671875 | 3 | [
"MIT"
] | permissive | //! Backend (rendering/input) creation helpers
//!
//! Collection of common traits and implementation about
//! rendering onto various targets and receiving input
//! from various sources.
//!
//! Supported graphics backends:
//!
//! - winit
//!
//! Supported input backends:
//!
//! - winit
//! - libinput
pub mod inpu... | true |
af8cebb714ead520bf74968a3bd912ffc64e6fa7 | Rust | Harnesser/tiny-verilog-rs | /src/timeheap.rs | UTF-8 | 1,575 | 3.4375 | 3 | [
"WTFPL"
] | permissive | ///
/// Min-heap pointing to the next procedure to run at the closest time
///
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use procedure::{Time, ProcId};
#[derive(Eq, PartialEq)]
struct Entry {
time: Time,
proc_id: ProcId,
}
impl Ord for Entry {
fn cmp(&self, other: &Entry) -> Ordering {
... | true |
e4c9b16a627d8c51ec872414002e10105e96d26e | Rust | scolby33/adventofcode2017 | /src/day03.rs | UTF-8 | 2,499 | 3.125 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::collections::HashMap;
pub fn run() {
assert!(get_spiral_coords(11)==(2, 0));
assert!(get_spiral_coords(10)==(2, -1));
assert!(get_spiral_coords(1)==(0, 0));
assert!(get_spiral_coords(17)==(-2, 2));
assert!(solve1(1)==0);
assert!(solve1(12)==3);
assert... | true |
2448069534957a09b344d01c708fc4bbc3b2b726 | Rust | imoegirl/rust-by-example | /src/p059_option_unwrap.rs | UTF-8 | 897 | 3.625 | 4 | [] | no_license | fn give_commoner(gift: Option<&str>) {
match gift {
Some("snake") => println!("Yuck! I'm throwing that snake in a fire"),
Some(inner) => println!("{}? How nice.", inner),
None => println!("No gift? oh well."),
}
}
fn give_princess(gift: Option<&str>) {
let inside = gift.unwrap(); //... | true |
0b032f61ef3c3eedc6bf2a695d88748fed2183c9 | Rust | mationai/qwirkler | /src/piece.rs | UTF-8 | 1,789 | 3.1875 | 3 | [] | no_license | use rand::{thread_rng, Rng};
pub type Bag = Vec<Piece>;
#[derive(Copy, Clone, PartialEq, Debug, Eq)]
pub enum Colour {
R,O,Y,G,B,P
}
impl Colour {
pub fn index(&self) -> usize {
match *self {
Colour::R => 0,
Colour::O => 1,
Colour::Y => 2,
Colour::G => 3,
Colour::B => 4,
... | true |
243f1615bef942bc8db56f8ad6221cf289a68a6e | Rust | firefantasy/flowistry | /src/core/config.rs | UTF-8 | 2,517 | 2.875 | 3 | [
"MIT"
] | permissive | use anyhow::{bail, Context, Result};
use rustc_data_structures::sync::{Lrc, MappedReadGuard};
use rustc_macros::Encodable;
use rustc_span::{
source_map::{monotonic::MonotonicVec, SourceMap},
BytePos, FileName, RealFileName, SourceFile, Span,
};
use std::{default::Default, path::Path};
#[derive(Encodable, Debug, Cl... | true |
99650b3ef071037b1a10d94e9019915702b41a73 | Rust | updogliu/sparse-merkle-tree-map | /src/lib.rs | UTF-8 | 7,315 | 2.921875 | 3 | [
"MIT"
] | permissive | #![no_std]
#![allow(stable_features)]
#![feature(alloc)]
#[cfg(not(test))]
extern crate alloc;
#[cfg(test)]
#[macro_use]
extern crate alloc;
use alloc::collections::btree_map::BTreeMap;
use alloc::vec::Vec;
mod bit_op;
#[cfg(test)]
mod tests;
pub type Key = [u8; 32];
pub type Value = [u8; 32];
pub type Hash256 =... | true |
7a12b278177f91f0b56ef06205d34c74bf08d1e1 | Rust | philippeitis/RuzzleSolverRS | /src/recursive.rs | UTF-8 | 5,768 | 2.953125 | 3 | [] | no_license |
pub mod recursive_dfs {
/// Fills the board with word info using the recursive DFS algorithm.
fn all_combos(board: &mut Board) {
for i in 0..BOARD_SIZE {
for j in 0..BOARD_SIZE {
helper(board, (i << 2) | j);
}
}
}
/// Generates the necessary arg... | true |
3b1bed3a802c070023ca7e26aab738910fcb040a | Rust | LDiazN/TypeManager | /TypeManager/src/test_suite.rs | UTF-8 | 5,865 | 3.328125 | 3 | [] | no_license | #[allow(unused)]
use crate::utils::*;
#[allow(unused)]
use crate::type_system::*;
#[test]
fn test_gcd() {
// just test that gcd works ok
assert_eq!(gcd(4, 1), 1);
assert_eq!(gcd(4,4), 4);
assert_eq!(gcd(7,9), 1);
assert_eq!(gcd(3,9), 3);
}
#[test]
fn test_lcm() {
// test that lcm works ok
... | true |
478b592d8dc9616234a246c07d60c0a6cbdf52e1 | Rust | the-emerald/dogfish | /src/piece/mod.rs | UTF-8 | 648 | 2.953125 | 3 | [] | no_license | use crate::piece::colour::Colour;
use crate::piece::piecetype::PieceType;
pub mod colour;
pub mod piecetype;
pub mod attacks;
#[derive(Copy, Clone)]
pub struct Piece {
colour: Colour,
piece_type: PieceType
}
impl Piece {
pub fn new(colour: Colour, piece_type: PieceType) -> Self {
Self {
... | true |
785ed41e6d1104cfd2ad918d130a538ceec6c8aa | Rust | mudox/tav | /src/config.rs | UTF-8 | 3,627 | 2.78125 | 3 | [] | no_license | use std::collections::HashMap;
use std::error::Error;
use std::fs;
use std::path::{Path, PathBuf};
use clap::{crate_authors, crate_description, crate_name, crate_version, App, AppSettings};
use serde::Deserialize;
use crate::logging::*;
/// Return config dir string.
/// Return config dir.
pub fn dir() -> PathBuf {
... | true |
4dc34ec95adac6653064e60fe8f76e4b0af9b0d5 | Rust | nenad1002/advent-of-code-2020-rust | /Day9/src/main.rs | UTF-8 | 2,544 | 3.09375 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs::File;
use std::io::{self, BufRead};
use std::path::Path;
fn main() {
let instructions = read_input();
println!("{:?}", part_2_solution(instructions, 22406676));
}
fn part_1_solution(instructions: Vec<String>, preample_length: usize) -> i32 {
let mut map = HashM... | true |
230242cabb4ae836aac2fc77806dd109ce34ff1a | Rust | Botcoins/watchdog | /src/config.rs | UTF-8 | 955 | 2.84375 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::default::Default;
use std::fs::OpenOptions;
use std::io::Read;
use toml;
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct WatchdogCfg {
#[serde(skip)]
pub dir: String,
#[serde(default)]
pub auto_restart: bool,
#[serde(default)]
pub test_on_redeploy: bool... | true |
08abe5ff1104b9cb7d007d4a51b1ffbe8ef677e8 | Rust | benbrunton/pusoy_dos_server | /project/src/controller/logout.rs | UTF-8 | 912 | 2.765625 | 3 | [] | no_license | use config::Config;
use std::panic::RefUnwindSafe;
use controller::{Controller, ResponseType};
use model::Session;
use helpers::{PathExtractor, QueryStringExtractor};
pub struct LogoutController{
hostname: String
}
impl LogoutController{
pub fn new(config: &Config) -> LogoutController {
let hostname... | true |
7a1363153eb8db54ef53de2803e919c10f051afd | Rust | reinterpretcat/vrp | /rosomaxa/tests/unit/population/rosomaxa_test.rs | UTF-8 | 3,791 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use super::*;
use crate::example::*;
use crate::helpers::example::create_example_objective;
fn create_rosomaxa(rebalance_memory: usize) -> (Arc<VectorObjective>, Rosomaxa<VectorObjective, VectorSolution>) {
let mut config = RosomaxaConfig::new_with_defaults(4);
config.rebalance_memory = rebalance_memory;
... | true |
9f17cdad46a8536d09b64f398aee6d9f7b50454d | Rust | Stremio/stremio-core | /stremio-watched-bitfield/src/watched_bitfield.rs | UTF-8 | 11,228 | 3.296875 | 3 | [
"MIT"
] | permissive | use crate::{BitField8, Error};
use std::{
fmt::{self, Display},
str::FromStr,
};
/// (De)Serializable field that tracks which videos have been watched
/// and the latest one watched.
///
/// This is a [`WatchedBitField`] compatible field, (de)serialized
/// without the knowledge of `videos_ids`.
///
/// `{anch... | true |
e4356d5a9046bf353d938eece172b41beac46703 | Rust | sharpvik/idioma | /src/lib.rs | UTF-8 | 7,484 | 3.703125 | 4 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | #![crate_name = "idioma"]
#![crate_type = "lib"]
//! As Rust developers we deeply care about safety and error handling - our programs are fast and
//! reliable. However, users never make it easy for us: they misunderstand instructions and break
//! things. When we catch them doing something they shouldn't be doing, we... | true |
6f02a2a82d3f32a34af7df60d980f8658de68c66 | Rust | livioribeiro/advent-of-code | /src/day15.rs | UTF-8 | 5,109 | 2.890625 | 3 | [
"MIT"
] | permissive | use std::cmp;
use regex::Regex;
const INPUT: &'static str = include_str!("data/day15.txt");
pub fn part1() -> u32 {
calculate_part1(INPUT)
}
pub fn part2() -> u32 {
calculate_part2(INPUT)
}
fn calculate_part1(input: &str) -> u32 {
let ingredients = parse(input);
let mut total = 0;
let combs = B... | true |
fc6c9687e80949cf46874d21c99dc902e5bc5a1e | Rust | shinkou/scancsv | /src/scancsv.rs | UTF-8 | 4,503 | 2.796875 | 3 | [
"MIT"
] | permissive | use std::fs::{File, OpenOptions};
use std::io::{BufRead, BufReader, Read, Write};
use std::io;
use std::path::Path;
use bzip2::read::BzDecoder;
use flate2::read::GzDecoder;
use regex::Regex;
use tar::Archive;
use xz2::read::XzDecoder;
pub enum Compression
{
Plain
, Bzip2
, Gzip
, Xz
}
pub struct ScanCsv<'a>
{
p... | true |
50470a3dc6bfcc7779fc96c55c1ff4e97de5e9ba | Rust | bradwood/git_lab_rust | /src/subcommand.rs | UTF-8 | 986 | 3.125 | 3 | [
"MIT"
] | permissive | use crate::config;
use anyhow::Result;
/// All subcommands need to implement this interface.
pub trait SubCommand {
/// Generates the cli-config that Clap requires for the subcommand.
fn gen_clap_command(&self) -> clap::App;
/// Runs the body of the subcommand.
fn run(&self, config: config::Config, ar... | true |
050051fda45eae0a80df44cee02d5eef1c857966 | Rust | tehAnswer/learning_rust | /while/src/main.rs | UTF-8 | 120 | 2.9375 | 3 | [] | no_license | fn main() {
let mut x = 5;
let mut done = false;
while x % 5 != 0 {
x += x - 3;
println!("{}", x);
}
}
| true |
6044d6d39a555ff499f97b5a167b552010b7fe76 | Rust | shijuleon/rocker | /src/container.rs | UTF-8 | 1,834 | 2.609375 | 3 | [] | no_license | use futures::stream::TryStreamExt;
use ipnetwork::IpNetwork;
use rand::Rng;
use rtnetlink;
use tokio;
use crate::image::Image;
pub struct Container<'a> {
name: String,
image: &'a Image<'a>,
}
fn rand_name() -> String {
let mut rng = rand::thread_rng();
let adj = ["speedy", "furious", "calm", "cunning"];
le... | true |
4723588381adae262143b3f365c728e20543160e | Rust | pretentious7/canvas-example | /src/lib.rs | UTF-8 | 3,133 | 2.84375 | 3 | [] | no_license | use std::f64;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use js_sys::{Uint8ClampedArray, WebAssembly};
// neat macro wrapper for js console.log
#[allow(unused_macros)]
macro_rules! log {
( $( $t:tt )* ) => {
web_sys::console::log_1(&format!( $( $t )* ).into());
}
}
// struct for complex ... | true |
7fe57cabbf2547ea4ae3ef47e9c43e1e5cf3245e | Rust | jgs1202/scalableGIB | /trgib/rust-fd-layout/src/group_force.rs | UTF-8 | 2,072 | 3.09375 | 3 | [
"MIT"
] | permissive | use force::{Force, Point};
use many_body_force::ManyBodyForce;
#[derive(Copy, Clone, Debug)]
pub struct Group {
pub x: f32,
pub y: f32,
pub dx: f32,
pub dy: f32,
}
impl Group {
pub fn new(x: f32, y: f32, dx: f32, dy: f32) -> Group {
Group {
x: x,
y: y,
d... | true |
68c7342569d426e1b09cd8a23c82c45039b65d1c | Rust | AusCyberman/rust-http-tunnel | /src/transmission.rs | UTF-8 | 2,078 | 3.34375 | 3 | [] | no_license | use std::convert::TryFrom;
use std::fs::File;
use std::io::Read;
use std::sync::{Arc,Mutex};
pub fn encode(data: Vec<u8>) -> String {
base64::encode(data)
}
pub fn decode(data: Vec<u8>) -> Vec<u8> {
base64::decode(data).unwrap()
}
fn unpacku32(num: &u32) -> [u8; 4] {
num.to_be_bytes()
}
fn packu32(arr: &[u... | true |
9c1e2993bb219a638ccab70468196960f054dd67 | Rust | exercism/rust | /exercises/practice/proverb/tests/proverb.rs | UTF-8 | 2,010 | 2.84375 | 3 | [
"MIT"
] | permissive | use proverb::build_proverb;
#[test]
fn test_two_pieces() {
let input = vec!["nail", "shoe"];
let expected = [
"For want of a nail the shoe was lost.",
"And all for the want of a nail.",
]
.join("\n");
assert_eq!(build_proverb(&input), expected);
}
// Notice the change in the last l... | true |
4218f107cc0c51506dfc6974504757f3416fd2e2 | Rust | lefebvreb/Rust-Othello | /src/types.rs | UTF-8 | 3,496 | 3.453125 | 3 | [] | no_license | use crate::othello::*;
//#################################################################################################
//
// BITBOARD TYPE
//
//#################################################################################################
/*
* The BitBoard type, a 64-bits un... | true |
9ad5f5cb3846e96882081cedd5fc6d0a6b856f66 | Rust | tipulabs/tipu | /src/components/app.rs | UTF-8 | 1,285 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | use tui::{
backend::Backend,
layout::Rect,
style::{Color, Style},
text::Span,
widgets::{Block, BorderType, Borders},
Frame,
};
pub struct App<'a> {
size: Rect,
title: &'a str,
is_focused: bool,
}
impl<'a> Default for App<'a> {
fn default() -> Self {
App {
ti... | true |
9abfdcb790179400fa302c283c52c2211fede5e1 | Rust | mokua/crust | /src/mount.rs | UTF-8 | 12,512 | 2.625 | 3 | [] | no_license | use crate::spec::{Mount, Spec};
use nix::mount::MsFlags;
use nix::sys::stat::{Mode, SFlag};
use nix::unistd::{chdir, mkdir};
use nix::{Error, NixPath};
use std::fmt;
use std::ops::BitAnd;
use flexi_logger::{LevelFilter, LogSpecification, Logger};
use nix::fcntl::{open, openat, OFlag};
use nix::sys::stat;
const put_ol... | true |
4f7c171f1fc4c758d82325881d567cd8aa39f4b3 | Rust | ledbettj/aoc2018 | /rust/src/day4.rs | UTF-8 | 567 | 2.765625 | 3 | [] | no_license |
use regex::Regex;
const INPUT : &str = include_str!("../inputs/day4.txt");
enum Event {
NewGuard { id: u32, hour: u32, min: u32 },
Asleep { id: u32, hour: u32, min: u32 },
Awake { id: u32, hour: u32, min: u32 }
}
// fn load_events(input: &str) -> Vec<Event> {
// let re = Regex::new(r"\[\d{4}-\d{2}-\... | true |
6b6e0e2ee74282ba40150b4221adcb09a4747310 | Rust | Frezc/relative-time-expression-rust | /src/error.rs | UTF-8 | 805 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::error::Error as StdError;
use std::fmt::{self, Display, Formatter};
use Error::*;
#[derive(Debug, PartialEq)]
pub enum Error {
EOFError {
expect: String,
},
Normal {
expect: String,
actual: String,
start: usize,
end: usize,
},
Unknown {
actual: String,
start: usize,
e... | true |
1a222db7a71863f3e13a293cc83fadf8d57ef2dc | Rust | 5hyn3/learn-rust | /19/5/macros/src/main.rs | UTF-8 | 265 | 2.546875 | 3 | [] | no_license | #[macro_export]
macro_rules! myVec {
( $( $x:expr ),* ) => {
{
let mut temp_vec = Vec::new();
$(
temp_vec.push($x);
)*
temp_vec
}
};
}
fn main() {
let v = myVec!(1,2,3);
}
| true |
d3988cde77e13ad2217c4807694173b8ee13699e | Rust | sideffect0/gol | /sys/sys/src/main.rs | UTF-8 | 162 | 3.203125 | 3 | [] | no_license | fn main() {
loop{
check_if_safe(format!("Safe {}", "Borrows"));
}
}
fn check_if_safe(s_borrow: String){
println!("Pure, {}!", s_borrow);
}
| true |
4d5052ac6b009b1bf55cd6534949dc9e7a60631f | Rust | andogq/Advent-of-Code-2020 | /day06_custom_customs/src/main.rs | UTF-8 | 910 | 3.109375 | 3 | [] | no_license | use std::fs;
use std::collections::HashMap;
fn main() {
let input = fs::read_to_string("input.txt").expect("Problem reading input file");
let mut part_a_count = 0;
let mut part_b_count = 0;
for line in input.split("\n\n") {
let mut used: HashMap<char, usize> = HashMap::new();
let mut ... | true |
99f4e72033a7356c35ca45bc349206db7406578c | Rust | SarthakU/DailyProgrammer | /Rust/Daily002_easy/InterestCalculator.rs | UTF-8 | 564 | 3.15625 | 3 | [] | no_license | // INTEREST CALCULATOR
//
// challenge #2 (easy)
// http://www.reddit.com/r/dailyprogrammer/comments/pjbj8/easy_challenge_2/
//
// sarthak7u@gmail.com
//
fn main() {
// simple interest
println!("{}",simple_interest(100.0, 5.0, 10.0));
// comppund interest
println!("{}",compound_interest(100.0, 5.0, 10... | true |
101bc95e27aeffd29b7943fa4021f5534e06b054 | Rust | kryo4096/reduk | /src/keyboard/keymap/mod.rs | UTF-8 | 900 | 2.890625 | 3 | [] | no_license | pub mod de_ch;
use keyboard::Scancode;
#[derive(Clone, Copy)]
pub enum NonPrinting {
None,
Shift,
Ctrl,
Alt,
CapsLock,
ScrollLock,
NumLock,
Escape,
Backspace,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
}
#[derive(Clone, Copy)... | true |
02f859047886b441bc24f28bfd5277d5436b6175 | Rust | lucifer1004/AtCoder | /abc233/src/bin/c.rs | UTF-8 | 524 | 2.640625 | 3 | [] | no_license | use proconio::input;
fn dfs(c: u128, p: usize, x: u128, bags: &Vec<Vec<u128>>, ans: &mut usize) {
if p == bags.len() {
if c == x {
*ans += 1;
}
return
}
for &num in bags[p].iter() {
if c * num <= x && x % (c * num) == 0 {
dfs(c * num, p + 1, x, bags,... | true |
a24915bdb9ef456029b54684a5f54d183ed08404 | Rust | cptroot/FerrOS | /lib/gnu-efi/src/err.rs | UTF-8 | 1,840 | 2.59375 | 3 | [] | no_license |
const STATUS_ERROR: usize = 0x8000000000000000;
/// A representation of all UEFI error values
/// All error status have the high bit set
#[repr(usize)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum Status {
Success = 0,
LoadError = STATUS_ERROR | 1,
InvalidParameter = STATUS_E... | true |
8a43f767688b751d933a045e95bc42457b371497 | Rust | mucaho/shipyard | /tests/delete_entity.rs | UTF-8 | 2,104 | 2.609375 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use core::any::type_name;
use shipyard::error;
use shipyard::*;
#[test]
fn no_pack() {
let world = World::new();
let (mut entities, mut usizes, mut u32s) = world
.borrow::<(EntitiesViewMut, ViewMut<usize>, ViewMut<u32>)>()
.unwrap();
let entity1 = entities.add_entity((&mut usizes, &mut u32... | true |
0c8cac2e9972963d3af4091436b96a7cf15be509 | Rust | vindvaki/advent-of-code-2017 | /src/bin/day_05.rs | UTF-8 | 1,416 | 3.15625 | 3 | [] | no_license | extern crate aoc2017;
use aoc2017::read_fixture;
fn main() {
let data = read_fixture();
let maze: Vec<i32> = data
.split_whitespace()
.map(|x| str::parse(x).expect("unable to parse number"))
.collect();
println!("part_1: {}", part_1(&maze));
println!("part_2: {}", part_2(&maze)... | true |
355081e685b8e04937ba6fd12bdbf8ef0c423d52 | Rust | alexanderreiff/adventofcode2019 | /day3/src/path.rs | UTF-8 | 720 | 3.53125 | 4 | [] | no_license | use crate::movement::Movement;
pub type Path = Vec<Movement>;
pub fn path_from_str(path_str: &str) -> Path {
path_str
.split(',')
.filter_map(|move_str| move_str.parse().ok())
.collect()
}
#[cfg(test)]
mod path_tests {
use super::*;
#[test]
fn it_parses_a_directions_string_co... | true |
94c4e2637e0372f20f023d02bc75dd7c127ccfd3 | Rust | krooken/AdventOfCode2020 | /day_01/src/main.rs | UTF-8 | 364 | 2.796875 | 3 | [] | no_license | use day_01;
fn main() {
let values = day_01::get_expenses("data/ExpenseReport.txt");
let pair = day_01::find_pair_with_sum(2020, &values);
println!("The product is: {}", day_01::product_of_pair(pair));
let triple = day_01::find_triple_with_sum(2020, &values);
println!("The product of the triple is... | true |
7ec26395673cc9716ae5dd75cf351e5b60444c86 | Rust | Sylfid/ProjetEnsimag | /Rust/TP1/exo3/src/main.rs | UTF-8 | 441 | 3.40625 | 3 | [] | no_license | #[derive(Debug)]
enum Couleur {
Rouge,
Vert,
Bleu,
}
#[derive(Debug)]
struct Point {
x: f64,
y: f64,
couleur: Option<Couleur>,
}
impl Point{
fn new(s: f64, t: f64)->Self{
Point{x:s,y:t,couleur:None}
}
fn dist(&self, a: Point)->f64{
((self.x - a.x).powi(2)+(self.y - a.y).powi(2)).sqrt()
... | true |
0ca112348f99a26d477ec793cf125c2a90d37463 | Rust | MarkMcCaskey/rusty-boy | /src/cpu/constants.rs | UTF-8 | 5,829 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | //! Constant values relating to the CPU
#[allow(non_camel_case_types)]
pub type byte = u8;
/// Cannot index memory directly, must be cast to a `usize`
pub type MemAddr = u16;
/// Location of the `Z` flag in the `F` register
pub const ZL: byte = 0x80;
/// Location of the `N` flag in the `F` register
pub const NLV: byte... | true |
0ab56cc055f15528cf8c683f483c72daf943b7e7 | Rust | jakemarsden/dominoes.rs | /src/tokenizer/tests.rs | UTF-8 | 3,918 | 3 | 3 | [
"MIT"
] | permissive | use super::error::ParseError::*;
use super::token::Token::*;
use super::token::{Attributes, TagKind};
use super::TokenizerImpl;
#[test]
fn empty_document() {
let input = "";
let tokenizer = TokenizerImpl::new(input.into());
let actual: Vec<_> = tokenizer.collect();
let expected = [Ok(EndOfFile)];
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.