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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ca8d498efd1fb1ee9c8286c96591a3a6389ad113 | Rust | sercant/leetcode-rust | /src/problems/longest_valid_parentheses.rs | UTF-8 | 1,972 | 3.421875 | 3 | [] | no_license | use crate::common::Solution;
impl Solution {
pub fn longest_valid_parentheses(s: String) -> i32 {
let mut valids: Vec<(i32, i32)> = vec![];
let mut op_stack: Vec<i32> = vec![];
for (i, ch) in s.bytes().enumerate() {
let index: i32 = i as i32;
if ch == b'(' {
... | true |
6898c5274872f0329ee4a84b4d86447b2a51b581 | Rust | abba123/Raytracer | /src/main.rs | UTF-8 | 13,310 | 3.25 | 3 | [] | no_license | extern crate image;
use image::{DynamicImage, GenericImage, Pixel, Rgba};
use std::ops::{Add, Sub, Mul, Neg};
const GAMMA: f32 = 2.2;
fn gamma_encode(linear: f32) -> f32 {
linear.powf(1.0 / GAMMA)
}
impl Neg for Vector3{
type Output = Vector3;
fn neg(self) -> Vector3{
Vector3{
x: -se... | true |
4009453e6f01c8532fbf6d8e63931e4f12022f9e | Rust | laohanlinux/cryptocurrency-kit-rs | /src/ethkey/signature.rs | UTF-8 | 13,038 | 2.796875 | 3 | [
"Apache-2.0"
] | permissive | use super::{public_to_address, Address, Error, Message, Public, Secret, SECP256K1};
use common::{to_hex, to_keccak};
use crypto::{hash, CryptoHash, Hash};
use ethereum_types::{H256, H520};
use secp256k1::key::{PublicKey, SecretKey};
use secp256k1::{Error as SecpError, Message as SecpMessage, RecoverableSignature, Recov... | true |
d0f87a9632e12ca29b54c1759f50a97e93b35f3c | Rust | brunt/schedule-updater | /src/main.rs | UTF-8 | 3,729 | 2.71875 | 3 | [] | no_license | extern crate regex;
extern crate reqwest;
use regex::Regex;
use std::fs;
use std::io::Write;
use std::thread;
fn main() {
//create output directory if it's not there already
if !std::path::Path::new(&"./out").exists() {
fs::create_dir("./out").expect("error creating output directory");
}
let w... | true |
6b2377cd0b7616c334bf9784bac0bbc43b2b75d5 | Rust | KennethGomez/sudoku_solver | /src/grid/algorithm.rs | UTF-8 | 2,401 | 2.90625 | 3 | [] | no_license | use crate::algorithm::Algorithm;
use crate::cell::Cell;
use crate::grid::Grid;
impl Algorithm for Grid {
fn update(&mut self) {
let (mut x, mut y, mut possibilities) = self.next();
if self.completed == true {
return;
}
self.history.push((x, y, possibilities.clone()));
... | true |
0c5b40004554b30e73f0cbb41e9c2fe83a264aac | Rust | web-dom/halcyon | /halcyon_dom/src/lib.rs | UTF-8 | 3,829 | 2.8125 | 3 | [
"MIT"
] | permissive | use halcyon::{Element, DOM};
pub mod prelude;
#[derive(Debug)]
#[allow(dead_code)]
pub struct WebIDLDOM {
document: web_sys::Document,
}
impl WebIDLDOM {
pub fn new() -> WebIDLDOM {
let window = web_sys::window().unwrap();
let document = window.document().unwrap();
WebIDLDOM { documen... | true |
7c3eb761822f72e327ed18f8ccd3ba0b3e8d6066 | Rust | kimikan/rust-raft | /src/utils.rs | UTF-8 | 1,730 | 3.3125 | 3 | [] | no_license |
use rand::{Rng, StdRng};
use std::time::Duration;
use std::io::{Result, Write};
use std::fs::OpenOptions;
//random a value, which between two different
//time duration, it's used for request peer to vote
//after a random period to avoid conflict
pub fn after_between(low: Duration, high: Duration) -> Durat... | true |
43bb90c876c58bbac427da8ed2c5e041df84d7ca | Rust | clarfonthey/bitvec | /src/array/tests.rs | UTF-8 | 3,530 | 3.09375 | 3 | [
"MIT"
] | permissive | //! Unit tests for bit-arrays.
#![cfg(test)]
use core::{
borrow::{
Borrow,
BorrowMut,
},
cell::Cell,
convert::TryFrom,
fmt::Debug,
hash::Hash,
ops::{
BitAnd,
BitOr,
BitXor,
Index,
IndexMut,
Range,
},
};
use static_assertions::*;
use crate::prelude::*;
#[test]
fn core_impl() {
assert_impl_a... | true |
16a7419d5ae5810bfa4f26356f61670c71d6648d | Rust | EricQAQ/exercism-rust | /perfect-numbers/src/lib.rs | UTF-8 | 1,306 | 3.6875 | 4 | [] | no_license | use std::collections::HashSet;
use std::cmp;
#[derive(Debug, PartialEq)]
pub enum Classification {
Perfect,
Abundant,
Deficient,
}
pub fn classify_one<'a>(number: u64) -> Result<Classification, &'a str> {
if number == 0 { return Err("Number must be positive") }
let half = number / 2 + 1;
let ... | true |
a80e5769716bcd6bbaa0b3a27aec79c3b0989ca2 | Rust | wetmore/raytracer | /src/camera.rs | UTF-8 | 3,001 | 2.921875 | 3 | [] | no_license | use crate::ray::Ray;
use crate::vec::Vec3;
use crate::{pixmap::PixMap, rand::Rng};
#[derive(Clone, Copy)]
pub struct CameraOptions {
fov: f64,
aspect: f64,
aperature: f64,
focus_dist: f64,
look_at: Vec3,
look_from: Vec3,
vup: Vec3,
}
#[derive(Clone, Copy)]
pub struct Camera {
origin: V... | true |
4437653e2b150e62d492949fbcdb75990c0c018e | Rust | gschenk/rustRain | /src/lib.rs | UTF-8 | 7,531 | 3.046875 | 3 | [
"MIT"
] | permissive | pub mod algorithm;
pub mod input;
pub mod solutions;
pub mod zero;
// Problem collects data and characterises problem
#[derive(Debug)]
pub struct Problem {
pub water_0: f64, //initial water level on each segment
pub grounds: Vec<u64>, //ground level
pub water_tot: u64, // total amount of water, con... | true |
decaa979cbbc64e205dcb0820478fd219cc9f173 | Rust | michaelstarmer/rust-examples | /_template/src/logger.rs | UTF-8 | 1,006 | 2.875 | 3 | [] | no_license | extern crate pretty_env_logger;
use std::process::Command;
fn main()
{
pretty_env_logger::init();
}
/// Initialize logger and display some examples.
pub fn init_application()
{
pretty_env_logger::init();
}
/// Clears the terminal window.
#[allow(dead_code)]
pub fn clear_terminal()
{
let output = Command::new(... | true |
ca4c77fb479e4943a133caf80991d3315640480d | Rust | havardh/rust-koans | /about_data_sharing.rs | UTF-8 | 687 | 2.875 | 3 | [] | no_license | use sync::Arc;
#[test]
fn immutable_data_can_be_shared() {
let ident = |x|x;
let numbers = Vec::from_fn(100, ident);
let numbers_arc = Arc::new(numbers.clone());
let (rtx, rrx) = channel();
for _i in range(1,10) {
let (tx, rx) = channel();
tx.send(numbers_arc.clone());
l... | true |
0947548dc1695868f7221a5667acd8023d632150 | Rust | szlend/enum_dispatch | /src/enum_dispatch_variant.rs | UTF-8 | 3,118 | 3.203125 | 3 | [
"MIT"
] | permissive | //! Provides an implementation of a `syn`- and `quote`-compatible syntax item describing a single
//! variant for the shortened enum form used by `enum_dispatch`.
//!
//! Each variant can be either just a type, or a name with a single associated tuple type
//! parameter. In the first form, the name is simply the same a... | true |
bd63362dbcef2ea1aec1af511c5d74be0f1e6768 | Rust | jimblandy/rbattle | /src/square.rs | UTF-8 | 13,778 | 3.53125 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | //! Types for square grids.
use graph::{Graph, Node};
use visible_graph::{GraphPt, IndexedSegment, VisibleGraph};
/// A grid of 1✕1 squares, of a given number of rows and columns. A cell's
/// neighbors are those above, below, and to the left and right of it; diagonal
/// connections are not neigbors.
///
/// In grap... | true |
dd8f7bc8a7ffaa763f56761aec28d5fc03ba66c4 | Rust | madmax28/aoc2020 | /src/day18/mod.rs | UTF-8 | 1,943 | 3.640625 | 4 | [] | no_license | #[derive(Debug, Clone, Copy, PartialEq)]
enum Op {
Add,
Mul,
}
impl Op {
fn apply(&self, a: i64, b: i64) -> i64 {
match self {
Op::Add => a + b,
Op::Mul => a * b,
}
}
}
fn eval_p1(vals: Vec<i64>, ops: Vec<Op>) -> i64 {
let mut val = vals[0];
for (o, v) i... | true |
aea12fb8f6a54105b93eb67e45062d5ee7e89af5 | Rust | czak/aoc | /2017/rust/src/bin/day04.rs | UTF-8 | 1,029 | 3.375 | 3 | [] | no_license | use std::io;
use std::io::BufRead;
use std::collections::HashSet;
fn main() {
let mut lines: Vec<Vec<String>> = vec![];
for line in io::stdin().lock().lines() {
let line = line.unwrap()
.split_whitespace()
.map(str::to_owned)
.collect();
lines.push(line);
... | true |
aa34c8d887ce0de7fc0b4895ebf12e98f491f05d | Rust | bigyihsuan/EsotericReaction | /src/lex/lexer.rs | UTF-8 | 8,094 | 3.125 | 3 | [] | no_license | use crate::lex::tok::{Indexes, Span};
#[derive(Debug)]
pub struct Lexer {
code: Vec<char>,
pub idx: usize,
pub line: usize,
pub col: usize,
pub ch: char,
}
impl Lexer {
pub fn new(code: String) -> Lexer {
Lexer {
idx: 0,
line: 1,
col: 0,
... | true |
5219feb3a968bab566fcd5a0fbdd2490a4bec4e6 | Rust | shrhdk/rust-study | /json/tests/json.rs | UTF-8 | 6,150 | 2.90625 | 3 | [] | no_license | extern crate json;
#[macro_use]
extern crate maplit;
use json::Json;
#[test]
fn test_parse_complex_object() {
let obj = Json::Object(Box::new(hashmap! {
"array".to_string() => Json::Array(vec![
Json::Object(Box::new(hashmap! {
"num".to_string() => Json::Number(1.0),
... | true |
474e2c1650e7d2538e2df5a6d2da47436f088411 | Rust | seankerr/rust-http-box | /src/util/decode.rs | UTF-8 | 4,682 | 3.0625 | 3 | [
"Apache-2.0"
] | permissive | // +-----------------------------------------------------------------------------------------------+
// | Copyright 2016 Sean Kerr |
// | |
// | Licensed und... | true |
7b0b6d71a0bdbecc821e3ed99c5d590f41f3f05f | Rust | c0ding/swift-bindgen | /swift/src/string.rs | UTF-8 | 11,965 | 3.140625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::Bool;
use std::{char, cmp, ffi::CStr, fmt, hash, slice, str};
/// A string type designed to represent text that is known at compile time.
///
/// See [documentation](https://developer.apple.com/documentation/swift/staticstring).
#[repr(C)]
#[derive(Copy, Clone, Eq)]
pub struct StaticString {
// Swift de... | true |
87f72630907b0834109a950b6718dccef44310c2 | Rust | Lisoph/empu | /examples/print_assembled.rs | UTF-8 | 2,255 | 2.828125 | 3 | [
"MIT"
] | permissive | extern crate empu;
extern crate term_painter;
use std::collections::HashMap;
use std::hash::Hash;
use std::cmp::Eq;
use empu::{Address, Instruction, Source, Unit, Usd};
use empu::Instruction::*;
use term_painter::ToStyle;
use term_painter::Color::*;
fn main() {
let program = [
Instruction::Mov(Usd {
... | true |
ce7f3e06d18fe51859239e715999320e378cf339 | Rust | KatsuyaKikuchi/programming_contest_rust | /src/AtCoder Typical Contest/ATC001/A.rs | UTF-8 | 1,128 | 2.75 | 3 | [] | no_license | use proconio::input;
use proconio::marker::Chars;
use std::collections::VecDeque;
fn main()
{
input! {
h:usize,
w:usize,
s:[Chars;h],
}
let mut u = vec![vec![false; w]; h];
let mut q: VecDeque<(usize, usize)> = VecDeque::new();
for i in 0..h {
match s[i].iter().position(|&c| c... | true |
725a999d8a530456538189f9b82f5ee0882fc8a6 | Rust | paradakh/human-sort | /src/lib.rs | UTF-8 | 2,490 | 4 | 4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Utilities to sort and compare strings with numeric symbols in human-friendly order.
//!
//! It built over iterators and compare string slices char by char (except for numerals)
//! until the first difference found without creating Strings or another structures with whole
//! data from provided &str, so doesn't requ... | true |
a14c63e915c73b3c8d32054b36834b4c31612481 | Rust | innoave/rincon | /rincon_client/src/user/methods.rs | UTF-8 | 23,006 | 2.984375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Methods for user administration.
use std::collections::HashMap;
use std::marker::PhantomData;
use serde::de::DeserializeOwned;
use serde::ser::Serialize;
use super::types::*;
use rincon_core::api::method::{Method, Operation, Parameters, Prepare, RpcReturnType};
use rincon_core::api::types::Empty;
use rincon_core... | true |
b77c3b8a8d7e447c632e4115474bb7a9ade0154e | Rust | xiuxiu62/rust-workshop | /vending_machine/src/main.rs | UTF-8 | 444 | 3.34375 | 3 | [] | no_license | use std::collections::HashMap;
struct Item {
price: u8,
amount: u8,
}
struct Machine<'a> {
balance: u32,
items: HashMap<&'a str, Item>,
}
impl Machine<'_> {
fn new<'a>() -> Machine<'a> {
Machine {
balance: 0,
items: HashMap::new(),
}
}
fn add_item(... | true |
51c842d060a7ed0aef79cdc0672010644fa07f43 | Rust | kirmanak/CommunicationSyscalls | /pthread_mutex/src/main.rs | UTF-8 | 1,824 | 2.796875 | 3 | [] | no_license | extern crate libc;
mod native;
use native::{create_thread, reverse, inverse, c_void, create_mutex, unlock_mutex, lock_mutex,
pthread_mutex_t};
use std::time::Duration;
use std::thread::sleep;
use std::env::args;
pub struct ThreadArgument<'a> {
pub characters: &'a mut Vec<char>,
pub mutex: &'a m... | true |
47650d80127dc3b06544b6f53b45c7d403ffa36a | Rust | untoldwind/t-rust-less | /cli/src/view/secret_type_view.rs | UTF-8 | 752 | 2.796875 | 3 | [
"MIT"
] | permissive | use cursive::view::ViewWrapper;
use cursive::views::{LinearLayout, TextView};
use t_rust_less_lib::api::SecretType;
pub struct SecretTypeView {
base_view: LinearLayout,
}
impl SecretTypeView {
pub fn new(secret_type: SecretType) -> Self {
SecretTypeView {
base_view: LinearLayout::horizontal()
.c... | true |
86b31efa827b57300f69db806853d9b9be23d0cc | Rust | bronvic/caesar | /src/main.rs | UTF-8 | 1,478 | 3.21875 | 3 | [] | no_license | use std::env;
use std::path::PathBuf;
use std::fs::File;
use std::error::Error;
use std::io::prelude::*;
mod coder;
use coder::*;
#[derive(PartialEq)]
enum Mode {
Encode,
Decode,
}
fn main() {
let args: Vec<_> = env::args().collect();
if args.len() != 4 {
panic!("Wrong number of arguments\nUs... | true |
d432b1b958c7c872ac8de3d6929f4327ccd44e4f | Rust | hawkw/huffman.rs | /src/lib.rs | UTF-8 | 3,650 | 3.515625 | 4 | [] | no_license | #![feature(box_patterns, box_syntax)]
extern crate hashmap_ext;
use hashmap_ext::UpdateOr;
use std::cmp::{Ordering, max};
use std::collections::{HashMap, BinaryHeap};
use Node::*;
mod bitwriter;
use bitwriter::BitWriter;
pub type EncodingTable<T> = HashMap<u8, T>;
pub trait Encodable {
type Item;
fn encod... | true |
82ba43dde3f58a2ef14f91b0b5532f0f1584c62d | Rust | athulramesh/rustyGraph | /src/lib.rs | UTF-8 | 2,031 | 2.734375 | 3 | [] | no_license | use std::collections::HashMap;
use pyo3::prelude::*;
mod algo;
/// Breadth first search
#[pyfunction]
fn bfs(graph: HashMap<i32, Vec<i32>>, start: i32) -> PyResult<Vec<i32>> {
Ok(algo::bfs(graph, start))
}
/// Depth first search
#[pyfunction]
fn dfs(graph: HashMap<i32, Vec<i32>>, start: i32) -> PyResult<Vec<i32... | true |
3fcbdc6a061aa469beb539edac9bd2f761001379 | Rust | serenity-rs/framework | /framework/src/argument.rs | UTF-8 | 9,134 | 3.421875 | 3 | [
"ISC"
] | permissive | //! Utilities for parsing command arguments.
use std::error::Error as StdError;
use std::fmt;
use serenity::{async_trait, model::prelude::*, prelude::*, utils::Parse};
use crate::utils::ArgumentSegments;
/// Error that might have occured when trying to parse an argument.
#[derive(Debug)]
pub enum ArgumentError<E> {... | true |
05c98616badcd9f4d4255d4944ee06a68fb48380 | Rust | saigono/raytrace | /src/camera.rs | UTF-8 | 1,996 | 2.90625 | 3 | [] | no_license | use crate::linalg::{Ray, Vec3};
use rand::Rng;
pub struct Camera {
origin: Vec3,
lower_left_corner: Vec3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
w: Vec3,
lens_radius: f32,
t_open: f32,
t_close: f32,
}
pub fn random_in_unit_disk() -> Vec3 {
let mut p: Vec3;
... | true |
60d07fe228d2fb0047a614f417cb55a207002400 | Rust | ltabis/raytracer | /src/props/color.rs | UTF-8 | 682 | 3.828125 | 4 | [
"MIT"
] | permissive | /// A color struct containing rgba values.
#[derive(Clone)]
pub struct Color {
pub r: f64,
pub g: f64,
pub b: f64,
pub a: f64,
}
impl Color {
pub fn white() -> Color {
Color {
r: 1.0,
g: 1.0,
b: 1.0,
a: 0.0,
}
}
pub fn bla... | true |
699447e66072899b3fe269d17a96eb7259ac8f72 | Rust | NurimOnsemiro/language_performance_test | /quicksort/rust/src/main.rs | UTF-8 | 4,480 | 3.015625 | 3 | [] | no_license | extern crate rand;
use rand::Rng;
use std::time::SystemTime;
const NUM_DATA: usize = 1000000;
static mut stack: [u32; NUM_DATA] = [0; NUM_DATA];
static mut top: u32 = 0;
unsafe fn init_stack() {
top = 0;
}
unsafe fn push(val: u32) {
if top < NUM_DATA as u32 {
stack[top as usize] = val;
top ... | true |
d9cd7144a6dec04c2fca8496bbd40d130196d1df | Rust | dennisss/dacha | /pkg/ptouch/src/command.rs | UTF-8 | 5,462 | 3.125 | 3 | [
"Apache-2.0"
] | permissive | use crate::status::*;
/// Buffer used to construct a sequence of commands that should be send to the
/// printer.
///
/// Use the methods on this struct to append commands and eventually use
/// as_ref() to get the data which can be transfered in one bulk transfer.
pub struct CommandBuffer {
data: Vec<u8>,
}
impl... | true |
b38907bfe5a326e72419a65ffa59b59c78dc1dbd | Rust | beltegeuse/mitsuba_rs | /src/serialized.rs | UTF-8 | 7,512 | 2.53125 | 3 | [] | no_license | use crate::SerializedShape;
use std::fs::File;
use std::io::{BufReader, Cursor, Read, Seek};
use byteorder::{LittleEndian, ReadBytesExt};
use cgmath::*;
bitflags! {
struct Flags: u32 {
const HAS_NORMALS = 0x0001;
const HAS_TEXCOORDS = 0x0002;
const HAS_TANGENTS = 0x0004;
... | true |
8f52362a6624dc67bfa9b5dcc90e37a3b32a1b0b | Rust | Zoxc/coroutines | /coroutine/src/lib.rs | UTF-8 | 1,557 | 3.40625 | 3 | [] | no_license | #![feature(never_type)]
pub enum State<Y, R, B> {
Yielded(Y),
Complete(R),
Blocked(B),
}
pub trait Executor {
type Blocked;
}
pub trait Generator<E: Executor> {
type Yield;
type Return;
fn resume(&mut self, executor: E) -> State<Self::Yield, Self::Return, E::Blocked>;
}
pub trait Await<G>: ... | true |
8883f5fd0ccbf5f200abf42f965994b8530e75ff | Rust | arudei-dev/hep-framework | /src/math/lorentz/op_index.rs | UTF-8 | 851 | 2.84375 | 3 | [] | no_license | use std::ops::{Index, IndexMut};
use crate::math::number::Number;
use super::*;
impl<T> Index<usize> for Lorentz4<T>
where
T: Number + Clone + Copy
{
type Output = T;
fn index(&self, idx: usize) -> &Self::Output {
debug_assert!(idx < 4, "Lorentz-4: out of bounds index access!");
&self.con... | true |
93bb54c5f95a0a84065804f4d960c92bb3b03cfa | Rust | Atul9/kaos | /src/macros.rs | UTF-8 | 632 | 2.546875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | ///
/// Macro to define a point to flunk
#[macro_export]
macro_rules! flunk {
($name:expr) => {{
$crate::flunker($name, |_| {
panic!("KAOS: Flunking at \"{}\"", $name);
});
}};
}
///
/// Define kaos tests
#[macro_export]
macro_rules! kaostest {
($name:expr, $body:block) => {{
... | true |
521cba210332b67bbb7fd77f7de2a01ef66d983f | Rust | jairoandre/nannou-study | /src/worley/main.rs | UTF-8 | 1,841 | 3.125 | 3 | [] | no_license | use nannou::prelude::*;
fn main() {
nannou::app(model)
.update(update)
.run();
}
const ANGLE_STEP: f32 = PI / 64.0;
const POS_STEP: f32 = 2.0;
struct Thing {
pos: Point2,
n: u64,
angle: f32,
points: Vec<Point2>
}
impl Thing {
pub fn new() -> Self {
Self {
p... | true |
aebc34fee48bf2f3558737fe21e29243cdf9e8b9 | Rust | kognise/avigraph | /src/arinc424/fields/p037_longitude.rs | UTF-8 | 1,577 | 3.328125 | 3 | [] | no_license | use crate::arinc424::utils::parseable::Parseable;
use crate::arinc424::utils::string_reader::StringReader;
/**
The Longitude field contains the longitude of the geographic position
of the navigational feature identified in the record.
Geographic positions whose longitudes must be included in the data base
are defined... | true |
3c620e19ca2adbcb762fc2c9282ef70ec10da9ae | Rust | nathanm2/stm-rs | /stp-cli/src/main.rs | UTF-8 | 5,373 | 2.71875 | 3 | [
"MIT"
] | permissive | #[macro_use]
extern crate clap;
use clap::ArgMatches;
use colored::*;
use std::collections::HashMap;
use std::fs::File;
use std::io::{self, prelude::*, ErrorKind};
use std::result;
use twp::parsers::{self, FrameDecoder};
const PROG_NAME: &str = crate_name!();
struct CliError(Option<String>);
type Result = result::Re... | true |
99403c9b994e94f7375e4cfd46a255b096ad5e80 | Rust | RoxasShadow/rs-es | /src/operations/get.rs | UTF-8 | 4,402 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright 2015 Ben Ashford
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... | true |
1e31f6df1ecd3911cbff2b50660415bbd57b41f5 | Rust | tempbottle/ws-rs | /src/lib.rs | UTF-8 | 15,866 | 4.03125 | 4 | [
"MIT"
] | permissive | //! Usage
//! -----
//!
//! For simple applications, use one of the utility functions `listen` and `connect`:
//!
//! `listen` accpets a string that represents a socket address and a Factory, see
//! [Architecture](#architecture).
//!
//! ```no_run
//! // A WebSocket echo server
//!
//! use ws::listen;
//!
//! listen("... | true |
8ac075ea9d5d1ceb583a0a6a441f21e91c798855 | Rust | mmagician/reed-solomon-novelpoly | /reed-solomon-tester/build.rs | UTF-8 | 696 | 2.640625 | 3 | [] | no_license | use std::env;
use std::io::{Result, Write};
use std::path::PathBuf;
use fs_err::OpenOptions;
use rand::{self, distributions::Uniform, prelude::Distribution};
fn gen_10mb_rand_data() -> Result<()> {
let mut rng = rand::thread_rng();
let dice = Uniform::<u8>::new_inclusive(0, 255);
let data = dice.sample_iter(&mut ... | true |
cedcdbb8724bee53830d5a0ad4fcdfe06d165058 | Rust | wagnerf42/rayon-logs | /src/pool.rs | UTF-8 | 18,371 | 2.640625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! `LoggedPool` structure for logging raw tasks events.
#![macro_use]
// we can now use performance counters to tag subgraphs
#[cfg(feature = "perf")]
use perfcnt::linux::PerfCounterBuilderLinux;
#[cfg(feature = "perf")]
use perfcnt::linux::{CacheId, CacheOpId, CacheOpResultId, HardwareEventType, SoftwareEventType};
... | true |
75542324a488a8a480ddb6e1781db89f77be4961 | Rust | kattrali/webkitten | /src/command.rs | UTF-8 | 4,101 | 3.25 | 3 | [
"BSD-2-Clause"
] | permissive | use std::path::Path;
use std::fs::{File,metadata,read_dir};
use config::Config;
use ui::BrowserConfiguration;
/// A representation of a script which executes and returns a boolean value
/// indicating success
#[derive(Debug,Clone)]
pub struct Command {
pub path: String,
pub arguments: Vec<String>,
}
impl Com... | true |
0d50eef3ab88fa85ad1845d56066b76202ab0777 | Rust | monkeylyf/interviewjam | /arr/leetcode_shortest_unsorted_continuous_subarray.rs | UTF-8 | 1,193 | 3.5 | 4 | [] | no_license | /**
* Given an integer array, you need to find one continuous subarray that if you
* only sort this subarray in ascending order, then the whole array will be
* sorted in ascending order, too.
*
* You need to find the shortest such subarray and output its length.
*
* Example 1:
* Input: [2, 6, 4, 8, 10, 9, 15]
... | true |
b4adda85cd3515bd8e06b471774fa0d22a5c41b8 | Rust | Electron-libre/i3_tree_manager | /src/ui.rs | UTF-8 | 6,801 | 2.640625 | 3 | [
"MIT"
] | permissive | use std::{error::Error, io, io::Stdout};
use i3ipc::reply::Node;
use termion::{input::MouseTerminal, raw::IntoRawMode, raw::RawTerminal, screen::AlternateScreen};
use tui::style::{Color, Modifier, Style};
use tui::text::{Span, Spans};
use tui::widgets::Paragraph;
use tui::{
backend::TermionBackend,
layout::{Co... | true |
9132713dad88bdf61e5dd231e25be029878a3598 | Rust | shadowng/rust-protobuf | /protobuf/src/reflect/runtime_type_box.rs | UTF-8 | 1,346 | 3.203125 | 3 | [
"MIT"
] | permissive | use crate::reflect::EnumDescriptor;
use crate::reflect::MessageDescriptor;
use std::fmt;
/// Runtime representation of elementary protobuf type.
#[derive(Debug, Clone)]
pub enum RuntimeTypeBox {
/// `i32`
I32,
/// `i64`
I64,
/// `u32`
U32,
/// `u64`
U64,
/// `f32`
F32,
/// `... | true |
84ce686f2d5533d38e86c3c6d933fb04b4caa942 | Rust | dtorok/advent_of_code | /2022/src/day05.rs | UTF-8 | 5,153 | 3.109375 | 3 | [] | no_license | // use core::slice::SlicePattern;
use scanf::sscanf;
// ===
// COMMAND
// ===
#[derive(Debug)]
struct Command {
from: usize,
to: usize,
amount: u8
}
impl Command {
fn new(from: usize, to: usize, amount: u8) -> Command {
Command {
from: from,
to: to,
amount:... | true |
70165a9afe7cd70b042ce804998c4c3bf4e823ed | Rust | cmskog/crypto-bank | /util/src/parse.rs | UTF-8 | 1,663 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | //! WebSocket JSON messages parsing utilities.
//! TODO: This is too inconsistent API,
//! before implementing BitFinex.
use std::str::FromStr;
use std::convert::From;
use serde_json::Value;
use serde_json::value::Index;
use super::OptionExt;
use super::errors::*;
#[inline]
pub fn get_array<'a, I: Index>(event... | true |
512f08969080ef69b3d84ffd8327e4728d4f3308 | Rust | ttokutake/kic | /src/command/destroy.rs | UTF-8 | 532 | 2.515625 | 3 | [
"MIT"
] | permissive | use error::{CliError, Usage, UsageKind};
use super::Command;
use constant::ME;
use lib::setting;
#[derive(Debug)]
pub struct Destroy;
impl Command for Destroy {
fn usage(&self) -> Usage {
return Usage::new(UsageKind::Destroy);
}
fn main(&self) -> Result<(), CliError> {
let message = form... | true |
888369db57dfe3f71e78264b05759804a3e0a6b8 | Rust | cordx56/silang | /src/preprocessor.rs | UTF-8 | 2,746 | 3.078125 | 3 | [
"MIT"
] | permissive | use nom::{
IResult,
character::complete::{
none_of,
char,
line_ending,
not_line_ending,
},
bytes::complete::{
tag,
is_not,
escaped,
},
branch::{
alt,
permutation,
},
combinator::{
map,
all_consuming,
... | true |
688f81e1f50a166e88ed51b0dcfe539db23d5297 | Rust | JoNil/AOC2019 | /day_6_b/src/main.rs | UTF-8 | 2,004 | 3.46875 | 3 | [] | no_license | use std::collections::HashMap;
use std::error::Error;
use std::fs;
fn parse_orbits(input: &str) -> Result<HashMap<String, String>, Box<dyn Error>> {
let mut res = HashMap::new();
for line in input.lines() {
let split = line.split(")").collect::<Vec<&str>>();
let orbits = split.get(0).ok_or("Ba... | true |
95c1091d5608c779ebc6ad9868c2be7a3b4c3ed6 | Rust | Lol3rrr/tunneload-plugin | /tunneload-plugin/src/traits/middleware.rs | UTF-8 | 726 | 2.5625 | 3 | [] | no_license | use stream_httparse::Response;
use crate::{Config, MiddlewareRequest, MiddlewareResponse};
/// This Trait defines the interface for a Middleware-Plugin
///
/// # Note:
/// The Middleware-Plugin only exports the Parts that you implement
/// from this Trait.
/// So if you only implement the Request-Handler, the Plugin ... | true |
a62ab3e98a5357e3add5181ff92f83c0b1e103ec | Rust | johnterickson/rust | /compiler/rustc_codegen_cranelift/build_system/utils.rs | UTF-8 | 1,844 | 3.0625 | 3 | [
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"MIT",
"LicenseRef-scancode-other-permissive",
"NCSA",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::env;
use std::fs;
use std::io::Write;
use std::path::Path;
use std::process::{self, Command, Stdio};
#[track_caller]
pub(crate) fn try_hard_link(src: impl AsRef<Path>, dst: impl AsRef<Path>) {
let src = src.as_ref();
let dst = dst.as_ref();
if let Err(_) = fs::hard_link(src, dst) {
fs::cop... | true |
201575595b627bdb24fd18534028869d656444d6 | Rust | mthorning/nodever | /src/lib/node_module/standard_module.rs | UTF-8 | 1,538 | 2.609375 | 3 | [] | no_license | use std::io::Error;
use std::path::PathBuf;
use std::cmp::Ordering;
use regex::Regex;
use crate::pjson_detail::PjsonDetail;
use crate::node_module::*;
use crate::semver::Semver;
pub struct StandardModule {
pub name: String,
pub version: Option<Semver>,
pub dep_type: DepType,
}
impl NodeModule for Standa... | true |
92adf51f3615d5256ee5a22ae9d2d4335993781b | Rust | sbditto85/adventofcode_rust | /src/daythree.rs | UTF-8 | 2,514 | 3.59375 | 4 | [] | no_license | static TESTNUMBER: u32 = 325489;
pub fn day() -> String {
//// Right side
//println!("Right Side");
//check_number(9);
//check_number(10);
//check_number(11);
//check_number(12);
//// Top Side
//println!("Top Side");
//check_number(13);
//check_number(14);
//check_number(15... | true |
2e809ee1fce386694a4b5d98469f51d7665e0568 | Rust | fredley/AOC-2019 | /src/aoc/day_7.rs | UTF-8 | 4,942 | 3.25 | 3 | [] | no_license | use crate::aoc::computer;
use crate::aoc::utils;
pub fn day_seven(input: String) -> () {
let memory: Vec<i64> = input.split(",").map(utils::parse_int_64).collect();
run_without_feedback(&input.split(",").map(utils::parse_int).collect());
run_with_feedback(&memory);
}
fn run_with_feedback(memory: &Vec<i64>... | true |
6143bdcfd1ef4cd23c1edb5037ea7cf1dbb9435c | Rust | iCodeIN/tokio-file | /tests/aio_write_eagain.rs | UTF-8 | 2,408 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use divbuf::DivBufShared;
use futures::future::lazy;
use futures::{Future, future};
use tempfile::TempDir;
use tokio_file::{AioResult, File};
use tokio::runtime::current_thread;
macro_rules! t {
($e:expr) => (match $e {
Ok(e) => e,
Err(e) => panic!("{} failed with {:?}", stringify!($e), e),
})
... | true |
815b766f291c9390f11045bdc47ec47bca8f0e07 | Rust | ryanpbrewster/rust-project-euler | /src/problems/problem_162.rs | UTF-8 | 2,509 | 3.90625 | 4 | [] | no_license | /*
In the hexadecimal number system numbers are represented using 16 different
digits:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
The hexadecimal number AF when written in the decimal number system equals
10x16+15=175.
In the 3-digit hexadecimal numbers 10A, 1A0, A10, and A01 the digits 0,1 and A
are all present. Like numbers ... | true |
c4702d98f3f7396a8fff1c3039aa338c1b399fd0 | Rust | hamadu/competitive-rust | /src/atcoder/arc/arc072/e.rs | UTF-8 | 2,028 | 3.046875 | 3 | [] | no_license | #![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;
trait InputValue {
fn parse(s: &str) -> Self;
}
fn read<T: InputValue>() -> T {
let mut buf = String::new();
let _ = stdin().read_line(&mut buf);
T::parse(... | true |
901e46d3da355430fe81aeedc4e7ad83f7d0c432 | Rust | rye/rust-netaddr2 | /src/lib.rs | UTF-8 | 1,013 | 2.8125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! A crate for parsing, representing, and manipulating network addresses.
//!
//! `netaddr2` arose from a need to mask and subnet IP space logically similar
//! to the way that routers and network interface cards (NICs) do. This enables
//! the user to ask questions like:
//!
//! - Does this `IpAddr` belong to this `... | true |
ce468ebe1f63debb213ef2c0d39e426d8f7083a9 | Rust | coder543/rush | /src/errext.rs | UTF-8 | 417 | 2.890625 | 3 | [
"MIT"
] | permissive | use pancurses;
pub type PResult = Result<(), &'static str>;
pub trait ErrExt {
fn as_err(&self) -> PResult;
fn unwrap(&self);
}
impl ErrExt for i32 {
fn as_err(&self) -> PResult {
if *self == pancurses::ERR {
Err("screen is broken?")
} else {
Ok(())
}
}... | true |
3d12d362bb309bea0b5fb821c2489aae40748373 | Rust | ejrinkus/advent-of-code-2019 | /day-nine/src/main.rs | UTF-8 | 833 | 2.53125 | 3 | [] | no_license | #[macro_use] extern crate text_io;
fn main() {
let line = std::fs::read_to_string("day-nine/input.txt").expect("file not found");
let tape: Vec<i64> = intcode::to_tape(&line);
let mut comp = intcode::IntcodeComp::new(tape.clone());
comp.start();
while *comp.state() != intcode::IntcodeState::F... | true |
5f76d6a0ed859280b75fbb1f27a47b05bfa0605a | Rust | kmdreko/kmdnd | /kmdnd_server/src/typedid.rs | UTF-8 | 2,619 | 2.875 | 3 | [] | no_license | use std::fmt::{Debug, Display};
use std::marker::PhantomData;
use std::str::FromStr;
use mongodb::bson::Bson;
use serde::{de::Error, Deserialize, Serialize};
use uuid::Uuid;
pub trait TypedIdMarker {
fn tag() -> &'static str;
}
pub struct TypedId<T: TypedIdMarker>(Uuid, PhantomData<T>);
impl<T: TypedIdMarker> T... | true |
28ceb820eea9b08a088a40a8503e958b2187a831 | Rust | Nervengift/inwxdynserver | /src/inwx/mod.rs | UTF-8 | 3,519 | 2.671875 | 3 | [] | no_license | mod errors;
extern crate reqwest;
extern crate serde_xml_rs;
pub use self::errors::{UpdateError, UpdateResult};
use std::net::IpAddr;
const API_URL: &str = "https://api.domrobot.com/xmlrpc/";
// not a constant because those can't be used in fmt macros
macro_rules! api_xml {
() => ("<?xml version=\"1.0\"?>
<met... | true |
56282b6c179234db8763e9ff2a17ce07b0488c3c | Rust | strangeman/vincenty-benchmark | /src/distance.rs | UTF-8 | 2,345 | 2.765625 | 3 | [] | no_license | use std::f64;
use std::f64::NAN;
// rewritten 'as-is' from Go package github.com/asmarques/geodist
// https://github.com/asmarques/geodist/blob/master/vincenty.go
fn vincenty_distance(lat1: f64, lon1: f64, lat2: f64, lon2: f64) -> f64 {
let a: f64 = 6378137.0;
let f: f64 = 1.0/298.257223563;
let b: f64 = 6356752.3... | true |
29fecbbb72a77ac03c1e09d04683e8a3eb3d33b6 | Rust | eopb/mun | /crates/mun_language_server/src/db.rs | UTF-8 | 2,721 | 2.578125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #![allow(clippy::enum_variant_names)] // This is a HACK because we use salsa
use crate::cancelation::Canceled;
use hir::{DefDatabaseStorage, HirDatabase, HirDatabaseStorage, SourceDatabaseStorage};
use mun_target::spec::Target;
use salsa::{Database, Runtime, Snapshot};
use std::panic;
/// The `AnalysisDatabase` provi... | true |
324868f6d92749cc1a4ca743a9e7f19df4f2610f | Rust | Verdex/sliver | /compiler/src/lexer.rs | UTF-8 | 11,338 | 3.125 | 3 | [
"MIT"
] | permissive |
use super::data::Token;
use super::input::Input;
#[derive(Debug)]
#[derive(PartialEq)]
enum Mode {
Normal,
ProtoComment,
LineComment,
BlockComment,
MaybeEndBlockComment,
Str,
Number,
Symbol,
}
fn lex_normal( c : char, toks : &mut Vec<Token>, buffer : &mut Vec<char> ) -> Mode {
ma... | true |
ae116cd20c4ca766d000a7f67ccd597c089b951c | Rust | haodeng/rust_beginner | /src/closure.rs | UTF-8 | 2,936 | 3.9375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | use std::thread;
use std::time::Duration;
fn generate_workout(intensity: u32, random_number: u32) {
let expensive_closure = |num| {
println!("calculating slowly...");
thread::sleep(Duration::from_secs(2));
num
};
if intensity < 25 {
println!("Today, do {} pushups!", expensi... | true |
9637c45f15807093b0f1685d6b38fb6286072910 | Rust | Dynisious/bitio | /src/bits/iter.rs | UTF-8 | 1,941 | 3.140625 | 3 | [] | no_license | //! Defines iterators for `Bits`.
//!
//! Author --- DMorgan
//! Last Moddified --- 2019-12-30
use super::*;
use core::iter::{Iterator, ExactSizeIterator,};
/// An iterator which cycles through all of the bits from `B1` too `B8`.
#[derive(PartialEq, Eq, Clone, Copy, Debug,)]
pub struct Cycle(pub(crate) Option<Bits... | true |
0ed31118290cbc39a6cc248ab9f6dfd0dfbb5246 | Rust | jawline/Brainfuck-In-Rust | /src/main.rs | UTF-8 | 1,844 | 2.90625 | 3 | [] | no_license | use std::io;
use std::io::{Write, Read};
pub struct BFState {
pub pos: usize,
pub cells: Vec<u8>
}
impl BFState {
pub fn new() -> BFState {
BFState { pos: 0, cells: [0; 30000].to_vec() }
}
}
macro_rules! bf_program {
($var:ident; + $($rest:tt)*) => {
$var.cells[$var.pos] += 1;
bf_program!($var... | true |
1d668043568eece54c7e9de856f6a48bd69c31a7 | Rust | graphprotocol/rust-web3 | /src/transports/ipc.rs | UTF-8 | 16,667 | 2.53125 | 3 | [
"MIT"
] | permissive | //! IPC Transport for *nix
#[cfg(unix)]
extern crate tokio_uds;
use std::collections::BTreeMap;
use std::io::{self, Read, Write};
use std::path::Path;
use std::sync::{atomic, Arc};
#[cfg(unix)]
use self::tokio_uds::UnixStream;
use crate::api::SubscriptionId;
use crate::helpers;
use crate::rpc;
use crate::transports... | true |
53eed6bbad4aa36bb9cec1727611b7694ce096aa | Rust | AircastDev/yew-component-size | /examples/basic.rs | UTF-8 | 1,258 | 2.640625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use wasm_bindgen::prelude::*;
use yew::prelude::*;
use yew_component_size::{ComponentSize, ComponentSizeObserver};
struct MyComponent {
link: yew::ComponentLink<Self>,
size: ComponentSize,
}
enum Msg {
OnComponentSize(ComponentSize),
}
impl Component for MyComponent {
type Message = Msg;
type Pro... | true |
8428efbd938744ae5d082fd0931fc74ec4e5780c | Rust | MichaelHe1125/rust-leetcode | /src/p0263_ugly_number.rs | UTF-8 | 1,459 | 4.125 | 4 | [] | no_license | // 263. Ugly Number
// Easy
// Write a program to check whether a given number is an ugly number.
// Ugly numbers are positive numbers whose prime factors only include 2, 3, 5.
// Example 1:
// Input: 6
// Output: true
// Explanation: 6 = 2 × 3
// Example 2:
// Input: 8
// Output: true
// Explanation: 8 = 2 × 2 × ... | true |
4c96b6941f3b8be174543f2333678e5211739b88 | Rust | Grzybojad/advent_of_code_2020 | /src/day17.rs | UTF-8 | 3,830 | 3.265625 | 3 | [] | no_license | #[derive(PartialEq, Copy, Clone)]
pub struct Cube {
// pos: V3,
pos: V4,
active: bool
}
// Commented out part 1 stuff, it's the same as part2, just switch V4 to V3 and remove all the w component stuff
// #[derive(PartialEq, Copy, Clone)]
// pub struct V3 {
// x: i32,
// y: i32,
// z: i32,
// }... | true |
3a5564b74750bc63d5aa1b44a5ac45a2f4436d7f | Rust | tuzz/laika | /src/view/scene/mod.rs | UTF-8 | 2,334 | 3.046875 | 3 | [] | no_license | use ::util::{Circle, Color, Matrix};
use ::model::Model;
use super::buffer::Buffer;
use super::program::Program;
use super::webgl::WebGLRenderingContext as GL;
use std::f32::consts::PI;
pub struct Scene {
program: Program,
circle_points: Buffer,
}
pub const NUMBER_OF_POINTS: usize = 50;
impl Scene {
p... | true |
37edcf220938ea9bd70c0c0becc4abafc3f79c04 | Rust | ibodrov/rust-notes | /examples/errors5.rs | UTF-8 | 472 | 3.59375 | 4 | [] | no_license | #[derive(Debug)]
enum MyError {
}
fn perform_something() -> Result<i32, MyError> {
Ok(123)
}
fn main() {
let x = perform_something().unwrap();
// Ok(x) или panic!
let y = perform_something().expect("OMG!");
// Ok(x) или panic! с сообщением
let z = perform_something()
.or_else(|_| -> ... | true |
05fc3a656df3a2812e80e9c4f6910d1db70b7caf | Rust | thodges314/Rust | /projects/chapter4/references_and_borrowing/src/main.rs | UTF-8 | 662 | 3.703125 | 4 | [] | no_license | // see return_values_with_tuple for comparison
fn main() {
let s1 = String::from("hello");
// change(&s1);
let len = calculate_length(&s1);
println!("The length of '{}' is {}.", s1, len);
}
fn calculate_length(s: &String) -> usize {
s.len()
} // since s is a reference, the value that it points ... | true |
7292eaca45440a1578233606f2801cb1ae8d6ae9 | Rust | rpalo/advent-of-code-2019 | /src/day5.rs | UTF-8 | 581 | 3.265625 | 3 | [] | no_license | /// Day 5: Sunny with a Chance of Asteroids
///
/// Test out the Thermal Environment Supervision Terminal
/// in the Intcode Interpreter
use std::fs;
use crate::intcode;
/// Parses the input. Expects a single line of integers separated by
/// commas
fn parse_input() -> Vec<isize> {
let text: String = fs::read_t... | true |
667f9cf83be78c7079e4245536541a5bd6435238 | Rust | zdelv/slicing | /src/geometry/vector.rs | UTF-8 | 6,541 | 3.609375 | 4 | [] | no_license | use serde::Serialize;
use std::fmt::Formatter;
use std::ops::{Add, Div, Mul, Neg, Sub};
use std::ops::{AddAssign, DivAssign, MulAssign, SubAssign};
// Purposely not generic right now
// In the long term, this can be made generic over f32 and f64 (at the very least).
#[derive(Debug, Copy, Clone, PartialEq, Serialize)]
... | true |
ab223542c68e8650eac58b287336dfeeaf34b3f9 | Rust | maurer/mycroft | /src/ir.rs | UTF-8 | 21,798 | 3.1875 | 3 | [] | no_license | //! The IR module describes the internal representation of the program.
//! Transformation into the IR will also check the AST for validity, so errors may be returned in
//! some cases.
use std::collections::{BTreeMap, BTreeSet};
use crate::ast;
/// `error-chain`-generated error module for the checks occurring durin... | true |
8f9d5c59cd00e587f0fc5fd0fb9b3333567487ab | Rust | zaeleus/noodles | /noodles-sam/src/header/parser/record.rs | UTF-8 | 2,031 | 3.109375 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
mod kind;
mod value;
use std::{error, fmt};
use self::{kind::parse_kind, value::parse_value};
use crate::header::Record;
use super::Context;
/// An error returned when a SAM header record fails to parse.
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum ParseError {
/// The header prefix is ... | true |
c1ac75ebe0a2239e6a1c36c1efc2191382d4d40b | Rust | jdonszelmann/aoc2019 | /src/day17/challenge1.rs | UTF-8 | 2,055 | 3.125 | 3 | [] | no_license | use crate::day02::challenge1::CPU;
use crate::day11::challenge1::get_cpu;
use std::cell::RefCell;
fn find_intersections(values: Vec<Vec<char>>) -> u64 {
let mut sum = 0;
for (y, column) in values.iter().enumerate() {
for (x, value) in column.iter().enumerate() {
let above = if y > 0 { valu... | true |
7037818cec03a098aced8ffaa563743735bdea31 | Rust | TaktInc/http-log-to-statsd | /http-log-to-statsd.rs | UTF-8 | 3,797 | 2.5625 | 3 | [] | no_license | extern crate rustc_serialize;
extern crate docopt;
extern crate cadence;
use docopt::Docopt;
use cadence::prelude::*;
use cadence::{StatsdClient, UdpMetricSink, DEFAULT_PORT};
use std::net::UdpSocket;
#[derive(Debug, RustcDecodable)]
struct Options {
flag_v: isize,
flag_listen: String,
flag_statsd: String... | true |
071935893833c3265cafa679b459031db50837f3 | Rust | overvenus/benches-rust | /src/collections/mod.rs | UTF-8 | 6,388 | 2.703125 | 3 | [] | no_license | use test;
use fnv::{FnvHashMap, FnvBuildHasher};
use ordermap::OrderMap;
use rand;
use rand::Rng;
use rand::Rand;
fn new_rand_vec<T: Rand>(size: usize) -> Vec<T> {
let mut rng = rand::thread_rng();
rng.gen_iter::<T>().take(size).collect::<Vec<T>>()
}
macro_rules! bench_map {
(q $name:ident => $map:expr ... | true |
6e916a9b547566456467036888870c856949b614 | Rust | simmsb/vm-rust | /src/memory.rs | UTF-8 | 5,005 | 3.15625 | 3 | [
"MIT"
] | permissive | use byteorder::{ByteOrder, NativeEndian};
use ::cpu::{Cpu, CpuIndex, Reg, CpuIndexable};
#[derive(Copy, Clone, FromPrimitive, Debug)]
pub enum MemSize {
U1,
U2,
U4,
U8,
}
#[derive(PartialEq, Debug, Copy, Clone)]
pub enum MemReg {
U1(u8),
U2(u16),
U4(u32),
U8(u64),
}
impl MemSize {
... | true |
0cd06e7685ba36a362af017c084f0697213af1a2 | Rust | rednithin/LeetCode | /30 Day Challenge/April 2020/18 - Minimum Path Sum.rs | UTF-8 | 1,259 | 3.1875 | 3 | [] | no_license | use std::cmp;
use std::collections::HashMap;
impl Solution {
pub fn find_minimum_path(
grid: &Vec<Vec<i32>>,
hashmap: &mut HashMap<(usize, usize), i32>,
i: usize,
j: usize,
m: usize,
n: usize,
) -> i32 {
if let Some(x) = hashmap.get(&(i, j)) {
... | true |
7240fa7fc013930a2e759ea5dfbba948f8bb298d | Rust | avranju/web-refresh | /src/main.rs | UTF-8 | 3,077 | 2.859375 | 3 | [
"MIT"
] | permissive | use std::io;
use std::os::raw::c_int;
use std::str::FromStr;
use std::string::ParseError;
use std::thread;
use crossbeam_channel as channel;
use log::info;
use signal_hook::{iterator::Signals, SIGINT, SIGUSR1};
use structopt::StructOpt;
use webdriver_client::{
chrome::ChromeDriver, firefox::GeckoDriver, messages::... | true |
602ec1c3dbed79fa8267aaceef50d9aeb3bd1251 | Rust | matter-labs/hodor | /src/air/constraint.rs | UTF-8 | 8,915 | 3.015625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use ff::{
PrimeField,
};
use super::*;
use std::ops::{AddAssign, SubAssign, MulAssign};
use std::default::Default;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct BoundaryConstraint<F: PrimeField> {
pub register: Register,
pub at_row: usize,
pub value: Option<F>,
}
#[derive(Debug, Clone, PartialEq... | true |
90a9378c4942a340e0f424b5893f4320801c524e | Rust | tlent/advent-of-code-2019 | /day-12/src/main.rs | UTF-8 | 4,787 | 3.28125 | 3 | [] | no_license | use std::cmp::Ordering;
use std::ops::{Add, AddAssign};
const INPUT: &str = include_str!("../input.txt");
fn main() {
let moons = Moon::moons_from_input(INPUT);
println!("{}", solve_part_one(&moons));
println!("{}", solve_part_two(&moons));
}
fn solve_part_one(moons: &[Moon]) -> i32 {
let mut moons =... | true |
fd276fa7ed9f9c1b4a8c39a0641ba92805849643 | Rust | maidsafe/temp_safe_network | /safenode/src/client/register/offline_replica.rs | UTF-8 | 11,706 | 2.640625 | 3 | [] | no_license | // Copyright 2023 MaidSafe.net limited.
//
// This SAFE Network Software is licensed to you under The General Public License (GPL), version 3.
// Unless required by applicable law or agreed to in writing, the SAFE Network Software distributed
// under the GPL Licence is distributed on an "AS IS" BASIS, WITHOUT WARRANTI... | true |
50e1c0bed2aa447f849977132cca231dacf10dad | Rust | jamie-c-starling/advent-of-code-2020 | /src/bin/6_2.rs | UTF-8 | 857 | 3.03125 | 3 | [] | no_license | use std::collections::HashMap;
use std::fs;
fn main() {
let contents = fs::read_to_string("src/bin/resources/6_input.txt")
.expect("Something went wrong reading the file");
let groups = contents.split("\n\n");
let mut dec_count = 0;
for group in groups {
let mut occurances: HashMap<ch... | true |
2af77eaba823eab179cbe64b9d19c11334842da6 | Rust | realbigsean/lighthouse | /common/fallback/src/lib.rs | UTF-8 | 1,705 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | use itertools::{join, zip};
use std::fmt::{Debug, Display};
use std::future::Future;
#[derive(Clone)]
pub struct Fallback<T> {
pub servers: Vec<T>,
}
#[derive(Debug, PartialEq)]
pub enum FallbackError<E> {
AllErrored(Vec<E>),
}
impl<T> Fallback<T> {
pub fn new(servers: Vec<T>) -> Self {
Self { se... | true |
670dcd2814f865b3ced20b5810322afd38b46917 | Rust | miller-time/rust-warrior | /src/engine.rs | UTF-8 | 3,305 | 3.1875 | 3 | [
"MIT"
] | permissive | //! The game engine
//!
//! This module was formerly the home of a [specs][specs] implementation but is
//! now home to a zero-dependency version of the engine that functions almost
//! identically. It ended up being a little more straightforward when entities
//! did not need to be queried.
//!
//! When `start` is cal... | true |
3c33fc13032bbe0f92f91dae48907ece0dda89ac | Rust | cbonaudo/exercism-rust | /pascals-triangle/src/lib.rs | UTF-8 | 1,177 | 3.640625 | 4 | [] | no_license | pub struct PascalsTriangle {
row_nb: u32,
}
impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
Self {
row_nb: row_count,
}
}
pub fn rows(&self) -> Vec<Vec<u32>> {
let mut rows_vec = Vec::new();
for row_nb in 0..self.row_nb {
if row_nb =... | true |
6c895cc8b13e959b1fa437bd37559f3d5a19fd75 | Rust | another-s347/io-index | /src/lang.rs | UTF-8 | 1,554 | 3.125 | 3 | [] | no_license | pub struct Language {
pub lang: &'static str,
pub nav_lang_link: &'static str,
pub nav_blogs: &'static str,
pub nav_projects: &'static str,
pub nav_learning: &'static str,
pub last_update: &'static str,
pub time_week: &'static str,
pub time_day: &'static str,
pub time_hour: &'static... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.