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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
b573afc868250f87c423814753a0db9a031efc9f | Rust | gmjosack/pagersduty | /src/rest/v2/types/notification_rules.rs | UTF-8 | 6,350 | 2.8125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use ::rest::v2::types::contact_methods::ContactMethod;
#[derive(Serialize, Deserialize, Debug, PartialEq)]
#[serde(tag = "type")]
pub enum NotificationRule {
#[serde(rename="assignment_notification_rule_reference")]
Reference {
id: String,
/// A short-form, server-generated string that provid... | true |
824e4564ec1bf933bdba9ecddd857f8d0f990e12 | Rust | yelite/refinery | /refinery_migrations/src/config.rs | UTF-8 | 2,119 | 2.796875 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
///Config used by refinery-cli
#[derive(Serialize, Deserialize)]
pub struct Config {
pub main: Main,
}
#[derive(Serialize, Deserialize, PartialEq)]
pub enum ConfigDbType {
Mysql,
Postgres,
Sqlite,
}
impl Config {
pub fn new(db_type: ConfigDbType) -> Config {
... | true |
5b5358eee0ba4c80936d5515a68ed0c9b1735b0b | Rust | divinerapier/adal-im | /src/server/mod.rs | UTF-8 | 3,027 | 2.90625 | 3 | [] | no_license | use crate::data::SyncData;
use crate::error::Error;
use crate::protocol::{BinaryProtocol, Context, MessageType, Packet};
use crate::service::Handler;
use std::collections::HashMap;
use std::sync::{Arc, RwLock};
pub mod manager;
#[allow(dead_code)]
pub struct Server {
services: Arc<RwLock<HashMap<MessageType, Han... | true |
30d5a9ef8fed6595f119820e68a4cf57d0f71c55 | Rust | andruekonst/Woods | /src/ensemble/mod.rs | UTF-8 | 4,686 | 2.953125 | 3 | [
"MIT"
] | permissive | use serde::{Serialize, Deserialize};
use ndarray::{ArrayView2, ArrayView1, Array1, Array2, stack, Axis};
use crate::utils::numerics::D;
use crate::estimator::*;
use rayon::prelude::*;
pub mod boosting;
pub mod deep_boosting;
/// Ensemble of estimators.
///
/// It can be constructed by number of estimators (`width`) ... | true |
9dbf3681dbdf46d945ddadcad0a46f808e01ed7c | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/base16ct-0.1.1/src/lib.rs | UTF-8 | 3,759 | 3.1875 | 3 | [
"BSD-2-Clause",
"MIT",
"Apache-2.0"
] | permissive | //! Pure Rust implementation of Base16 ([RFC 4648], a.k.a. hex).
//!
//! Implements lower and upper case Base16 variants without data-dependent branches
//! or lookup tables, thereby providing portable "best effort" constant-time
//! operation. Not constant-time with respect to message length (only data).
//!
//! Supp... | true |
89349707d1450fa94077b0d9de7243041c18e0bc | Rust | deadcode/fiddle | /fiddle.rust/listing_4_6/src/main.rs | UTF-8 | 176 | 3.375 | 3 | [
"BSD-2-Clause"
] | permissive | fn main() {
let mut s1 = String::from("Hello");
change_str(&mut s1);
println!("s1 = {}", s1);
}
fn change_str(str: &mut String) {
str.push_str(" World!");
}
| true |
960ce1f2c19cbbe8261db76d000f3fb3fd0508c6 | Rust | elauffenburger/sixty-five-oh-too | /src/cpu/instr/bit.rs | UTF-8 | 1,899 | 3.125 | 3 | [] | no_license | use super::Cpu;
use super::InstrResult;
use super::super::addr::AddrResult;
use super::super::addr;
use util;
use std::fmt;
pub fn zero_page(cpu: &mut Cpu) -> Box<InstrResult> {
let addr_result = addr::zero_page(cpu);
bit(addr_result, 2, 3)
}
pub fn abs(cpu: &mut Cpu) -> Box<InstrResult> {
let addr_resu... | true |
835ddcf6eeba6c558512489e597bd1ac88d9439d | Rust | lemunozm/torophy | /examples/monitor/renderer.rs | UTF-8 | 3,981 | 3.046875 | 3 | [
"Apache-2.0"
] | permissive | use glium::{implement_vertex, uniform, Display, Program, Frame, Surface};
#[derive(Copy, Clone)]
pub struct Vertex {
position: [f32; 2],
}
implement_vertex!(Vertex, position);
impl Vertex {
pub fn new(x: f32, y: f32) -> Vertex {
Vertex { position: [x, y] }
}
}
pub struct Color {
data: [f32; ... | true |
9ff5ad65d0e87bba8564f15ee97c7dd397dc1b42 | Rust | pwmarcz/chiprs | /chiprs-sdl/src/sdl_interface.rs | UTF-8 | 3,426 | 2.6875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate sdl2;
extern crate chiprs;
use sdl2::pixels::Color;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::render::WindowCanvas;
use sdl2::rect::Rect;
use std::time::{Duration, Instant};
use chiprs::Chip;
use chiprs::display::{Display, DISPLAY_W, DISPLAY_H};
const PIXEL_W: usize = 10;
const PIXE... | true |
0712e886bd972c3f71e62a33ecb20af9ca5f22d8 | Rust | placrosse/lvgl-rs | /examples/arc.rs | UTF-8 | 3,036 | 2.578125 | 3 | [
"MIT"
] | permissive | use embedded_graphics::pixelcolor::Rgb565;
use embedded_graphics::prelude::*;
use embedded_graphics_simulator::{
OutputSettingsBuilder, SimulatorDisplay, SimulatorEvent, Window,
};
use lvgl::style::Style;
use lvgl::widgets::{Arc, ArcPart, Label, LabelAlign};
use lvgl::{self, Align, Color, DisplayDriver, Part, State... | true |
74077fe3b7ff33626c3160ea27dbf2aa043f3720 | Rust | brennengarland/thesis | /src/functions/rotate_entity.rs | UTF-8 | 260 | 2.578125 | 3 | [] | no_license | use super::*;
pub fn rotate_entity(pos: &mut Position, sen: &Antenna) {
pos.direction = (pos.direction + sen.azimuth_beam_width / 2.0) % 360.0;
}
// #[cfg(test)]
// mod tests {
// use super::*;
// #[test]
// fn test_rotate() {
// }
// } | true |
60eea663b1e18213c5e8a4f4fe16af609361e591 | Rust | oshbec/grit | /tests/commit.rs | UTF-8 | 1,603 | 2.578125 | 3 | [] | no_license | mod common;
use chrono::Local;
use common::TestBed;
use grit::commands::{commit, init};
use std::{env, fs};
#[test]
fn creates_objects_found_in_real_git_commit() {
let test_bed = TestBed::setup();
init(Some(&test_bed.workspace()));
test_bed.create_file("README", "This is the README");
test_bed.creat... | true |
50519b77f2ca30dfa0ea14546030446d182d2c4f | Rust | michaelfletchercgy/rainguage | /rainguage-firmware/src/analog_pin.rs | UTF-8 | 3,162 | 2.71875 | 3 | [] | no_license | extern crate feather_m0 as hal;
use crate::hal::pac::ADC;
use crate::hal::clock::GenericClockController;
pub struct AnalogPin {
adc: ADC
}
impl AnalogPin {
pub fn new(clocks:&mut GenericClockController, adc:ADC) -> AnalogPin {
let mut result = AnalogPin {
adc
};
// The ca... | true |
9010f732e2da904495847be2205d88d136aa3474 | Rust | Bromind/rfs | /src/rfs_common.rs | UTF-8 | 1,598 | 3.171875 | 3 | [] | no_license | //! This module contains common definitions to rfs_client and rfs_server.
use blowfish::Blowfish;
use block_cipher_trait::BlockCipherVarKey;
use std::io::BufReader;
use std::io::Read;
use config::Field;
/// BlowfishKey type.
pub type BlowfishKey = Vec<u8>;
/// Challenge type.
pub type Challenge = Vec<u8>;
/// Return... | true |
0ac48e694372d6ad40b6e8df423e08fed14d8d56 | Rust | sirkibsirkib/lilbits | /src/tests.rs | UTF-8 | 2,646 | 3.421875 | 3 | [
"MIT"
] | permissive | // #[macro_use]
use super::*;
use std::collections::HashSet;
use std::thread;
fn some_vec() -> Vec<u8> {
vec![1,3,5,6,7,10,12,17,18,19,26,33,35,
36,39,40,50,52,54,54,56,57,60,63]
}
#[test]
fn to_hashset_and_back() {
let start = vec![1,3,5,6,7,10,12,17,18,19,26,
33,35,36,39,40,5... | true |
ccd331c7a38bc2bdddcf65ac5fcfb873094dd8b9 | Rust | morganfogg/zanthe | /src/game/state.rs | UTF-8 | 14,342 | 2.71875 | 3 | [
"MIT"
] | permissive | use std::cmp::min;
use std::collections::VecDeque;
use std::vec::Vec;
use crate::game::Result;
use rand::{rngs::StdRng, SeedableRng};
use tracing::debug;
use crate::game::error::GameError;
use crate::game::instruction::{
Form, Instruction, InstructionSet, OpCode, Operand, OperandSet, Result as InstructionResult,
... | true |
669db5de5ca85eb8c2985fa6be5d84c8e3456045 | Rust | mitsuhiko/minijinja | /minijinja/src/loader.rs | UTF-8 | 6,774 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | use std::borrow::Cow;
use std::collections::BTreeMap;
use std::fmt;
use std::fs;
use std::io;
use std::path::Path;
use std::path::PathBuf;
use std::sync::Arc;
use memo_map::MemoMap;
use self_cell::self_cell;
use crate::compiler::lexer::SyntaxConfig;
use crate::error::{Error, ErrorKind};
use crate::template::CompiledT... | true |
73c9ce9728b2a48924e52ec245b9685142d60739 | Rust | loyd/chokurei | /common/key.rs | UTF-8 | 2,704 | 3.375 | 3 | [] | no_license | use std::fmt;
use url::Url;
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Key(String);
impl From<String> for Key {
fn from(string: String) -> Key {
Key(string)
}
}
impl From<Url> for Key {
fn from(url: Url) -> Key {
let host = url.host_str().map(|host| host.trim_left_matches("w... | true |
fefda3a5b352f5db766adc39000e459e2d611b19 | Rust | alexpearce/adventofcode_2017 | /src/day3/mod.rs | UTF-8 | 5,272 | 3.859375 | 4 | [
"Unlicense"
] | permissive | //! Solutions to day 3.
use std::collections::HashMap;
use std::iter;
use std::ops::Add;
#[derive(Debug,Hash,PartialEq,Eq,Copy,Clone)]
struct Coordinate {
x : isize,
y : isize
}
impl<'a, 'b> Add<&'b Coordinate> for &'a Coordinate {
type Output = Coordinate;
fn add(self, other : &'b Coordinate) -> Co... | true |
8b7c86ab945386fcd234640162cc37b6b689127c | Rust | LudoSpill/monkeys_v2 | /src/model/monkeys.rs | UTF-8 | 11,952 | 3.25 | 3 | [
"MIT"
] | permissive | use rand::Rng;
use super::pirate::Pirate;
use super::island::Direction;
pub trait MonkeyMove {
fn monkey_move(&mut self, pirate: Pirate, hunters: Vec<HunterMonkey>, erratics: Vec<ErraticMonkey>);
}
#[derive(Clone, Copy, PartialEq)]
pub struct HunterMonkey {
x: i8,
y: i8,
island_size: usize
}
impl Hu... | true |
ac770315a78efeb2f1b5ab803ea8de69184edddc | Rust | whitfin/efflux | /src/context/offset.rs | UTF-8 | 1,054 | 3.625 | 4 | [
"MIT"
] | permissive | //! Offset bindings to provide byte offsets for `Mapper` stages.
/// Offset structure to allow tracking of the current byte.
///
/// This offers little more than abstraction over the byte
/// offset being tracked manually; however the strong typing
/// allows `Offset` to be added to a `Context`.
#[derive(Debug, Defaul... | true |
3611230d022427b6d3b8acbff8d2438454f35d15 | Rust | mre/svg-metadata | /src/error.rs | UTF-8 | 1,106 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use roxmltree::Error as XMLError;
use std::error::Error;
use std::fmt;
use std::io::Error as IoError;
use std::num::ParseFloatError;
#[derive(Debug)]
/// The error type of the library, which gets
/// returned on parsing issues.
pub struct MetadataError {
details: String,
}
impl MetadataError {
pub fn new(msg:... | true |
5e0aa1b883512e6c47db39a20f98f556a69f6309 | Rust | jimfulton/byteserver | /src/index.rs | UTF-8 | 2,216 | 2.859375 | 3 | [
"MIT"
] | permissive | // File-storage index-file and mmap index
use std::io::prelude::*;
use byteorder::{ReadBytesExt, WriteBytesExt};
use crate::util;
pub type Index = std::collections::btree_map::BTreeMap<util::Oid, u64>;
static MAGIC: &'static [u8] = b"fs2i";
pub fn save_index(index: &Index, path: &str,
segment_siz... | true |
65107ef2e10fe503cc264e72e8c65c74ec081100 | Rust | lineCode/tuix | /examples/editor/src/canvas_options.rs | UTF-8 | 1,216 | 2.828125 | 3 | [
"MIT"
] | permissive |
use tuix::*;
#[derive(Default)]
pub struct CanvasOptionsDropdown {
popup: Entity,
}
impl CanvasOptionsDropdown {
pub fn new() -> Self {
Self {
popup: Entity::null(),
}
}
}
impl Widget for CanvasOptionsDropdown {
type Ret = Entity;
type Data = ();
fn on_build(&mut... | true |
ae5c58b1ec5ff586386a3be6d1817103cd38910a | Rust | DangerFunPants/cpsc_of_testbed | /traffic-generation-rs/src/main.rs | UTF-8 | 4,878 | 2.875 | 3 | [] | no_license |
use std::net::*;
use serde::{Serialize, Deserialize};
use serde_json::{Result, Value};
use std::io;
use std::time;
use std::io::{BufRead, Read};
use std::option::Option;
use std::thread;
#[derive(Serialize, Deserialize, Debug)]
enum TrafficModel {
Uniform,
TruncNorm,
RandomSampling,
TruncNormSymmetric... | true |
e3326ead44a6fa0d7becff5eabab760a21621200 | Rust | bokuweb/mtpc | /src/parser/map.rs | UTF-8 | 537 | 2.90625 | 3 | [] | no_license | use crate::errors::ParserError;
use crate::parser::Parser;
#[derive(Copy, Clone)]
pub struct Map<P, F>(P, F);
impl<A, B, P, F> Parser for Map<P, F>
where
P: Parser<Output = A>,
F: Fn(A) -> B,
{
type Output = B;
fn parse<'a>(&self, input: &'a str) -> Result<(Self::Output, &'a str), ParserError> {
... | true |
1ecc9c60a9d82be314eaab462b9b0e0a2ed37798 | Rust | itto-ki/atcoder | /ABC/013/A.rs | UTF-8 | 237 | 3 | 3 | [] | no_license | fn read_char() -> char {
let mut input = String::new();
let _ = std::io::stdin().read_line(&mut input);
input.trim().parse().unwrap()
}
fn main() {
let x = read_char();
println!("{}", (x as u8) - ('A' as u8) + 1);
}
| true |
f5874f897058357378b25530f91df49597ec8d69 | Rust | shinespark/the-rust-programming-language | /lifetimes/src/main.rs | UTF-8 | 465 | 3.984375 | 4 | [] | no_license | fn main() {
// 黙示的に
fn foo(x: &i32) {
}
// 明示的に
fn bar<'a>(x: &'a i32) {
}
// 'a: ライフタイムaと読む
// implブロック
let y = &5; // これは`let _y = 5; let y = &_y;`と同じ
let f = Foo { x: y };
println!("x is: {}", f.x());
// 'static
let x: &'static str = "Hello, world.";
}
stru... | true |
c9975c539adec24be8c1a9b565603e038c65df59 | Rust | ktmlm/crypto | /src/blockcipher/mod.rs | UTF-8 | 2,424 | 2.84375 | 3 | [
"MIT"
] | permissive |
mod rc2;
mod sm4;
mod aes;
mod aria;
mod camellia;
pub use self::rc2::*;
pub use self::sm4::*;
pub use self::aes::*;
pub use self::aria::*;
pub use self::camellia::*;
#[allow(non_camel_case_types)]
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum BlockCipherKind {
SM4,
RC2_FIXED_SIZE,
AES128... | true |
955be7ceb982f3392bb27472e86220795be48791 | Rust | MaxOhn/Bathbot | /bathbot-macros/src/flags.rs | UTF-8 | 1,366 | 2.671875 | 3 | [
"ISC"
] | permissive | use proc_macro2::TokenStream;
use quote::{quote, ToTokens};
use syn::{
parse::{Parse, ParseStream},
punctuated::Punctuated,
token::Comma,
Attribute, Ident, Result,
};
pub struct Flags {
list: Punctuated<Ident, Comma>,
}
impl Flags {
pub fn new() -> Self {
Self {
list: Punct... | true |
e5c5848a6cb22b72b1899fa3927f4d703f44eb63 | Rust | volker48/advent-of-code | /2021/src/day6.rs | UTF-8 | 1,366 | 3.078125 | 3 | [] | no_license | use crate::helpers;
enum FishUpdate {
OneFish(Fish),
TwoFish(Fish, Fish),
}
#[derive(Debug, Clone, Copy)]
struct Fish {
timer: i32,
}
impl Fish {
fn new(timer: i32) -> Fish {
Fish { timer }
}
fn update(self) -> FishUpdate {
match self.timer {
x if x > 0 => FishUpda... | true |
af977238d9d66136507064d5c31e9060e94055b8 | Rust | tlambertz/rusty-hermit | /hermit-sys/src/net/waker.rs | UTF-8 | 1,556 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | /// The waker registration is derived from smoltcp waker registration
use core::task::Waker;
/// Utility struct to register and wake a waker.
#[derive(Debug)]
pub(crate) struct WakerRegistration {
waker: Option<Waker>,
}
impl WakerRegistration {
pub(crate) const fn new() -> Self {
Self { waker: None }
}
/// Re... | true |
a4d6facb739f1502de122ba4fcfbba5cd96ecf40 | Rust | stjordanis/interpret-1 | /src/alt/jump_stack.rs | UTF-8 | 4,209 | 2.71875 | 3 | [] | no_license | use crate::typ::{add, Expr};
use crate::{
stack::{Stack, StackOwner},
tape::Tape,
};
type Compiled<'a> = fn(Stack<'a, i64>, Tape<'a, isize>);
fn call<'a>(k: isize, stack: Stack<'a, i64>, tape: Tape<'a, isize>) {
let k: Compiled<'a> = unsafe { std::mem::transmute(k) };
k(stack, tape)
}
fn measure(x: &... | true |
1ed280a5ba13ee7b584cffac827bf2734e49b4c5 | Rust | ljgago/advent-of-code-2020 | /day14/src/part_one.rs | UTF-8 | 1,060 | 3.25 | 3 | [
"MIT"
] | permissive | // part_one.rs
use std::collections::HashMap;
use crate::common::Program;
fn apply_mask(mask: String, num: usize) -> Option<usize> {
let mask_on: usize = usize::from_str_radix(&mask.replace("X", "0"), 2).unwrap();
let mask_off: usize = usize::from_str_radix(&mask.replace("X", "1"), 2).unwrap();
Some((nu... | true |
6838a79cae05ae3b768e81b78cf5d86fa4173551 | Rust | jacklund/aws-instance | /src/commands/list.rs | UTF-8 | 2,592 | 2.59375 | 3 | [] | no_license | use crate::{util, Result};
use rusoto_ec2::Ec2Client;
use serde_json::{Map, Value};
pub async fn list(ec2_client: &Ec2Client, ansible: bool) -> Result<()> {
let instances = util::get_all_instances(ec2_client).await?;
if ansible {
let mut inventory = Map::new();
for instance in instances {
... | true |
de9ad7203b4d04fd3bab2a542f8ae4a4a029b658 | Rust | snorrwe/morton-table | /morton-table/src/morton_table/tests.rs | UTF-8 | 4,317 | 2.859375 | 3 | [
"MIT"
] | permissive | use super::*;
use rand::prelude::*;
use std::collections::{HashMap, HashSet};
#[test]
fn insertions() {
let mut table = MortonTable::new();
table.insert(Point::new(16, 32), Value(123)).unwrap();
}
#[test]
fn test_range_query_all() {
for _ in 0..16 {
test_range_query_all_impl();
}
}
fn test_r... | true |
29ed93e5c7918c0f0736f531748fcd5d69f5ea23 | Rust | Byron/gitoxide | /gix-object/src/commit/mod.rs | UTF-8 | 5,620 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::ops::Range;
use bstr::{BStr, BString, ByteSlice};
use crate::{Commit, CommitRef, TagRef};
mod decode;
///
pub mod message;
/// A parsed commit message that assumes a title separated from the body by two consecutive newlines.
///
/// Titles can have any amount of whitespace
#[derive(PartialEq, Eq, Debug, Ha... | true |
83dcc0a3957ac2709ce9129a85e7e7abea635b3e | Rust | dsherret/swc | /ecmascript/minifier/src/debug.rs | UTF-8 | 2,996 | 2.75 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use once_cell::sync::Lazy;
use std::{env, process::Command};
use swc_common::{sync::Lrc, SourceMap, SyntaxContext};
use swc_ecma_ast::{Ident, Module, StrKind};
use swc_ecma_codegen::{text_writer::JsWriter, Emitter};
use swc_ecma_transforms::{fixer, hygiene};
use swc_ecma_utils::{drop_span, DropSpan};
use swc_ecma_visit... | true |
1b2f7fa6457cd1a1e068f0a89b33adbe790b107b | Rust | Dentosal/isolated-rs | /src/command.rs | UTF-8 | 3,565 | 3.1875 | 3 | [
"MIT"
] | permissive | use std::{
ffi::CString,
path::{Path, PathBuf},
};
use crate::Process;
#[derive(Debug, Clone)]
pub(crate) enum DiskWritePolicy {
/// Write to temporary directory, automatically deleted when dropping child
TempDir,
/// Write modifications to the file system done by the application to this directory... | true |
595bc5896b60b0c5b01aea1040d1c72d90fef5a8 | Rust | FauxFaux/casync-rs | /casync-format/tests/trivial.rs | UTF-8 | 2,042 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::fs;
use std::io;
use std::io::Read;
use anyhow::Error;
use casync_format::chunks::from_index;
use casync_format::Stream;
#[test]
fn load_index() -> Result<(), Error> {
let file = io::Cursor::new(&include_bytes!("data/trivial.caidx")[..]);
let (_sizes, v) = casync_format::read_index(file)?;
asse... | true |
584ffa1ab330c755cab9c50ee10d35e2b821fac6 | Rust | eupn/stm32wb-hal | /src/datetime.rs | UTF-8 | 3,625 | 3.546875 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Date and timer units & helper functions
/// Seconds
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Second(pub u32);
/// Minutes
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Minute(pub u32);
/// Hours
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Hour(pub u32);
/// Day (1-7)
#[derive(Clone, Cop... | true |
170c08a1210217574d888d6f0463f3d7d7dc22b4 | Rust | kevlarr/four-score | /rust_/src/main.rs | UTF-8 | 2,473 | 3.3125 | 3 | [] | no_license | extern crate fourscore;
use std::io;
use std::io::Write;
use fourscore::*;
use fourscore::MoveResult::*;
fn main() {
println!("Welcome to FourScore!\n");
let players = new_players().unwrap();
let mut board = new_board().unwrap();
let mut p = 0;
loop {
println!("{}", board);
let ... | true |
e7c61cb63319afd7fcd99d4446978f91b3f328b7 | Rust | hapcode/async-graphql | /src/scalars/mod.rs | UTF-8 | 2,370 | 2.75 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod any;
mod bool;
mod datetime;
mod floats;
mod id;
mod integers;
mod json;
mod naive_time;
mod string;
mod uuid;
#[cfg(feature = "bson")]
mod bson;
#[cfg(feature = "chrono_tz")]
mod chrono_tz;
#[cfg(feature = "url")]
mod url;
pub use any::Any;
pub use id::ID;
pub use json::{Json, OutputJson};
#[cfg(test)]
mod test... | true |
c192a759d2cc3f1440a7633a8b6f94c0899e0407 | Rust | astro/underpass-turbo | /src/ql/parser.rs | UTF-8 | 13,288 | 2.75 | 3 | [] | no_license | // TODO: delete; use super::tokens::{Token, Tokenizer};
use super::{SetName, StatementSpec, Statement, QueryType, Filter};
use super::syntax::ScriptParser;
pub fn parse(input: &str) -> Vec<StatementSpec> {
// TODO: propagate input sets across composite statements
ScriptParser::new()
.parse(input)
... | true |
324a86ce33529c3a249ae8cf13f1eaa8bdedea81 | Rust | chyh1990/route-checker | /src/main.rs | UTF-8 | 7,357 | 2.75 | 3 | [
"MIT"
] | permissive | extern crate libc;
extern crate regex;
//extern crate native;
use libc::{c_int, c_void, socket, AF_INET, AF_PACKET, sockaddr_storage};
use std::io::{Read, Seek};
use std::path::Path;
use std::thread;
use std::fs::File;
use std::mem;
use std::io::{BufReader, Bytes, BufRead};
use std::collections::HashMap;
use std::proc... | true |
5e6f60b0802460345d01b72bbf0e8ebe896f588f | Rust | cjxgm/fancy-status | /src/widgets/mem.rs | UTF-8 | 4,814 | 2.53125 | 3 | [
"MIT"
] | permissive | use color::Colorf32;
use fastup::{self, Node, parse_for_first_node, parse_color};
use stats_once::{MEM_TOTAL, MEM_USED};
use super::error_node;
use std::ops::{Add, Sub, Mul, Div};
#[derive(Debug, Copy, Clone, Default)]
pub struct Widget;
impl super::Widget for Widget {
fn expand(&self, args: Vec<String>) -> Node ... | true |
aaf19706592c660a3c3d951277f015276d90f71c | Rust | fildourado/raytracer | /src/vec3.rs | UTF-8 | 3,987 | 3.21875 | 3 | [
"MIT"
] | permissive | use std::ops::*;
use std::f32;
#[derive(Clone, Copy, Debug)]
pub struct Vec3 {
pub e: [f32; 3]
}
impl Vec3 {
pub fn new(x: f32, y: f32, z: f32) -> Vec3 {
Vec3 { e: [x, y, z] }
}
pub fn x(&self) -> f32 {
self.e[0]
}
pub fn y(&self) -> f32 {
self.e[1]
}
pub fn z(&self) -> f32 {
self.... | true |
50ad9fbb34c1b78a0f08a4dac58f524e79f1a1a9 | Rust | tomhoule/nannou-sketches | /src/bin/langton_ant.rs | UTF-8 | 6,137 | 3.328125 | 3 | [] | no_license | use nannou::prelude::*;
/// The length of the side of one square in the grid, in pixels.
const SIZE: usize = 9;
const SIZE_FLOAT: f32 = SIZE as f32;
const TICK_INTERVAL: std::time::Duration = std::time::Duration::from_millis(12);
#[derive(Debug)]
enum CellState {
Black,
White,
}
#[derive(Debug)]
struct Cell... | true |
213127c68e0c032c22ba59dbb90c35aa1899eaad | Rust | urbanslug/flex-vg | /src/io/reference.rs | UTF-8 | 7,928 | 2.671875 | 3 | [] | no_license | use std::str;
// Files
use std::fs::File;
use std::io::BufReader;
use std::io::Read;
// VCF
use vcf::{self, VCFReader, VCFRecord};
use crate::graph::graph;
use crate::io::types::{Buf, Seeker};
// VCF
fn open_vcf(fp: &str) -> VCFReader<BufReader<File>> {
let f = File::open(fp).unwrap();
vcf::VCFReader::new(f... | true |
7d95240ba4102c810e5228a2d6c02695c3e7ca2f | Rust | Robbe7730/adventofcode2020 | /src/main.rs | UTF-8 | 1,020 | 2.59375 | 3 | [] | no_license | #![feature(iterator_fold_self)]
#![feature(linked_list_remove)]
mod day;
mod days;
use std::path::PathBuf;
use structopt::StructOpt;
use days::run_all_days;
use days::run_day;
#[derive(StructOpt, Debug)]
struct Cli {
#[structopt(short, long, help = "Run all days until day_num")]
all: bool,
#[structopt(... | true |
639d96a5278e639924611d3fd7d3e7757a3bbaad | Rust | Dyr-El/advent_of_code_2020 | /aelg-rust/src/day08.rs | UTF-8 | 2,118 | 3.28125 | 3 | [] | no_license | use crate::error;
use crate::vm::*;
type Data = Program;
pub fn parse(input: &[&str]) -> Result<Data, error::AOCError> {
input
.iter()
.map(|l| {
program_parser(l).map_err(|e| {
format!("Couldn't parse {}\nerror: {}", l, e)
.as_str()
.into()
})
})
.map(|r| r.m... | true |
acbf90ac297e5ec4fd83875f9adaafd79de1cb46 | Rust | nwtnni/icfp-2020 | /src/game.rs | UTF-8 | 10,239 | 3.015625 | 3 | [
"MIT"
] | permissive | use std::rc::Rc;
use crate::ast::Atom;
use crate::ast::Exp;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Response {
/// Static game state.
pub info: Info,
/// Game completion stage.
pub stage: Stage,
/// Dynamic game state.
pub state: Option<State>,
}
impl From<&Exp> for Option<R... | true |
529240602ad7e1ee47180b5bb8efd0e2c22b1d77 | Rust | Gravitas-GM/key-manager | /src/cli/commands/compile.rs | UTF-8 | 1,539 | 2.859375 | 3 | [] | no_license | use std::fs;
use std::io::Write;
use std::path::PathBuf;
use structopt::StructOpt;
use crate::app::Application;
use crate::cli::Command;
use crate::error::KeyManagerError;
#[derive(Debug, StructOpt)]
pub struct CompileCommand {
/// Output will be written to this path.
#[structopt(parse(from_os_str))]
out... | true |
4a9aca8e8a62c6652ff4b4488925dc320574d4cd | Rust | joanhey/FrameworkBenchmarks | /frameworks/Rust/salvo/src/db_mongo_raw.rs | UTF-8 | 1,739 | 2.65625 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use futures_util::{stream::FuturesUnordered, TryStreamExt};
use mongodb::{
bson::{doc, RawDocumentBuf},
error::Error,
Database,
};
use crate::World;
pub async fn find_world_by_id(db: Database, id: i32) -> Result<World, Error> {
let world_collection = db.collection::<RawDocumentBuf>("world");
let ... | true |
4590d3ffbeda8ab975a968cc13a3c4ba4e4ee0bd | Rust | patch7331/kauri | /server/src/main.rs | UTF-8 | 1,472 | 2.859375 | 3 | [] | no_license | //! Kauri daemon
//!
//! The following module contains the Kauri daemon. A simple HTTP server that
//! runs silently in the background, providing performance critical services to
//! the Electron front end. This portion of the project most notable includes
//! the following modules:
//!
//! - A basic `document` impleme... | true |
da8a6003ca371bf80d0eca2dafec88c128b03198 | Rust | driftluo/cita-cli | /cita-tool/src/client/system_contract.rs | UTF-8 | 36,213 | 2.5625 | 3 | [
"MIT"
] | permissive | use crate::client::basic::ClientExt;
use crate::client::{remove_0x, TransactionOptions};
use std::str::{self, FromStr};
use crate::abi::contract_encode_input;
use crate::error::ToolError;
use crate::rpctypes::JsonRpcResponse;
use crate::LowerHex;
use ethabi::{Address, Contract};
use failure::Fail;
use tool_derive::Co... | true |
a74054fcca94f2986ba61a72e959dc2c5c6f106b | Rust | mareknowak/cardsnif | /nif_serde_rustler/native/cardsnif/src/player.rs | UTF-8 | 7,416 | 3.296875 | 3 | [
"MIT"
] | permissive | use serde::{Deserialize, Serialize};
use crate::cards::Card;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub enum Command {
#[serde(rename = "Elixir.PlayerRust.CommandAddCards")]
AddCards(Vec<Card>), // add list of cards to the model
#[serde(rename = "Elixir.PlayerRust.CommandRemoveCards")]... | true |
faf50cb37cc1b16a02c9460c6cc1b2d52656ebce | Rust | ikubetoomuzik/advent_of_code | /2022/src/bin/day_one_one.rs | UTF-8 | 681 | 3.046875 | 3 | [] | no_license | use std::io::read_to_string;
fn main() -> std::io::Result<()> {
let mut elve_calories: Vec<u32> = vec![0];
let mut most_calories = 0;
let mut num_elves = 0;
let file = std::fs::File::open("files/input_day1")?;
for line in read_to_string(file).unwrap().lines() {
if line.is_empty() {
... | true |
ac2657b74a858588e68e939bf3abe7fe2451bf27 | Rust | leejw51crypto/chain | /client-core/src/types/address_type.rs | UTF-8 | 812 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::str::FromStr;
use unicase::eq_ascii;
use client_common::{Error, ErrorKind, Result};
/// Enum for specifying different types of addresses
#[derive(Debug, Clone, Copy)]
pub enum AddressType {
/// Transfer address
Transfer,
/// Staking address
Staking,
}
impl FromStr for AddressType {
type... | true |
5814f35405da9c2f722a018d248d5f3d62fd05f3 | Rust | Mark-Simulacrum/advent-of-code | /src/lib.rs | UTF-8 | 11,338 | 2.75 | 3 | [
"MIT"
] | permissive | #![feature(test)]
#[macro_use]
extern crate failure;
extern crate itoa;
extern crate md5;
extern crate memchr;
extern crate smallvec;
extern crate test;
use std::ptr;
mod md5iter;
pub use md5iter::HashIter;
mod bitvec;
mod matrix;
pub mod modulo_solver;
pub use bitvec::BitVec;
pub use matrix::{Grid, Matrix};
pub ... | true |
65cbf3fd647dc37693ae0408603152f0f2f3accf | Rust | anfernee/dotfiles | /samples/rust/vecmac/src/lib.rs | UTF-8 | 252 | 2.828125 | 3 | [] | no_license | macro_rules! avec {
($arg1:ty, $arg2:expr) => {};
($arg1:ty => $arg2:expr; $arg3:path) => {};
}
pub fn try_vec() {
let x = 1;
avec!(x, x + 1);
print!("{}", x);
}
#[test]
fn it_works() {
try_vec();
assert_eq!(2 + 2, 4);
}
| true |
18a0ad796bc23f254fadb104121df41d92f4b3c7 | Rust | theseus-os/Theseus | /kernel/task_fs/src/lib.rs | UTF-8 | 14,053 | 2.90625 | 3 | [
"MIT"
] | permissive | #![no_std]
//! This crate contains the direcotires and files that comprise the taskfs, which is similar
//! to the /proc directory in linux. There are four main sections in this code:
//! 1) TaskFs: the top level directory that holds the individual TaskDirs
//! 2) TaskDir: the lazily computed directory that contains f... | true |
73a678cc670b81e0413dbd34a0ce447b32b6ee70 | Rust | Kr4ken-9/Dogmeat-rs | /src/main.rs | UTF-8 | 1,521 | 2.953125 | 3 | [
"WTFPL"
] | permissive | #[macro_use] extern crate serenity;
#[macro_use] extern crate serde_derive;
extern crate toml;
use serenity::client::Client;
use serenity::prelude::EventHandler;
use serenity::framework::standard::StandardFramework;
use std::io;
mod config;
mod commands;
struct Handler;
impl EventHandler for Handler {}
fn main() {... | true |
a51ae4265ce07a237c0a8a03531964532af4995e | Rust | japaric-archived/stm32.rs | /src/usart/brr.rs | UTF-8 | 190 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use volatile::Into;
#[derive(Clone, Copy)]
#[repr(C)]
pub struct Register(u32);
impl Into<Register> for u16 {
fn convert_into(self) -> Register {
Register(self as u32)
}
}
| true |
476f301b162afcd1d356d163664fdbc306c6b228 | Rust | acshi/jlrs | /jlrs/src/layout/valid_layout.rs | UTF-8 | 2,694 | 3.09375 | 3 | [
"MIT"
] | permissive | //! Trait to check if a Rust type and a Julia type have matching layouts.
//!
//! When working with Julia values, it's always possible to access their [`DataType`]. This
//! `DataType` contains all information about the value's fields and their layout. The
//! [`ValidLayout`] trait defined in this module is used to che... | true |
5e5f22ad27b5d0a39238d4dc134803b37e2ae8dc | Rust | DennisNemec/rust-lisp | /src/protocol/mod.rs | UTF-8 | 2,111 | 2.75 | 3 | [
"Apache-2.0"
] | permissive | pub mod header;
pub mod constants;
use constants::*;
/* Traits */
pub trait Serialization<T> {
fn serialize(self) -> Vec<u8>;
fn deserialize(binary: Vec<u8>) -> Result<T, String>;
}
/* Helper functions */
pub fn extract_address_from_bytes_arr(binary: &[u8], atyp: &AddressType) -> Vec<u8> {
return if let ... | true |
4b9b4673ef027c38cfe2a447ef66a3cbe207f9f2 | Rust | PsichiX/Oxygengine | /engine/core/src/ecs/commands.rs | UTF-8 | 8,492 | 2.59375 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::{
app::AppLifeCycle,
ecs::{life_cycle::EntityChanges, Universe},
prefab::PrefabManager,
};
pub use hecs::*;
use std::{
any::TypeId,
collections::{HashMap, VecDeque},
marker::PhantomData,
};
pub trait UniverseCommand: Send + Sync {
fn run(&mut self, universe: &mut Universe);
}
st... | true |
a475e8f8cbb66409c52c66dff89619410616abed | Rust | tillrohrmann/rust-challenges | /aoc_2021_14/src/main.rs | UTF-8 | 745 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use std::cmp::Ordering;
fn main() {
let content = aoc_common::read_raw_file_content("input.txt").unwrap();
let (polymer, rules) = aoc_2021_14::parse_input(&content).unwrap();
let evolved_polymer = aoc_2021_14::evolve(&polymer, &rules, 10).unwrap();
let elements = evolved_polymer.count_elements();
... | true |
f407db95ad87500ce310c749ee9d5403d82bb736 | Rust | MohamedHajr/Problem-Solving | /exercism/rust/clock/src/lib.rs | UTF-8 | 1,499 | 3.578125 | 4 | [] | no_license | use std::fmt;
#[derive(Debug, PartialEq)]
pub struct Clock{
minutes: i32,
}
fn hrs_to_mins(hours: i32) -> i32 {
if hours >= 0 {
(hours % 24) * 60
} else {
(24 - (hours.abs() % 24)) * 60
}
}
fn calc_mins(minutes: i32) -> i32 {
if minutes > 0 {
minutes % 60
} else {
... | true |
b35312a8f970b551ff490d313d8ba8891e62aefb | Rust | michaelherold/cred | /src/cmd/add.rs | UTF-8 | 1,441 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate diesel;
use std::io::{self, Write};
use clap::ArgMatches;
use diesel::prelude::*;
use super::super::models::NewCredential;
fn get_input(prompt: &str) -> Option<String> {
let mut input = String::new();
print!(" -> {}: ", prompt);
io::stdout().flush().unwrap();
match io::stdin().read_l... | true |
0b024e2114078f113e760b05d3f552520f4f3c87 | Rust | kompics/kompact | /core/src/net/buffers/decode_buffer.rs | UTF-8 | 13,873 | 3.21875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
use std::cmp::Ordering;
/// Used to allow extraction of data frames in between inserting data
/// And can replace the underlying BufferChunk with new ones
pub struct DecodeBuffer {
buffer: BufferChunk,
write_offset: usize,
read_offset: usize,
next_frame_head: Option<FrameHead>,
// Use... | true |
6d54da33cabca88e3b506eda373fb856fb8853c0 | Rust | 22388o/client_side_validation | /commit_verify/src/merkle.rs | UTF-8 | 16,191 | 2.515625 | 3 | [
"LicenseRef-scancode-public-domain-disclaimer",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | // LNP/BP client-side-validation foundation libraries implementing LNPBP
// specifications & standards (LNPBP-4, 7, 8, 9, 42, 81)
//
// Written in 2019-2021 by
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neigh... | true |
308cb5364f1b6762ecf9fb38ed3281ac42eb9170 | Rust | hhatto/nem2-rs | /src/account/http.rs | UTF-8 | 2,763 | 2.796875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serde_json::Value;
use crate::HttpClient;
pub struct AccountHttp<'a> {
pub client: HttpClient,
base_path: &'a str,
}
impl<'a> AccountHttp<'a> {
pub fn new(base_url: &str) -> Self {
AccountHttp {
client: HttpClient::new(base_url),
base_path: "/account",
}
}
... | true |
d259897acb2d99eff3a6c7cd3685de614c1be8cd | Rust | LeopoldTal/porcus | /src/case.rs | UTF-8 | 6,177 | 4.03125 | 4 | [] | no_license | //! Case detection and mapping.
//!
//! # Usage
//!
//! ```
//! use porcus::case::{self, Case};
//!
//! let s = "HELLO";
//! assert_eq!(case::detect_case(&s), Case::Upper);
//! assert_eq!(case::to_case(s, Case::Sentence), "Hello");
//! ```
use std::fmt;
use unicode_segmentation::UnicodeSegmentation;
/// Case of a wor... | true |
db82880d11bb65b4b2a61d96c2a99d4ba2394cda | Rust | viktorstrate/toy-sat | /src/solver/mod.rs | UTF-8 | 1,866 | 3.109375 | 3 | [] | no_license | use super::parser;
use std::fmt;
pub mod bruteforce;
pub mod combinational;
pub enum SolveResult {
Satisfiable(Vec<i64>),
Unsatisfiable,
Unknown,
}
impl Default for SolveResult {
fn default() -> Self {
SolveResult::Unknown
}
}
impl fmt::Display for SolveResult {
fn fmt(&self, f: &mut fmt::Formatter)... | true |
8d5f8667b0fc9768b5823e6836624aba187b531d | Rust | ellmau/adf-obdd | /lib/src/nogoods.rs | UTF-8 | 26,051 | 3.34375 | 3 | [
"MIT"
] | permissive | //! Collection of all nogood-related structures.
use std::{
fmt::{Debug, Display},
ops::{BitAnd, BitOr, BitXor, BitXorAssign},
};
use crate::datatypes::Term;
use roaring::RoaringBitmap;
/// A [NoGood] and an [Interpretation] can be represented by the same structure.
/// Moreover this duality (i.e. an [Interp... | true |
7cb25a29c34174e6ea4d50bb48863936e118592d | Rust | wujinderead/MyGoProjects | /gotest/leet_rust/tests/leet2165_smallest_value_of_the_rearranged_number.rs | UTF-8 | 2,808 | 3.6875 | 4 | [] | no_license | // https://leetcode.com/problems/smallest-value-of-the-rearranged-number/
// You are given an integer num. Rearrange the digits of num such that its value is minimized
// and it does not contain any leading zeros.
// Return the rearranged number with minimal value.
// Note that the sign of the number does not change a... | true |
1e4319144645d6a4e989f0e58e7fc98cc9599305 | Rust | Spoopsta/ProgrammingParadigmsCodeExamples | /Structure Example.rs | UTF-8 | 986 | 4.09375 | 4 | [] | no_license | fn main(){
struct Quadrilateral {
name: String,
height: i32,
width: i32,
}
let shape = Quadrilateral{
name: String::from("Square"),
height: 5,
width: 5
};
let shape2 = Quadrilateral{
name: String::from("Rectangle"),
... | true |
8af78647c07ac34e0149fec7d10e0b749e4cba91 | Rust | coriolinus/julia-set | /src/iter.rs | UTF-8 | 2,998 | 3.984375 | 4 | [] | no_license | //! Module providing an iterator adaptor which transforms Iterator<(C, S)> into Iterator<(C, S, C)>.
//!
//! Via trait, auto-implements this adaptor for all iterators it knows how to deal with.
//!
//! Humans are good at making lists of alternating data types: we might think of a set of
//! driving directions, say, as ... | true |
a847cefd55a7bfb403dde881fd87587413170dd2 | Rust | paulyc/moonrs | /lib/src/lib.rs | UTF-8 | 9,748 | 2.828125 | 3 | [] | no_license | extern crate hifitime;
pub use hifitime::*;
pub mod moon {
use hifitime::Epoch;
extern crate vsop87;
use vsop87::vsop87a;
use vsop87::RectangularCoordinates;
pub trait ConvertibleToSpherical {
fn longitude(&self) -> f64;
fn magnitude(&self) -> f64;
}
impl ConvertibleToSp... | true |
a5c8a6d15a77d56bbc205a35d83377cfc5005a04 | Rust | rustyforks/psila | /psila-crypto-openssl/src/lib.rs | UTF-8 | 30,273 | 2.890625 | 3 | [
"MIT"
] | permissive | use byteorder::{BigEndian, ByteOrder};
use openssl::symm::{Cipher, Crypter};
use psila_crypto::{BlockCipher, CryptoBackend, Error, BLOCK_SIZE, KEY_SIZE, LENGTH_FIELD_LENGTH};
use std::vec::Vec;
fn clear(slice: &mut [u8]) {
for v in slice.iter_mut() {
*v = 0;
}
}
fn into_error(error: openssl::error::Er... | true |
bd0fdebf7f1b7a32cba58938427d0f108556336d | Rust | sidju/drim | /src/db/sessions.rs | UTF-8 | 719 | 2.515625 | 3 | [] | no_license | use super::*;
pub async fn get_user(db: DbPool, uuid: String)
-> Result<User, Error>
{
let parsed = sqlx::types::Uuid::parse_str(&uuid)?;
Ok(
sqlx::query_as!(User,
"SELECT users.id, users.nick, users.email, users.pass, users.role FROM sessions JOIN users ON sessions.userid = users.id WHERE sessions.uu... | true |
be3198b93289e2d230e4e630128687ab1e42510c | Rust | mthebridge/aoc-2020 | /day05/src/main.rs | UTF-8 | 2,539 | 3.6875 | 4 | [] | no_license | use std::convert::TryFrom;
// This struct is really unnecessary - we only ever use it to map straight
// to a seat ID, which we could do with two local vars.
//
// But it makes the code marginally cleaner.
#[derive(Debug, Clone, Eq, PartialEq)]
struct BoardingPass {
row: u8,
seat: u8,
}
impl BoardingPass {
... | true |
452bdeabc87315c9b084d5f4a27f474b85bc9d96 | Rust | oliverlee/vr-lab | /renderer/src/depth_renderer.rs | UTF-8 | 1,830 | 2.578125 | 3 | [] | no_license | use crate::*;
pub struct Renderer {
pub program: rendering::Program,
pub obj_to_wld_loc: gl::OptionUniformLocation,
}
impl Renderer {
pub fn render(&mut self, gl: &gl::Gl, world: &mut World, resources: &Resources) {
unsafe {
self.update(gl, world);
if let ProgramName::Linke... | true |
75f659be48b3e7c7989bc10db3605969a03f7609 | Rust | aldrio/passthrough-dns | /src/dns/zone.rs | UTF-8 | 2,242 | 2.734375 | 3 | [] | no_license | use crate::dns::protocol::{DnsQuestion, DnsRecord, QueryType, ResultCode, TransientTtl};
use std::env;
use std::net::Ipv4Addr;
pub struct Zone<'a> {
domain: &'a str,
mname: &'a str,
rname: &'a str,
}
impl<'a> Zone<'a> {
pub fn new(domain: &'a str, mname: &'a str, rname: &'a str) -> Zone<'a> {
... | true |
db5d34e5a3d62ba256180239ed24d9e2c57b407c | Rust | MikailBag/copy-ln | /src/main.rs | UTF-8 | 689 | 3.015625 | 3 | [] | no_license | use std::path::PathBuf;
use structopt::StructOpt;
#[derive(StructOpt)]
struct Options {
#[structopt(long, short = "p")]
prefix: PathBuf,
#[structopt(long, short = "f")]
file: Vec<PathBuf>,
#[structopt(long, short = "s")]
skip_exist: bool,
/// Treat symlinks as regular files
#[structopt(... | true |
5fb9441ee6898c78d3c7082cf80a58b7619d3457 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/code-festival-2016-qualc/src/bin/a.rs | UTF-8 | 288 | 2.578125 | 3 | [] | no_license | use proconio::{input, marker::Chars};
fn main() {
input! {
s: Chars,
};
let ans = if let Some(i) = s.iter().position(|c| c == &'C') {
s[i + 1..].iter().any(|c| c == &'F')
} else {
false
};
println!("{}", if ans { "Yes" } else { "No" });
}
| true |
5632a5ee37ef3728d4b41f6723e2ca7430f022fe | Rust | jblee123/advent_of_code_2019 | /aoc2019_day08/src/day08_utils.rs | UTF-8 | 1,481 | 3.5625 | 4 | [] | no_license | use std::convert::TryInto;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct Layer {
pub digit_counts: [u32; 10],
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Image {
pub width: u32,
pub height: u32,
pub layers: Vec<Layer>,
}
pub fn decode_image(data_str: &str, width: u32, height: u32) -... | true |
3e0bdcfc7ab9517af90d9510833447517938710c | Rust | po3rin/rust_playground | /ackermann-calc/src/main.rs | UTF-8 | 2,027 | 3.296875 | 3 | [] | no_license | use num_bigint::BigUint;
use num_traits::cast::ToPrimitive;
use num_traits::pow::Pow;
use std::thread;
fn main() {
println!("{}", ackermann(4, 2));
}
fn b(v: u32) -> BigUint {
BigUint::from(v)
}
fn naive_ackermann(m: i32, n: i32) -> i32 {
fn work(m: i32, n: i32) -> i32 {
if m == 0 {
n... | true |
98c848a17342ae4f2c53395914d3091b088b6da5 | Rust | TBye101/log_t | /src/file_logger.rs | UTF-8 | 3,883 | 3.59375 | 4 | [
"MIT"
] | permissive | pub mod logging_implementations {
extern crate chrono;
use crate::logging_abstraction::Logger;
use contracts::*;
use std::{fs::File, io::Write};
const UNINITIALIZED_FILE_HANDLE_EXCEPTION: &str = "The log file was not initialized before writing to the log.";
pub struct FileLogger {
//... | true |
02144d145910ffbaa13ed2d909a2e337184869b5 | Rust | mwallenfang/dicey | /src/dice.rs | UTF-8 | 9,570 | 3.28125 | 3 | [] | no_license | mod die;
pub mod roll;
use crate::errors::{ParsingError, StructureError};
use die::Die;
use lazy_static::lazy_static;
use regex::Regex;
use roll::Roll;
use std::error::Error;
use std::fmt;
use std::str::FromStr;
lazy_static! {
//TODO: Find a regex way to find the dice strings, instead of just looking for ds
s... | true |
9d2ae03be0571ac1deeeb8e37c0e92f435764497 | Rust | chromium/chromium | /third_party/rust/anyhow/v1/crate/src/ensure.rs | UTF-8 | 45,298 | 2.71875 | 3 | [
"GPL-1.0-or-later",
"MIT",
"LGPL-2.0-or-later",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause"
] | permissive | use crate::Error;
use alloc::string::String;
use core::fmt::{self, Debug, Write};
use core::mem::MaybeUninit;
use core::ptr;
use core::slice;
use core::str;
#[doc(hidden)]
pub trait BothDebug {
fn __dispatch_ensure(self, msg: &'static str) -> Error;
}
impl<A, B> BothDebug for (A, B)
where
A: Debug,
B: Deb... | true |
c3c159d455b0c746da41af93bff32f8fd91bc7b6 | Rust | dylanmckay/hllvm | /src/ir/ty/integer.rs | UTF-8 | 546 | 2.546875 | 3 | [
"MIT"
] | permissive | //! Integer type.
use SafeWrapper;
use ir::{Type, Context};
use sys;
/// A type representing a function.
pub struct IntegerType<'ctx>(Type<'ctx>);
impl<'ctx> IntegerType<'ctx>
{
/// Gets an integer type.
pub fn new(num_bits: usize,
context: &Context) -> Self {
unsafe {
let ... | true |
85012b67345efb14a80a1899b24aa83d1f7d515c | Rust | hobbit19/grammers | /lib/grammers-tl-types/build/loader.rs | UTF-8 | 1,720 | 2.765625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2020 - developers of the `grammers` project.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distr... | true |
9000804645acd214e9e059ac4190b526f047cc6e | Rust | masp/nes_emulator | /parser_6502/tests/instructions.rs | UTF-8 | 3,799 | 3.03125 | 3 | [] | no_license | use parser_6502::*;
use claim::*;
macro_rules! assert_compiles {
($prog:literal, $opcode:ident, $argtype:ident) => {
let p = Program::compile($prog);
assert_ok!(&p);
assert_eq!(p.unwrap().instructions,
&[Instruction::new(Opcode::$opcode, Arg::$argtype)]);
};
($prog:lite... | true |
7daf88942298bd353194b20d3448fbf0814f5500 | Rust | thomasandbox/axum-sandbox | /examples/hello_world/main.rs | UTF-8 | 426 | 2.515625 | 3 | [] | no_license | use axum::{handler::get, response::Html, Router};
use std::net::SocketAddr;
async fn hello_world() -> Html<&'static str> {
Html("Hello, World\n")
}
#[tokio::main]
async fn main() {
let app = Router::new().route("/", get(hello_world));
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
println!("Listening on... | true |
bcc0f47e6025b8ffff9ca505a26c288388e9315f | Rust | netvipec/AoC2019 | /Rust/Day8/part2/src/main.rs | UTF-8 | 2,645 | 3.046875 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::io::prelude::*;
// typedef struct {
// char idlength;
// char colourmaptype;
// char datatypecode; // 2
// short int colourmaporigin;
// short int colourmaplength;
// char colourmapdepth;
// short int x_origin;
... | true |
c89ad5af1419a37dd9207e61b7615e1052c20337 | Rust | Urhengulas/pl_from_scratch | /eldiro/src/env.rs | UTF-8 | 503 | 3.15625 | 3 | [] | no_license | use std::collections::HashMap;
use crate::val::Val;
#[derive(Debug, Default, Eq, PartialEq)]
pub struct Env {
bindings: HashMap<String, Val>,
}
impl Env {
pub fn store_binding(&mut self, name: String, val: Val) {
self.bindings.insert(name, val);
}
pub fn get_binding_value(&self, name: &str) ... | true |
2dc72243c088cd157ecd55f110778cbe1ec97fa5 | Rust | limoiie/magic-file | /src/magic_param.rs | UTF-8 | 1,676 | 3.078125 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use serde_json;
use serde_json::json;
#[derive(Serialize, Deserialize, Default, Debug, PartialEq)]
pub(crate) struct MagicParam {
indir: i32,
name: i32,
elf_phnum: i32,
elf_shnum: i32,
elf_notes: i32,
regex: i32,
bytes: i32,
}
impl MagicParam {
pu... | true |
6e0965b5948159c19c18fb234e7627311de5b481 | Rust | tailhook/nginx-config | /src/visitors.rs | UTF-8 | 2,374 | 3.46875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Various visitors for working with AST
use std::collections::VecDeque;
use ast::Directive;
use value::Value;
/// A deep iterator over all directives in configuration file or a part of it
#[derive(Debug)]
pub struct DirectiveIter<'a> {
cur: Option<&'a Directive>,
queue: VecDeque<&'a Directive>,
}
impl<'a>... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.