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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c6bc2ec70e2c265bdc1b1e92e2a700fb596de000 | Rust | danielhenrymantilla/mini_paste | /src/proc_macro/mod.rs | UTF-8 | 6,424 | 2.921875 | 3 | [
"Apache-2.0",
"Zlib"
] | permissive | extern crate proc_macro;
use ::proc_macro::{*, TokenTree as TT};
use ::core::iter;
macro_rules! matches {(
$expr:expr,
$(|)? $($pat:pat)|+
$(if $guard:expr)?
$(,)?
) => (match $expr {
$(| $pat)+
$(if $guard)?
=> true,
| _
=> false,
})}
#[proc_macro] pub
fn item (input: Toke... | true |
6e37c00c08e1f2daac9b77e203571d360204d711 | Rust | me020523/rust-playground | /array/src/main.rs | UTF-8 | 63 | 2.671875 | 3 | [] | no_license | fn main() {
let x = [5;5];
println!("x is {}",x[2]);
}
| true |
628637522203a680601ab762ed228b6df248faa9 | Rust | RiverTethys/rust-rosetta | /src/factorial.rs | UTF-8 | 1,880 | 3.71875 | 4 | [
"Unlicense",
"LicenseRef-scancode-public-domain"
] | permissive | // Implements http://rosettacode.org/wiki/Factorial
use std::iter::range_inclusive;
// Calculate the factorial using recursion
fn factorial_recursive (n: uint) -> uint {
match n {
0 => 1,
_ => n * factorial_recursive(n-1)
}
}
// Calculate the factorial using a fold
fn factorial_iterative(n: uint) -> uint {
ra... | true |
0b461964897ccaec6c9cc035c07f825f6cf1de7b | Rust | cibingeorge/rquickjs | /core/src/loader/bundle.rs | UTF-8 | 2,650 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::resolve_simple;
use crate::{Ctx, Error, Loaded, Loader, Module, Resolver, Result, Script};
use std::ops::Deref;
/// The module data which contains bytecode
///
/// This trait needed because the modules potentially can contain any kind of data like a typing (for TypeScript) or metadata.
pub trait HasByteCode... | true |
5cef3d65523d1c5b43c2a2c2277a71ea8668851d | Rust | pco2699/algorithms | /floyd-warshall/src/main.rs | UTF-8 | 3,636 | 2.953125 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader, Error};
use std::collections::HashMap;
use std::str::FromStr;
type Graph = HashMap<usize, HashMap<usize, i64>>;
fn main() {
println!("{}", run("g1.txt"));
println!("{}", run("g2.txt"));
println!("{}", run("g3.txt"));
}
fn run(filename: &str) -> String... | true |
29494eafd346192730888ed65a0ccd208f2446ed | Rust | mozilla/gecko-dev | /third_party/rust/wasm-encoder/src/core/types.rs | UTF-8 | 10,852 | 2.859375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"LLVM-exception",
"Apache-2.0"
] | permissive | use crate::{encode_section, Encode, Section, SectionId};
/// Represents a subtype of possible other types in a WebAssembly module.
#[derive(Debug, Clone)]
pub struct SubType {
/// Is the subtype final.
pub is_final: bool,
/// The list of supertype indexes. As of GC MVP, there can be at most one supertype.
... | true |
aadb974c1caece19a21d6adea020f11a45faba6c | Rust | Emurgo/rust-cardano | /chain-impl-mockchain/src/message/config.rs | UTF-8 | 1,991 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::config::ConfigParam;
use chain_core::mempack::{ReadBuf, ReadError, Readable};
use chain_core::property;
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(
feature = "generic-serialization",
derive(serde_derive::Serialize, serde_derive::Deserialize),
serde(transparent)
)]
pub struct ConfigParams(... | true |
cb17355dd50f82fe4526d681fdc4fbf84dcb8291 | Rust | dendisuhubdy/degen-wallet | /degen-wallet-rs/src/tui/draw.rs | UTF-8 | 1,736 | 2.8125 | 3 | [] | no_license | use std::error::Error;
use termion::event::Key;
use tui::widgets::{Block, Borders};
use crate::tui::{
helpers::{draw_standard_grid, init_terminal},
state::{AppState, Drawable, Screen},
util::event::{Event, Events},
};
pub fn draw_screen() -> Result<(), Box<dyn Error>> {
let mut terminal = init_termin... | true |
b2e1195ec792caa11f94837547d9d91fcb59f297 | Rust | nikomatsakis/vectormath-rs | /src/angle.rs | UTF-8 | 844 | 3.65625 | 4 | [
"MIT"
] | permissive | #![deny(missing_docs)]
//! Radian and Degree
use float::Float;
/// Angle in radians
#[derive(Debug, Copy, Clone)]
pub struct Rad<T>(pub T);
/// Angle in degrees
#[derive(Debug, Copy, Clone)]
pub struct Deg<T>(pub T);
impl<T: Float> From<Rad<T>> for Deg<T> {
#[inline(always)]
fn from(r: Rad<T>) -> Deg<T> {
... | true |
f57381193171ab50ed4f42dabbd6537ffdb94e66 | Rust | fossabot/Mirage | /libswitch/src/i2c/mod.rs | UTF-8 | 12,664 | 2.84375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Inter-Integrated Circuit driver for Tegra210.
//!
//! # Description
//!
//! The I²C controller (I2C) implements an I²C 3.0 specification-compliant
//! I²C master and slave controller. The I²C controller supports multiple
//! masters and slaves. It supports Standard mode (up to 100 Kbits/s),
//! Fast mode (up to 400... | true |
00dea3d0a7065fb05c3aef45d1922822f8aec097 | Rust | Owez/nakes | /src/init.rs | UTF-8 | 597 | 2.8125 | 3 | [] | no_license | //! Allows creation of a new project with specified name
use std::fs::File;
use std::io::prelude::*;
use crate::{log, Error, Result};
/// Creates a nrw lockfiles from bytes embedded into the binary
fn create_lockfile() -> Result<()> {
log::info("Generating lockfile");
let lockfile_bytes = include_bytes!("..... | true |
d30aa4cc70529dc32794055586ab3b041d15fd13 | Rust | jfoote/wasmtime | /crates/api/tests/externals.rs | UTF-8 | 2,328 | 2.78125 | 3 | [
"LLVM-exception",
"Apache-2.0"
] | permissive | use wasmtime::*;
#[test]
fn bad_globals() {
let ty = GlobalType::new(ValType::I32, Mutability::Var);
assert!(Global::new(&Store::default(), ty.clone(), Val::I64(0)).is_err());
assert!(Global::new(&Store::default(), ty.clone(), Val::F32(0)).is_err());
assert!(Global::new(&Store::default(), ty.clone(), V... | true |
fd6569a784eb6a531d982264261bf66de164bf13 | Rust | Orca-bit/DataStructureAndAlgorithm | /src/other/_75_sort_colors.rs | UTF-8 | 755 | 3.46875 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn sort_colors(nums: &mut Vec<i32>) {
if nums.len() < 2 {
return;
}
let mut left = -1;
let mut right = nums.len();
let mut index = 0;
while index < right {
if nums[index] == 0 {
left += 1;
... | true |
8c66e2842c6f250cb48eed3e9d8cc52da0fbac44 | Rust | Nilstrieb/NumberSystemConverter | /src/main.rs | UTF-8 | 1,432 | 3.3125 | 3 | [] | no_license | mod converter;
#[macro_use]
extern crate lazy_static;
extern crate regex;
use std::io;
use regex::Regex;
use std::result::Result::Err;
fn main() {
println!("Enter a conversion | help");
loop {
let mut input = String::new();
io::stdin()
.read_line(&mut input)
.expect... | true |
d6d4ce878e30678b2acba2905f526453a9461d92 | Rust | Gasper/AdventOfCode2019 | /day13/thirteen.rs | UTF-8 | 11,522 | 3.09375 | 3 | [] | no_license | use std::convert::From;
use std::fs::read;
use std::collections::HashMap;
const FINISH: i64 = 99;
const ADD: i64 = 1;
const MULTIPLY: i64 = 2;
const INPUT: i64 = 3;
const OUTPUT: i64 = 4;
const JMP_TRUE: i64 = 5;
const JMP_FALSE: i64 = 6;
const LESS_THAN: i64 = 7;
const EQUALS: i64 = 8;
const ADJUST_BASE: i64 = 9;
#[... | true |
a7084867725b165b32bf5d0343810187c80e0167 | Rust | Technical27/postman | /src/helpers.rs | UTF-8 | 6,157 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serenity::client::Context;
use serenity::framework::standard::{Args, CommandResult};
use serenity::model::prelude::{Message, ReactionType};
use std::env;
use json::JsonValue;
use regex::Regex;
use log::trace;
use lazy_static::lazy_static;
use diesel::prelude::*;
use super::post::*;
use super::reddit::*;
us... | true |
dcadb131da4edd7d081e4d1e6ab5aec960d21b12 | Rust | raiote/design-pattern | /bridge/src/channel/wechat.rs | UTF-8 | 483 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::Pay;
use crate::mode::IPayMode;
pub struct WeChat<T:IPayMode>{
pay_mode: T
}
impl<T:IPayMode> Pay<T> for WeChat<T>{
fn new(pay_mode: T)->Self {
Self{
pay_mode
}
}
fn transfer(&self, uid: &str, trade_id: &str, amount: u64){
println!("WeChat pay simulation... | true |
0d81ad317259351ac9f041d7ca57afff38688832 | Rust | hobofan/ambassador | /ambassador/tests/run-pass/gat.rs | UTF-8 | 684 | 3.09375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | extern crate ambassador;
use ambassador::{delegatable_trait, Delegate};
#[delegatable_trait]
pub trait StreamingIterator {
type Output<'a>
where
Self: 'a;
fn next(&mut self) -> Option<Self::Output<'_>>;
}
struct RepeatMut<T>(T);
impl<T> StreamingIterator for RepeatMut<T> {
type Output<'a> = ... | true |
6f1948551a9f97b3df9e24798047ddb40b5902f6 | Rust | gkbrk/rust-ipfs-api | /src/str_error.rs | UTF-8 | 645 | 3.171875 | 3 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt::{Debug, Display};
pub struct StrError<'a> {
msg: &'a str,
}
impl<'a> StrError<'a> {
pub fn from_str(error: &str) -> Box<StrError> {
Box::new(StrError { msg: error })
}
}
impl<'a> Display for StrError<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> ... | true |
f9cdf5332c36a27753fc922b42ba0e213fc80b7f | Rust | mattaschmann/codewars_rust | /src/bouncing_balls.rs | UTF-8 | 1,040 | 3.546875 | 4 | [] | no_license | fn bouncing_ball(h: f64, bounce: f64, window: f64) -> i32 {
// h must be greater than 0
if !(h > 0.0) { return -1; }
// bounce must be between 0 and 1
if !(0.0 < bounce && bounce < 1.0) { return -1; }
// window must be between 0 and h
if !(0.0 < window && window < h) { return -1; }
let mut count = 1;
... | true |
4f26b8a020ae5b2ca8640620cae1af8169ce753b | Rust | eukaryote/rtss | /benches/tests.rs | UTF-8 | 2,991 | 2.75 | 3 | [] | no_license | #![feature(test)]
extern crate rand;
extern crate test;
extern crate rtss;
#[cfg(test)]
mod small {
use test::Bencher;
use rtss;
#[bench]
fn empty(b: &mut Bencher) {
b.iter(|| 1)
}
#[bench]
fn one_byte_share_rtss_one_of_one(b: &mut Bencher) {
let v: Vec<u8> = vec![42];
... | true |
3e51df0e46367079deb526f4ba9f4a2ec379d041 | Rust | SeanTater/elkridge | /src/main.rs | UTF-8 | 8,524 | 2.609375 | 3 | [
"MIT"
] | permissive | extern crate fuse;
extern crate rusqlite;
#[macro_use] extern crate clap;
#[macro_use] extern crate failure;
extern crate libc;
extern crate time;
use failure::Fallible;
use std::ffi::OsStr;
use time::Timespec;
use libc::ENOENT;
use fuse::{FileType, FileAttr, Filesystem, Request, ReplyData, ReplyEntry, ReplyAttr, Repl... | true |
e101e27ac3ab38eb1979c8e8e92224a865469dcd | Rust | asvedr/oolang | /src/bytecode/exc_keys.rs | UTF-8 | 4,444 | 2.921875 | 3 | [] | no_license | use std::collections::{HashMap, BTreeMap};
use std::io::{Read, Write, Result, Error, ErrorKind};
use std::fs::File;
use std::str::FromStr;
use syn::SynMod;
// all exception keys are the numbers in C
// must make one NAME-CODE map for all modules in application
pub struct ExcKeys {
map : HashMap<String,usize>,
... | true |
208f2086dfa21ead9e60bf39360255db00b62be2 | Rust | beagleknight/roguelike-ecs | /src/game.rs | UTF-8 | 7,530 | 2.578125 | 3 | [] | no_license | pub use tcod::{
colors,
input::{self, Event, Key, KeyCode},
};
use tcod::{console::*, Color};
use crate::components::{Object, Position, Tile};
use crate::map::TileKind;
const SCREEN_WIDTH: i32 = 80;
const SCREEN_HEIGHT: i32 = 50;
const BAR_WIDTH: i32 = 20;
const PANEL_HEIGHT: i32 = 7;
const PANEL_Y: i32 = SC... | true |
78f6376dba93b407fdeed9b418953aa52afb598a | Rust | igncp/code-gym | /rust/advent_of_code_18/24/src/main.rs | UTF-8 | 26,544 | 3.65625 | 4 | [] | no_license | /*
--- Day 24: Immune System Simulator 20XX ---
After a weird buzzing noise, you appear back at the man's cottage. He seems relieved to see his
friend, but quickly notices that the little reindeer caught some kind of cold while out exploring.
The portly man explains that this reindeer's immune system isn't similar t... | true |
43b9e1ce7c478f52933a87fc167de6221863d0ef | Rust | clankford/rustext | /src/main.rs | UTF-8 | 2,635 | 3.421875 | 3 | [] | no_license | use std::io;
/* use std::fs::File;
use std::io::prelude::*; */
fn main() {
println!("What is your name?");
let mut name = String::new();
io::stdin().read_line(&mut name)
.expect("Failed to read line");
println!("Hello, {}, nice to meet you!", name.trim());
}
/* println!("--------------");... | true |
09210085e613d63552938a89d0ce2799d0a171c8 | Rust | vindvaki/advent-of-code-2018 | /src/bin/day_08.rs | UTF-8 | 3,824 | 3.375 | 3 | [] | no_license | #[macro_use]
extern crate error_chain;
use std::io::Read;
mod errors {
error_chain!{}
}
use errors::*;
fn main() {
let mut data = String::new();
std::io::stdin().read_to_string(&mut data).unwrap();
let tree = parse_input(&data).unwrap();
println!("part_1: {}", part_1(&tree));
println!("part_... | true |
158fb2f5fae7948d32fc82c3ccb6414f61c0b32f | Rust | jansol/adventofcode | /2016/src/bin/01.rs | UTF-8 | 2,429 | 2.75 | 3 | [] | no_license | enum Step {
L(i32),
R(i32),
}
use Step::*;
fn left(orientation: (i32, i32)) -> (i32, i32) {
let (x,y) = orientation;
(-y,x)
}
fn right(orientation: (i32, i32)) -> (i32, i32) {
let (x,y) = orientation;
(y,-x)
}
fn main() {
println!("Hello, advent!");
let steps = vec![
R(2), L(... | true |
9136c27071848d0319975f38f4b41559f3eba7dd | Rust | adcopeland/peuler | /rust/peuler/src/my_big_int/mod.rs | UTF-8 | 3,068 | 3.609375 | 4 | [] | no_license | // Just enough BigInt for problems 13 and 16
#[derive(Clone, PartialEq, Eq)]
pub struct BigInt {
rep: Vec<u8>, // ascii "string" form of the int, stored with least significant digit first
}
impl BigInt {
// Make a new BigInt from a string. Converts the string into rep form (ascii string in reverse, in byte form)
... | true |
5cb162a5b9d12e4d76c35e941700439628ed2369 | Rust | wurstmineberg/wurstminebot-discord | /crate/wurstminebot/src/cal.rs | UTF-8 | 6,275 | 2.75 | 3 | [
"MIT"
] | permissive | use {
std::borrow::Cow,
chrono::{
Duration,
prelude::*,
},
serde::Deserialize,
serenity::{
prelude::*,
utils::Colour,
},
serenity_utils::RwFuture,
sqlx::{
PgPool,
types::Json,
},
tokio::time::sleep,
crate::{
Database,
... | true |
a781a9e2e9f08b62fbdd4d2035121738b75d1276 | Rust | wadachi-ware/wadachi-cpu | /src/processor.rs | UTF-8 | 34,771 | 3.1875 | 3 | [
"MIT"
] | permissive | use crate::decode::{decode, BType, IType, Instruction, JType, RType, SType, UType};
use crate::exception::Exception;
use crate::memory::Memory;
pub struct Processor {
pub regs: [u32; 32],
pub pc: u32,
pub mem: Box<dyn Memory>,
// Used to determine if the pc should be incremented.
has_jumped: bool,
... | true |
206c5b792bb0558bdfdff4f01b33d01320c7be41 | Rust | jpalip/RustGlass | /src/lang/lexer/token/token_type.rs | UTF-8 | 2,703 | 3.203125 | 3 | [] | no_license | #[derive(Copy, Clone, PartialEq)]
pub enum TokenType {
Plus,
Minus,
Times,
Divide,
Mod,
PlusEquals,
MinusEquals,
TimesEquals,
DivideEquals,
ModEquals,
Not,
Or,
GreaterThan,
GreaterThanEqual,
LessThan,
LessThanEqual,
NotEqual,
Number,
Identifier... | true |
16ce4c7890d71bd35197dba35d2fe688b66d1520 | Rust | ruizmarlon/habitat | /tools/one-off-release/src/main.rs | UTF-8 | 8,807 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use env_logger::Builder as LogBuilder;
use log::{debug,
error,
info,
LevelFilter};
use regex::Regex;
use reqwest::Url;
use std::{error,
fmt,
fs::{self,
File},
io::{self,
BufRead},
path::PathBuf,
process::Comman... | true |
3e4cb6852a088c2d99cbb2d7e33650f7b3512a58 | Rust | giodamelio/code-challenges | /project_euler/rust/src/math.rs | UTF-8 | 4,654 | 4 | 4 | [] | no_license | extern crate num;
use num::num_integer::Integer;
/// Get all the factors of a number
///
/// # Examples
/// ```
/// assert_eq!(math::factors(12), vec!(2, 3, 4, 6));
/// assert_eq!(math::factors(93), vec!(3, 31));
/// ```
pub fn factors(num: i64) -> Vec<i64> {
let mut factors: Vec<i64> = Vec::new();
let max = ... | true |
bab261de36e884fbef51a25a1d50d287952d8be6 | Rust | myddrin/advent_code_2020 | /rust/day_14/main.rs | UTF-8 | 5,463 | 3.40625 | 3 | [] | no_license | use std::{io, env};
use std::fs::File;
use std::io::{BufReader, BufRead};
use crate::Op::NewMask;
use std::collections::{HashMap, HashSet};
static BITS: usize = 36;
#[derive(Debug,PartialEq,Eq,Clone)]
enum Op {
NewMask,
Write,
}
#[derive(Debug,Clone)]
struct Operation {
op: Op,
a: usize, // new mask... | true |
f9808e59baffd037e6d3d030fa886ed3f69d819d | Rust | lluchs/ocmapgen | /src/mattex.rs | UTF-8 | 7,178 | 2.65625 | 3 | [
"ISC",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::ffi::*;
use crate::errors::*;
use crate::Handle;
use crate::group::Group;
use std::ffi::{CStr, CString};
use std::collections::HashMap;
use image::{self, DynamicImage};
use error_chain::bail;
pub struct MaterialMap {
handle: *mut C4MaterialMapHandle,
}
impl MaterialMap {
pub fn new() -> MaterialMa... | true |
c8fc3448780b98d2c69edb4298cbae585381a95e | Rust | rainliu/leetcode | /src/643MaximumAverageSubarrayI/643MaximumAverageSubarrayI.rs | UTF-8 | 430 | 2.671875 | 3 | [] | no_license | impl Solution {
pub fn find_max_average(nums: Vec<i32>, k: i32) -> f64 {
let n = nums.len();
let mut local = 0;
for i in 0..(k as usize) {
local += nums[i];
}
let mut global = local;
for i in (k as usize)..n {
local += nums[i]-nums[i-(k as usiz... | true |
f149f6f680fe4a5d3abcaef94090317989002be6 | Rust | elwizard33/zunitoken | /zunitoken_primitives/src/serialization.rs | UTF-8 | 1,214 | 2.6875 | 3 | [
"MIT"
] | permissive | use pairing::{Engine, PrimeField, Field, PrimeFieldRepr};
use std::{mem, io, iter};
use std::io::{Read, Write};
use byteorder::{BigEndian, ReadBytesExt};
pub fn read_fr_repr_be<Fr:PrimeField>(data: &[u8]) -> io::Result<Fr::Repr> {
let mut fr_repr = Fr::zero().into_repr();
match fr_repr.read_be(data) {
... | true |
dbbe7ae07c89c4d72c2ac5a33699f78c53feae17 | Rust | Schenk75/Learn-Rust | /leetcode-by-rust/LCOF/lcof66-构建乘积数组/src/main.rs | UTF-8 | 990 | 3.3125 | 3 | [] | no_license | struct Solution;
impl Solution {
pub fn construct_arr_storelists(a: Vec<i32>) -> Vec<i32> {
if a.is_empty() {return a;}
let mut a1 = vec![a[0]];
let mut a2 = vec![a[a.len()-1]];
for i in 1..a.len()-1 {
a1.push(a1[i-1] * a[i]);
a2.push(a2[i-1] * a[a.len()-1-i]... | true |
2051fdf234f67b32a6012be525eeaa06c3633275 | Rust | saerd/rust_image_compressor | /src/huffman.rs | UTF-8 | 4,904 | 2.953125 | 3 | [] | no_license | use std::rc::Rc;
use self::HuffLink::*;
use std::cell::RefCell;
use std::collections::HashMap;
use std::hash::Hash;
use compressor::Compressor;
use bits::BitString;
use std::cmp::Ordering::{Less, Greater};
use self::Proc::*;
type NodeMut<'a> = std::cell::RefMut<'a, HuffNode>;
type NodeRef<'a> = std::cell::Ref<'a, H... | true |
8fa3b5a4205d16b6f4c5b2bc9fae88fc92dfff82 | Rust | qiuchengxuan/rs-swagger-utils | /src/swagger/mod.rs | UTF-8 | 741 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use definition::Definitions;
use path::Paths;
#[derive(Debug, PartialEq, Deserialize)]
pub struct Swagger {
#[serde(rename = "swagger")]
pub spec: Option<String>,
pub definitions: Option<Definitions>,
pub paths: Option<Paths>,
}
#[cfg(test)]
mod tests {
use std::fs::File;
use std::path::PathBu... | true |
3de565362d4b7a8d185ebeec80388bbdbe5c4f25 | Rust | mtXTJocj/rosetta_code | /ast_interpreter/src/main.rs | UTF-8 | 961 | 2.71875 | 3 | [
"Unlicense"
] | permissive | use ast_interpreter::ASTInterpreter;
use syntax_analyzer::ast_node::*;
use std::env;
use std::fs::File;
use std::io::{stdin, stdout, BufRead, BufReader, BufWriter, Write};
fn main() {
let mut str_in = String::new();
let mut reader: Box<dyn BufRead> = match env::args().nth(1) {
None => Box::new(BufRea... | true |
080219e0348a78a32caf5203d8d171b528c22659 | Rust | mdnrops/fast_git | /src/main.rs | UTF-8 | 1,178 | 2.71875 | 3 | [] | no_license | use clap::{Arg, App};
use error_chain::error_chain;
#[allow(unused_imports)]
#[allow(unused_variables)]
use std::process::{Command, Stdio};
mod run_cmd;
mod remove_git;
error_chain! {
foreign_links {
Io(std::io::Error);
Utf8(std::string::FromUtf8Error);
}
}
fn main() -> Result<()> {
let ma... | true |
d20220607825b1f2e07ce7f7767b0ce7c70e690a | Rust | albertgoncalves/ruskie | /db/src/schedule.rs | UTF-8 | 5,006 | 2.53125 | 3 | [] | no_license | mod blobs;
mod scrape;
mod sql;
mod void;
use crate::blobs::read_json;
use crate::scrape::{filename, get_to_file};
use crate::sql::connect;
use crate::void::{OptionExt, ResultExt};
use rayon::prelude::*;
use rusqlite::{Connection, ToSql, NO_PARAMS};
use serde::Deserialize;
use serde_json::Number;
use std::env::var;
us... | true |
4471e5259693f61b81e218f405e05d8e80939857 | Rust | video-audio/va-ts | /src/descriptor/desc_0x0a.rs | UTF-8 | 2,337 | 2.71875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fmt;
use crate::error::{Error, Kind as ErrorKind};
use crate::iso_639::ISO639;
use crate::result::Result;
use crate::section::{Cursor, Szer, TryNewer};
/// ISO/IEC 13818-1
///
/// ISO 639 language descriptor
#[derive(Clone)]
pub struct Desc0x0A<'buf> {
buf: &'buf [u8],
}
impl<'buf> Desc0x0A<'buf> {
... | true |
262d15f057549a81ec2f1a69e01d8fd3a5f07162 | Rust | Enforcer/rusty-matching-engine | /src/orders.rs | UTF-8 | 3,701 | 3.4375 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
use std::str::FromStr;
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum Side {
Bid,
Ask,
}
#[derive(Copy, Clone, Debug)]
pub struct Trade {
pub executing_order_id: i32,
pub matched_order_id: i32,
pub timestamp: u128,
pub amount: i32,
pub price: i32,
}
#[derive(Cop... | true |
1342035cdf1a21b85a960ef34f06a20e9b67f2c8 | Rust | yeliknewo/rs-polyclops | /src/being_args.rs | UTF-8 | 1,014 | 3 | 3 | [] | no_license | use math::{Vec3};
#[derive(Clone)]
pub struct BeingArgs {
pub pos: Option<Box<Vec3>>,
pub vel: Option<Box<Vec3>>,
pub acc: Option<Box<Vec3>>,
pub sca: Option<Box<Vec3>>,
pub rot: Option<Box<Vec3>>,
}
impl BeingArgs {
pub fn new() -> BeingArgs {
BeingArgs {
pos: None,
... | true |
1e2000bce64de0770ba5d8b10769bfbfa48a88d4 | Rust | aep000/ReactiveDB | /reactive_db/src/utilities/max_size_hash_map.rs | UTF-8 | 1,476 | 3.4375 | 3 | [] | no_license |
use std::collections::VecDeque;
use std::collections::HashMap;
pub struct MaxSizeHashMap<K, V> {
map: HashMap<K, (V, usize)>,
inserts: VecDeque<K>,
size: usize
}
#[allow(dead_code)]
impl<K: Eq + std::hash::Hash + Clone, V> MaxSizeHashMap<K, V> {
pub fn new(max_size: usize) -> MaxSizeHashMap<K, V>{
... | true |
33f175f2ea3a9a2880375489081661aeed0a95d0 | Rust | GGist/omni-rs | /src/ssdp/header/nts.rs | UTF-8 | 3,474 | 3.078125 | 3 | [] | no_license | use std::fmt::{Formatter, Result};
use hyper::header::{HeaderFormat, Header};
const NTS_HEADER_NAME: &'static str = "NTS";
const ALIVE_HEADER: &'static str = "ssdp:alive";
const UPDATE_HEADER: &'static str = "ssdp:update";
const BYEBYE_HEADER: &'static str = "ssdp:byebye";
/// Represents an NTS header which specif... | true |
e369d8bafd377dc20d9c65361a3d4d685f4e56b8 | Rust | danmedani/prime_sieve | /src/lib.rs | UTF-8 | 4,845 | 2.984375 | 3 | [
"MIT"
] | permissive | extern crate num_cpus;
extern crate primal_sieve;
#[macro_use]
mod macros;
pub mod filter;
pub mod collection;
mod concurrent_help;
#[cfg(test)]
mod tests {
use filter::{
prime_filter,
// prime_filter_section,
old_prime_filter,
prime_filter_section_sequentially,
};
extern ... | true |
29d35280356203481722700b274d9ac28be61977 | Rust | MaxMEllon/wasm-tutorial | /src/lib.rs | UTF-8 | 174 | 2.546875 | 3 | [] | no_license | extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn fib(n: i32) -> i32 {
match n {
0 => 0,
1 => 1,
_ => fib(n-2) + fib(n-1),
}
}
| true |
8a7dcb0f0be83498a84823ec8e178c21aaa545e3 | Rust | amar-laksh/focusTV_rust | /src/target/debug/build/opencv-3c40c99bd52f01a8/out/VectorOfVectorOfPoint2f.type.rs | UTF-8 | 1,144 | 2.515625 | 3 | [] | no_license |
extern "C" {
fn cv_new_VectorOfVectorOfPoint2f() -> *mut c_void;
fn cv_delete_VectorOfVectorOfPoint2f(ptr:*mut c_void) -> ();
fn cv_push_VectorOfVectorOfPoint2f(ptr:*mut c_void, ptr2: *const c_void) -> ();
fn cv_VectorOfVectorOfPoint2f_len(ptr:*mut c_void) -> i32;
fn cv_VectorOfVectorOfPoint2f_data... | true |
d9d5324e53c8e2703289f623940c1eb01ed8411b | Rust | jiguanglizipao/sgx-mnist | /rust-autograd/src/ops/const_gen_ops.rs | UTF-8 | 3,683 | 2.859375 | 3 | [
"MIT"
] | permissive | use ndarray;
use ndarray_ext;
use ndarray_ext::NdArray;
use op;
use tensor::Tensor;
use Float;
pub struct Zeros;
pub struct Ones;
pub struct Range;
pub struct ConvertToTensor<T: Float> {
pub arr: NdArray<T>,
}
pub struct Scalar<T: Float> {
pub val: T,
}
impl<T: Float> op::Op<T> for Scalar<T> {
fn name(&se... | true |
6cfc9c5a70a25dc08ca6df374b5b16543595e8b9 | Rust | oooseun/Project | /Rust/rosetta/binary_strings/src/main.rs | UTF-8 | 2,907 | 4.21875 | 4 | [] | no_license | use std::str;
fn main() {
//Create new string pub
let str = String::from("Hello world!");
println!("{}", str);
assert!(str == "Hello world!", "Incorrect string text");
//Create and assign value to string
let mut assigned_str = String::new();
assert!(assigned_str == "", "Incorrect string cre... | true |
03c65d884ee9720e51bff2eb49e7d4160aca1580 | Rust | hasenbanck/asche | /examples/raytracing/uploader.rs | UTF-8 | 3,188 | 2.5625 | 3 | [
"MIT",
"Apache-2.0",
"Zlib"
] | permissive | use erupt::vk;
use asche::{CommandBufferSemaphore, CommonCommands};
use crate::{Lifetime, Result};
pub struct Uploader {
staging_buffer: asche::Buffer<Lifetime>,
timeline: asche::TimelineSemaphore,
timeline_value: u64,
transfer_pool: asche::TransferCommandPool,
transfer_queue: asche::TransferQueu... | true |
b85704c6f029c3f64f2ea3856816235a329b9dc2 | Rust | piotr-cla/ockam | /implementations/rust/ockam/ockam_credential/src/credential_attribute.rs | UTF-8 | 2,753 | 3.046875 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use crate::CredentialAttributeType;
use ockam_core::lib::*;
use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
mod fields {
pub use bbs::prelude::*;
pub use ff::{Field, PrimeField};
pub use pairing_plus::bls12_381::{Fr, FrRepr};
}
/// The attribute data that is signed by
#[derive(Clone, Debug, D... | true |
9549601715229a8c62c76df4711086dceeef670a | Rust | codius-deprecated/codius-sandbox-core | /src/executors.rs | UTF-8 | 1,303 | 2.828125 | 3 | [] | no_license | #[allow(unstable)]
extern crate libc;
use std::ffi::CString;
use std::ptr;
use std::os;
pub trait Executor {
fn exec(&mut self) -> !;
}
pub struct Execv<'a> {
argv: &'a [&'a str]
}
impl<'a> Execv<'a> {
pub fn new(argv: &'a [&'a str]) -> Self {
Execv {
argv: argv
}
}
}
imp... | true |
7b6f453670a77c87635743f3271db79ce26b6827 | Rust | virtuoushub/Theseus | /kernel/framebuffer/src/lib.rs | UTF-8 | 7,271 | 3.0625 | 3 | [
"MIT"
] | permissive | //! This crate defines a `Framebuffer` structure, which is effectively a region of memory
//! that is interpreted as a 2-D array of pixels.
#![no_std]
extern crate alloc;
extern crate memory;
extern crate multicore_bringup;
extern crate owning_ref;
extern crate shapes;
extern crate color;
extern crate zerocopy;
pub ... | true |
c1547cb510c24506538d8f7c96809a6044ba45ad | Rust | thibran/non_empty | /src/non_empty_into.rs | UTF-8 | 5,859 | 2.703125 | 3 | [
"BSD-2-Clause"
] | permissive | use super::NonEmpty;
impl Into<String> for NonEmpty<String> {
#[inline]
fn into(self) -> String {
self.into_inner()
}
}
impl<'a> Into<&'a String> for NonEmpty<&'a String> {
#[inline]
fn into(self) -> &'a String {
self.into_inner()
}
}
impl<'a> Into<&'a str> for NonEmpty<&'a st... | true |
619f0c1b313bd3430e6f37237777e536d0893089 | Rust | jcomito/rust-algorithms | /tests/codeforces343d.rs | UTF-8 | 2,374 | 2.96875 | 3 | [
"MIT"
] | permissive | //! Solves [Water Tree](http://codeforces.com/contest/343/problem/D).
//! To make a self-contained file for contest submission, dump each desired
//! module's contents directly here instead of the use statements.
//! Also, replace io::Cursor with io::stdin as shown in scanner.rs.
extern crate contest_algorithms;
use co... | true |
d17eaeabf3e45896493a8f1e59dbded6063d6748 | Rust | declanvk/streamers | /src/radix_tree/entry.rs | UTF-8 | 1,011 | 3.203125 | 3 | [] | no_license | use std::mem;
use std::fmt;
use super::key::TreeKey;
#[derive(Clone, PartialEq, Eq)]
pub struct KeyValue<K: TreeKey, V> {
key: K,
value: V,
}
impl<K: TreeKey, V> KeyValue<K, V> {
pub fn new(key: K, value: V) -> Self {
KeyValue { key, value }
}
pub fn key(&self) -> &K {
&self.key
... | true |
b6c11dba2864cbdb8d4035af580a74729bd639ea | Rust | richwandell/rustjs | /src/parser/symbols.rs | UTF-8 | 5,988 | 2.875 | 3 | [] | no_license | use crate::lexer::js_token::Tok;
use std::collections::HashMap;
use std::fmt::{Display, Formatter, Result};
#[allow(dead_code)]
#[derive(Clone, Debug, PartialEq)]
pub(crate) enum Expression {
Object {
mutable: bool,
properties: HashMap<String, JSItem>
},
Binop {
a: Box<Expression>,
... | true |
bf6e0c408600fd65dd10799ff3698082ec122ab7 | Rust | jonhoo/async-lease | /tests/lease.rs | UTF-8 | 3,542 | 3.234375 | 3 | [] | no_license | use async_lease::Lease;
use tokio_test::*;
#[test]
fn default() {
task::mock(|cx| {
let mut l: Lease<bool> = Lease::default();
assert_ready!(l.poll_acquire(cx));
assert_eq!(&*l, &false);
assert_eq!(l.take(), false);
l.restore(true);
});
}
#[test]
fn straight_execution()... | true |
2902a030998fbbe769ccb66bde5035bf384a8674 | Rust | gilescope/MoonZoon | /examples/todomvc/frontend/src/router.rs | UTF-8 | 563 | 2.625 | 3 | [
"MIT"
] | permissive | use crate::app;
use zoon::*;
// ------ router -------
#[static_ref]
pub fn router() -> &'static Router<Route> {
Router::new(|route| match route {
Some(Route::Active) => app::select_filter(app::Filter::Active),
Some(Route::Completed) => app::select_filter(app::Filter::Completed),
Some(Route... | true |
57602a5c6cfa2ebff707811ededa679d902f1128 | Rust | foo-jin/advent-of-code | /2016/day01/src/main.rs | UTF-8 | 3,505 | 3.328125 | 3 | [
"MIT"
] | permissive | use std::{
collections::HashSet,
io::{self, Read, Write},
};
macro_rules! err {
($($tt:tt)*) => { Err(Box::<dyn std::error::Error>::from(format!($($tt)*))) }
}
mod aoc {
pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
}
type Pos = (i32, i32);
#[derive(Copy, Clone)]
enum Dire... | true |
7a02f2f95129309854ad77d45ebe29d89a8c90fa | Rust | tarkalabs/faster_jpath | /src/serde_anyobject/error.rs | UTF-8 | 4,866 | 3.15625 | 3 | [
"MIT"
] | permissive | use std::fmt;
use rutie::{self, Exception, Object};
use serde;
pub enum ErrorKind {
Message(String),
RutieException(rutie::AnyException),
NotImplemented(&'static str),
}
use self::ErrorKind::*;
impl fmt::Display for ErrorKind {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *sel... | true |
477af81342c4011ab60a8beb6d9408a4a05bb0f6 | Rust | curvelogic/eucalypt | /src/syntax/string_lexer.rs | UTF-8 | 9,454 | 3.515625 | 4 | [
"MIT"
] | permissive | //! Lexer for parsing string patterns
use crate::syntax::error::SyntaxError;
use codespan::{ByteIndex, ByteOffset};
use std::iter::Peekable;
use std::str::Chars;
/// Tokens in the eucalypt syntax
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Token<'text> {
EscapedOpenBrace,
EscapedCloseBrace,
OpenBrace,
... | true |
f2a60b62c8f54e36effe8c90be10f04b2d249d09 | Rust | Hakukano/FLP-SAML2 | /src/idp.rs | UTF-8 | 856 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use openssl::x509::X509;
use std::{fs::read, path::Path};
use url::Url;
use crate::error::Result;
pub mod authn_response;
pub mod logout_response;
#[derive(Clone, Debug)]
pub struct IdentityProvider {
pub login: Url,
pub logout: Url,
pub certificates: Vec<X509>,
}
impl IdentityProvider {
pub fn new(... | true |
97489e29fe4c5fd2e55da8b20f33f2e1a079a115 | Rust | NeoGalaxy/RagParse | /src/opt.rs | UTF-8 | 3,250 | 2.96875 | 3 | [] | no_license | use std::any::type_name;
use std::str::FromStr;
use crate::parser::ArgParseResult;
use ArgParseResult::*;
pub type OptParser<'a,T> = &'a dyn Fn(&str) -> ArgParseResult<T>;
pub struct Opt<'a> {
names: &'a [&'a str],
descr: &'a str,
invoker: &'a dyn Fn() -> ArgParseResult<()>,
invoked: bool,
}
pub struct ValOpt<'... | true |
2baf9dfae3d751ed5258457aa365f4dcdbaebaab | Rust | Dragoteryx/brainfuck | /src/memory.rs | UTF-8 | 4,152 | 2.984375 | 3 | [] | no_license | use std::io::{stdin, stdout, Write};
use crate::{Args, Error};
use colored::Colorize;
use std::fmt::Debug;
// memory
mod memory8; pub use memory8::*;
mod memory16; pub use memory16::*;
mod memory32; pub use memory32::*;
pub trait Memory<T>: Debug {
fn args(&self) -> &Args;
fn size(&self) -> u32;
fn null() -> T... | true |
6e801444998d0a41034b69b1c615ec8712fc5f0b | Rust | phil-opp/drivers | /vesad/src/scheme.rs | UTF-8 | 9,632 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::collections::BTreeMap;
use std::{mem, slice, str};
use orbclient::{Event, EventOption};
use syscall::{Result, Error, EACCES, EBADF, EINVAL, ENOENT, O_NONBLOCK, Map, SchemeMut};
use display::Display;
use screen::{Screen, GraphicScreen, TextScreen};
#[derive(Clone)]
pub enum HandleKind {
Input,
Screen... | true |
9165dff54d0d76987b3786b901c55adabbb3b052 | Rust | mbartelsman-dev/dynasties | /src/date.rs | UTF-8 | 902 | 3.625 | 4 | [] | no_license | #[derive(Eq, PartialEq, Debug)]
pub struct Date {
year: i32,
season: u32,
}
impl Date {
fn new() -> Date {
Date {
year: 0,
season: 0,
}
}
fn set_date(&mut self, year: i32, season: u32) {
}
fn incr_date(&mut self) -> &mut Date {
let date = D... | true |
033ee7fc57d2bae11d2a0b94279e58d0f312b26f | Rust | gugahoa/ww-subscribe | /src/lib.rs | UTF-8 | 2,685 | 2.546875 | 3 | [] | no_license | #[macro_use]
extern crate diesel;
pub mod models;
pub mod schema;
use diesel::pg::PgConnection;
use diesel::prelude::*;
use dotenv::dotenv;
use std::env;
use telebot::functions::*;
use models::*;
use tokio_core::reactor::Core;
use std::thread;
use futures::sync::mpsc;
use telebot::bot;
use tokio::prelude::*;
pub fn... | true |
54bd2d0c0046ae0be8ce3a5addca946589cdf476 | Rust | pnquest/AoC2018 | /rust/day_6/src/main.rs | UTF-8 | 3,100 | 3.09375 | 3 | [] | no_license | extern crate common;
extern crate stopwatch;
#[macro_use]
extern crate itertools;
use stopwatch::Stopwatch;
use std::collections::HashMap;
fn main() {
let mut sw = Stopwatch::start_new();
let lines:Vec<String> = common::file_to_vector("input.txt")
.expect("There was an error");
let points: Vec<(u... | true |
b971fb9ba977ae8f6ae6ac85fc354e25633c3542 | Rust | simensgreen/bevy | /crates/bevy_render/src/render_graph/node.rs | UTF-8 | 5,505 | 2.75 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use super::{Edge, RenderGraphError, ResourceSlotInfo, ResourceSlots};
use crate::renderer::RenderContext;
use bevy_ecs::{system::BoxedSystem, world::World};
use bevy_utils::Uuid;
use downcast_rs::{impl_downcast, Downcast};
use std::{borrow::Cow, fmt::Debug};
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd,... | true |
9861d31ef218e8aee56da5aedc540ff32c717238 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/futures-util/src/stream/select_all.rs | UTF-8 | 7,485 | 2.890625 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | /
/
!
An
unbounded
set
of
streams
use
core
:
:
fmt
:
:
{
self
Debug
}
;
use
core
:
:
iter
:
:
FromIterator
;
use
core
:
:
pin
:
:
Pin
;
use
futures_core
:
:
ready
;
use
futures_core
:
:
stream
:
:
{
FusedStream
Stream
}
;
use
futures_core
:
:
task
:
:
{
Context
Poll
}
;
use
super
:
:
assert_stream
;
use
crate
:
:
strea... | true |
6491ba9689a24aea58b6d18325ca390660dd5741 | Rust | thekidder/hyper | /src/header/shared/entity.rs | UTF-8 | 3,845 | 3.8125 | 4 | [
"MIT"
] | permissive | use std::str::FromStr;
use std::fmt::{self, Display};
/// An entity tag
///
/// An Etag consists of a string enclosed by two literal double quotes.
/// Preceding the first double quote is an optional weakness indicator,
/// which always looks like this: W/
/// See also: https://tools.ietf.org/html/rfc7232#section-2.3
... | true |
36fe18561ee745dd873826a38157effddf071e5a | Rust | cisen/preemptive | /Chapter4-Systick/src/usart.rs | UTF-8 | 1,570 | 2.734375 | 3 | [] | no_license | use core::fmt::{Error, Write};
use stm32f103xx;
/// Initialize usart2
pub fn usart_init(
rcc: &mut stm32f103xx::RCC,
gpioa: &mut stm32f103xx::GPIOA,
usart2: &mut stm32f103xx::USART2,
) {
// enable usart and gpioa clocks
rcc.apb1enr.write(|w| w.usart2en().enabled());
rcc.apb2enr.write(|w| w.iopa... | true |
0fcd3041421fc7fed56cd5d4e923da59b77276cf | Rust | Azure/azure-sdk-for-rust | /sdk/iot_hub/src/service/operations/create_or_update_configuration.rs | UTF-8 | 4,306 | 2.75 | 3 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"LGPL-2.1-or-later"
] | permissive | use azure_core::headers;
use azure_core::Method;
use serde::Serialize;
use std::collections::HashMap;
use crate::service::resources::{ConfigurationContent, ConfigurationMetrics};
use crate::service::responses::ConfigurationResponse;
use crate::service::{ServiceClient, API_VERSION};
azure_core::operation! {
/// Th... | true |
e752dd97a349d046561c711f3b17d75710ddd237 | Rust | mfred488/ferris-is-you | /ferris-base/tests/you.rs | UTF-8 | 2,041 | 2.703125 | 3 | [
"MIT"
] | permissive | use ferris_base;
mod utils;
#[test]
fn move_up() {
let start = vec![
"............",
"..🦀........",
"............",
"Fe==U ......",
];
let inputs = vec![ferris_base::core::direction::Direction::UP];
let end = vec![
"..🦀........",
"............",
... | true |
a0c7d52ef452128e541bd5e948c8b5c60d88d392 | Rust | jrz1977/pgdbfs | /src/fcache/mod.rs | UTF-8 | 10,023 | 2.84375 | 3 | [
"Apache-2.0"
] | permissive | use db::PgDbMgr;
use std::cmp;
use std::collections::HashMap;
use std::fmt;
use std::iter::FromIterator;
static TAG: &str = "FCache";
#[derive(Debug)]
pub struct FSegment {
pub file_id: i64,
pub segment_no: i64,
pub data: Vec<u8>,
}
impl fmt::Display for FSegment {
fn fmt(&self, f: &mut fmt::Formatte... | true |
7e147e276ebac1e11fc40fda84660b88792c6d33 | Rust | tshepang/gd32vf103-pac | /src/exti/pd.rs | UTF-8 | 30,148 | 2.90625 | 3 | [
"ISC"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::PD {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W)... | true |
d2dc3c6c92ef913fa4ac5d228c9577a7c60718e8 | Rust | liuchengxu/vim-clap | /crates/matcher/src/matchers/bonus_matcher/bonus/filename.rs | UTF-8 | 843 | 3.109375 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | use types::Score;
/// Returns a bonus score if the match indices of an item include the file name part.
///
/// Formula:
/// bonus_score = base_score * len(matched_elements_in_file_name) / len(file_name)
pub(crate) fn calc_bonus_file_name(file_path: &str, score: Score, indices: &[usize]) -> Score {
match pattern... | true |
113314fe7950478dfc9b96b8e88d9af940068fd8 | Rust | singulared/swayipc-rs | /src/event.rs | UTF-8 | 1,374 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::reply::Event;
use crate::{bail, Error};
use serde::Serialize;
use serde_json::from_slice;
use std::convert::TryFrom;
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum EventType {
Workspace,
Mode,
Window,
#[serde(rename = "barconfig_upd... | true |
53f77804258ad83495e7ef783423802f501ad11f | Rust | prz23/zinc | /zinc-types/src/instructions/data_stack/load_by_index.rs | UTF-8 | 1,463 | 3.53125 | 4 | [
"Apache-2.0"
] | permissive | //!
//! The `load from stack by index` instruction.
//!
use std::fmt;
use serde::Deserialize;
use serde::Serialize;
use crate::instructions::Instruction;
///
/// The `load from stack by index` instruction.
///
/// Takes `index` from evaluation stack, loads several values from the data stack
/// at `address + index`... | true |
843345a424215d1f1d6aa58331c11933f64131e6 | Rust | alanxoc3/adventofcode | /2020/src/day/_04.rs | UTF-8 | 3,456 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use regex::Regex;
pub fn p1(s: &String) -> String {
let mut valid_count = 0;
let passports = parse_passports(s);
for p in passports {
if has_needed_fields(&p) {
valid_count += 1;
}
}
return valid_count.to_string();
}
pub fn p2(s: &String... | true |
8bf76547df07a419236302ec1bef94b3e0f94cfb | Rust | jo12bar/weekend-tracer-rs | /src/hittable/moving_sphere.rs | UTF-8 | 4,113 | 3.15625 | 3 | [
"Unlicense"
] | permissive | //! Structs and methods for working with **moving** `Hittable` spheres.
use crate::{
aabb::AABB,
hittable::{get_sphere_uv, HitRecord, Hittable},
material::Material,
ray::Ray,
vec3,
vec3::Vec3,
};
use std::sync::Arc;
/// A linearly-moving sphere. Will move from `center0` at `time0` to `center1`... | true |
e28483c5fb63bc9d24a3ab318754befc67db36cc | Rust | rumbogs/rust-raytracer-one-weekend | /src/modifiers/rotate.rs | UTF-8 | 3,398 | 2.796875 | 3 | [] | no_license | use std::f32::consts::PI;
use super::super::aabb::Aabb;
use super::super::hittable::{HitRecord, Hittable};
use super::super::material::Material;
use super::super::ray::Ray;
use super::super::vector3::Vector3;
pub struct RotateY {
pub object: Box<Hittable>,
pub sin_theta: f32,
pub cos_theta: f32,
pub a... | true |
8781600e3b85617848a3b59ec2621d4fd8989b91 | Rust | mrobakowski/alcubierre | /alcubierre/src/lib.rs | UTF-8 | 1,809 | 2.890625 | 3 | [] | no_license | pub use alcubierre_derive::*;
use inventory::iter;
pub use warp;
pub use inventory;
use warp::{Filter, Reply};
use warp::filters::BoxedFilter;
use std::net::SocketAddr;
use warp::reply::BoxedReply;
#[derive(Debug)]
pub struct Route {
pub name: &'static str,
pub mod_path: &'static str,
pub filter: BoxedFilt... | true |
4fd96b4ed70d832608273e44b15e819a5329b9a3 | Rust | sathishvinayk/rust_360 | /types_in_rust/tuples.rs | UTF-8 | 596 | 3.53125 | 4 | [] | no_license | use std::collections::HashMap;
fn reads() {
let mut readers = HashMap::new();
readers.insert("key1", 2);
readers.insert("key2", 4);
for (key, value, ) in readers {
println!("{:?} {:?}", key, value);
}
}
fn main() {
let x: (i8, i8) = (1,2);
let y: (&str, &str, &str)... | true |
e437dde90a942af4d58a5c5a2c330440e759c141 | Rust | andsanmar/saturate | /src/solver/cdcl.rs | UTF-8 | 7,489 | 3.078125 | 3 | [] | no_license | use crate::structures::*;
use std::sync::mpsc;
// Vector of asignations
// 1st component: index the clauses it forms part of (1 if true, 2 false)
// 2nd component: value assigned
type CdclVec = Vec<((Vec<usize>, Vec<usize>), Option<bool>)>;
// Vector of pairs: clause and status (solved)
type CdclCNF<'a> = Vec<(&'a Cl... | true |
893b39c5793c2b8c956779effff5f4b6dc175ab1 | Rust | preston-evans98/bitcoin-warp | /networking/src/constants.rs | UTF-8 | 1,124 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::time::Duration;
/// The default round-trip-time estimate for new peers
///
/// The higher this value is, the more heavily loaded new peers will appear to be.
/// A high value causes the load balancer to prefer routing requests to more established peers
/// until such time as it can establish a reliable estima... | true |
14fe72a2ff1ce8817a37f5baf66b8df6981af86e | Rust | paytonrules/Capture | /godot-capture/src/nodes/oauth/provider.rs | UTF-8 | 5,148 | 3.109375 | 3 | [
"MIT"
] | permissive | use super::webserver::WebServer;
use super::{TokenError, TokenReceiver};
pub struct OAuthProvider;
impl OAuthProvider {
pub fn new() -> Self {
OAuthProvider
}
pub fn provide<T, U>(&self, server: T, token_receiver: U) -> Result<String, TokenError>
where
T: WebServer,
U: TokenRe... | true |
bcbc964d3b9b0142d7976825cd0c0dd11b4f2ac6 | Rust | DavidBM/acteur-rs | /src/services/director.rs | UTF-8 | 6,189 | 2.59375 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use crate::actors::envelope::Letter;
use crate::services::broker::MessageBroker;
use crate::services::envelope::ServiceLetterWithResponders;
use crate::services::handle::Listen;
use crate::services::handle::Serve;
use crate::services::manager::{Manager, ServiceManager, ServiceManagerCommand};
use crate::system_director... | true |
21c19ba1b7d740320145b39998250c58afe918b3 | Rust | KenSuenobu/rust-pushrod | /src/text_widget.rs | UTF-8 | 5,870 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | // Text Widget
// Pushrod
//
// 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 in writing,... | true |
cf19f2275735eb1f4c73115323ecec386ad0ed01 | Rust | aclysma/skulpin | /skulpin-app-winit/src/app.rs | UTF-8 | 10,413 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"OFL-1.1",
"Zlib"
] | permissive | //! Contains the main types a user needs to interact with to configure and run a skulpin app
use crate::skia_safe;
use crate::winit;
use super::app_control::AppControl;
use super::input_state::InputState;
use super::time_state::TimeState;
use super::util::PeriodicEvent;
use skulpin_renderer::LogicalSize;
use skulpin... | true |
ac2f191461ff32e09c8251330eaa09c3ee661c1d | Rust | graydon/rust-nbe-for-mltt | /crates/mltt-elaborate/src/lib.rs | UTF-8 | 33,984 | 2.625 | 3 | [
"MIT"
] | permissive | //! Elaboration of the MLTT language's concrete syntax into its core syntax.
//!
//! Performs the following:
//!
//! - name resolution
//! - desugaring
//! - pattern compilation (TODO)
//! - bidirectional type checking
//! - elaboration of holes (TODO)
#![warn(rust_2018_idioms)]
use language_reporting::{Diagnostic, L... | true |
c5ee9ed45ef05c1ad735eba7cbe3e7126a985683 | Rust | marius851000/fs3ds | /src/partition.rs | UTF-8 | 6,721 | 3 | 3 | [] | no_license | use std::io;
use std::io::SeekFrom;
use std::io::{Read, Seek, Write};
use std::sync::{Arc, Mutex};
fn partition_read<T: Read + Seek>(
buf: &mut [u8],
file: &mut T,
start: usize,
end: usize,
mut pointer: usize,
) -> (usize, io::Result<usize>) {
let end_byte_absolute = buf.len() + pointer as usiz... | true |
b1187eaf769df79170f946150d1d99c815cff6b0 | Rust | softprops/aws-embedded-metrics | /src/env.rs | UTF-8 | 5,609 | 2.546875 | 3 | [
"MIT"
] | permissive | use crate::{config::Config, log::MetricContext};
use serde::Deserialize;
use std::{
borrow::Cow,
env::var,
io::{BufRead, BufReader, Write},
net::TcpStream,
time::Duration,
};
pub(crate) trait EnvironmentProvider {
fn get(&mut self) -> Box<dyn Env>;
}
pub(crate) struct Detector;
impl Environme... | true |
4721ff6b4e66a73559016a880d8ea0f02798460b | Rust | ChenPufeng/Rust_learning | /thread/src/main.rs | UTF-8 | 863 | 3.359375 | 3 | [] | no_license | use std::thread;
use std::sync::mpsc;
use std::sync::{Mutex, Arc};
fn main() {
// thread
let mut c = vec![];
for i in 0..10 {
c.push(thread::spawn(move || {
println!("thread number {}", i);
}));
}
for j in c {
j.join();
}
// Channel
let (tx, rx) =... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.