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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3c961925d63e838cd42814079e6bc20699a53e44 | Rust | rust-git/rsgit | /core/src/object/check_tag.rs | UTF-8 | 7,011 | 2.890625 | 3 | [
"Apache-2.0"
] | permissive | use super::{parse_utils, ContentSource, ContentSourceResult};
pub(crate) fn tag_is_valid(s: &dyn ContentSource) -> ContentSourceResult<bool> {
let mut r = s.open()?;
if let Some(line) = parse_utils::read_line(&mut r)? {
if let Some(object_id) = parse_utils::header(&line.as_slice(), b"object") {
... | true |
1c43abdb1139da0ff842a023b05d4285efe9995d | Rust | Zoomulator/rust-sorted | /src/iter_intersection.rs | UTF-8 | 2,067 | 3.375 | 3 | [
"MIT"
] | permissive | use super::{SortOrder, SortedIterator};
use std::cmp::Ordering;
/// Adaptor iterator which outputs the intersection of two sorted iterators in
/// linear time. Will ouput the repeated items as many times as they are present in both iterators.
#[derive(Debug)]
pub struct Intersection<I, J>
where
I: SortedIterator,
... | true |
e4f169972c77a282db0d1791a2f9b7f09d30ae65 | Rust | zdimension/hm-infer-rs | /src/infer.rs | UTF-8 | 11,937 | 2.578125 | 3 | [
"MIT"
] | permissive | use crate::{BaseType, BaseType::*, Environment, SExpr, SExpr::*};
use std::cell::Cell;
use std::collections::HashMap;
impl <'a> Environment<'a>
{
pub fn analyze(
&self,
expr: &SExpr,
syms: &mut HashMap<String, &'a BaseType<'a>>,
) -> Result<&'a BaseType<'a>, String> {
fn aux<'b>... | true |
77ad7ffc35dcd62f02fa01bfebef0b02b7dc5d97 | Rust | Panchob/Advent-of-code-2020 | /day07/src/main.rs | UTF-8 | 2,707 | 3.265625 | 3 | [] | no_license |
use std::collections::HashMap;
fn seek_bag(rules:&HashMap<String, Vec<String>>, bag:&String) -> bool {
let mut found = false;
if !rules.contains_key(bag) || rules[bag][0] == "no other"{
found = false;
} else {
for b in &rules[bag] {
if b.contains("shiny gold"){
... | true |
9f17bb3dfe3745ac655768fe3d60be4893ef5005 | Rust | spirali/pas | /src/highlevel/hiformula.rs | UTF-8 | 8,018 | 3.1875 | 3 | [] | no_license | use crate::common::Name;
use crate::solver::{LoFormula, LoPredicate};
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum Expression {
Variable(Name),
Constant(u64),
Add(Vec<Expression>),
Mul(Box<Expression>, u64),
Mod(Box<Expression>, u64),
}
impl Expression {
pub fn from_name(name: Name) -> Self... | true |
a53ae8453dd6d9fcc6a56de489bd1555449348ff | Rust | hone/buildpacks-slack | /src/main.rs | UTF-8 | 1,761 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use anyhow::anyhow;
use gotham::{
helpers::http::response::create_permanent_redirect,
hyper::{Body, Response},
middleware::state::StateMiddleware,
pipeline,
router::{
builder::{self, DefineSingleRoute, DrawRoutes},
Router,
},
state::{FromState, State},
};
use gotham_derive::S... | true |
4788d58fa94275ee78d737c26a925f9f98a51186 | Rust | DRiKE/uniload | /src/main.rs | UTF-8 | 1,969 | 2.96875 | 3 | [
"Unlicense"
] | permissive | use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::{thread, time};
// delay (in milliseconds between reading /proc/stat)
const DEFAULT_DELAY: u64 = 1000;
// read the first NUM_COLS_IN_STAT columns from /proc/stat
// after the cpuN column
const NUM_COLS_IN_STAT: usize = 7;
fn main() {
let delay: u... | true |
03bd8ce4c25da4bb854c3d25818fb6ba790ffda5 | Rust | abusch/rustracer | /rustracer-core/src/sampler/lowdiscrepancy.rs | UTF-8 | 5,639 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::rng::RNG;
use crate::{Point2f, Point2i, ONE_MINUS_EPSILON};
pub fn van_der_corput(
n_samples_per_pixel_sample: u32,
n_pixel_samples: u32,
samples: &mut [f32],
rng: &mut RNG,
) {
let scramble: u32 = rng.uniform_u32();
let total_samples = n_samples_per_pixel_sample * n_pixel_samples;
... | true |
b84891f32e4e711e887011ec2ce1ad81356e5057 | Rust | foxfriends/dwarf-mine-builder | /src/component/cube_info.rs | UTF-8 | 943 | 2.875 | 3 | [] | no_license | use specs_derive::Component;
use game_engine::prelude::*;
use crate::model::{CubeDescriptor, FloorMap, CollisionMap};
#[derive(Component, Copy, Clone, Debug)]
pub struct CubeInfo(CubeDescriptor);
impl CubeInfo {
pub fn new(descriptor: CubeDescriptor) -> Self {
CubeInfo(descriptor)
}
/// A map of ... | true |
b6595da3c7a054cd819ed13efe1248acb718f3ad | Rust | CoderCharmander/pokemon-engine | /src/dragon.rs | UTF-8 | 2,580 | 3.171875 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::cmp::max;
use std::ops::Add;
use std::ops::Mul;
#[derive(Serialize, Deserialize)]
pub struct DragonData {
pub name: String,
pub base_stats: Stats,
}
impl DragonData {
pub fn new(name: &str, base_stats: Stats) -> Self {
Self {
name: name.to_... | true |
68367c67c8bcc1ef7416ef84cdd8c18f35291f2e | Rust | venkypolls/Rust-language-learnings | /src/tuples.rs | UTF-8 | 120 | 2.875 | 3 | [] | no_license | pub fn run(){
let person:(&str,&str, i32 ) = ("venky","developer",22);
println!("{:?} , {}",person,person.2);
} | true |
ab5a3027b38b0f259eba925ae2bb39cce3242a71 | Rust | pchickey/posish | /src/process/id.rs | UTF-8 | 279 | 2.5625 | 3 | [
"Apache-2.0",
"LLVM-exception",
"MIT"
] | permissive | /// `getuid()`
#[inline]
pub fn getuid() -> u32 {
unsafe { libc::getuid() }
}
/// `getgid()`
#[inline]
pub fn getgid() -> u32 {
unsafe { libc::getgid() }
}
/// `getpid()`
#[inline]
pub fn getpid() -> u32 {
let pid: i32 = unsafe { libc::getpid() };
pid as u32
}
| true |
f9d190536139042563e939daf4b2a3fc80dc239f | Rust | Marwes/statrs | /src/error.rs | UTF-8 | 3,605 | 3.65625 | 4 | [
"MIT"
] | permissive | use std::error::Error;
use std::fmt;
/// Enumeration of possible errors thrown
/// within the `statrs` library
#[derive(Debug)]
pub enum StatsError {
/// Generic bad input parameter error
BadParams,
/// An argument should have been positive and was not
ArgMustBePositive(&'static str),
/// An argume... | true |
668785faeb4b8b65a1bf51b7444bd151c204a801 | Rust | gridbugs/apocalypse-post | /src/behaviour/behaviour.rs | UTF-8 | 13,043 | 2.921875 | 3 | [
"MIT"
] | permissive | use std::result;
#[derive(Debug)]
pub enum Error {
UnknownNodeIndex,
NodeStateMismatch,
UnexpectedNodeType,
StackEmpty,
StackNotEmpty,
Yielding,
NotYielding,
}
pub type Result<T> = result::Result<T, Error>;
pub type NodeIndex = usize;
pub enum LeafResolution<A> {
Return(bool),
Yi... | true |
cb066639dc4b9b60d8a1b0ec8ce0019df24a59ac | Rust | wateryan/project-euler-rust | /src/bin/problem1.rs | UTF-8 | 849 | 4.15625 | 4 | [
"MIT"
] | permissive | /// If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
/// Find the sum of all the multiples of 3 or 5 below 1000.
fn main() {
println!("Finding the sum of all the multiples of 3 or 5 below 1000");
let limit = 1000;
iterative_so... | true |
d3e9a2d95c07394c9708af511069d5ea5864ec59 | Rust | pvandommelen/aoc-2020-rust | /src/day03/part2.rs | UTF-8 | 611 | 2.796875 | 3 | [] | no_license | use std::fs;
use std::time;
mod day03;
fn main() {
let input = fs::read("./src/day03/input.txt").expect("Unable to read input file");
let start = time::Instant::now();
let map = day03::Map{data: input, width: 31};
let slopes = [
(1, 1),
(3, 1),
(5, 1),
(7, 1),
... | true |
d84fe80204ba041f3664c06f4c9690c3c750b0c1 | Rust | GGabi/OjiDB | /src/lib.rs | UTF-8 | 6,573 | 2.890625 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
/* Exports */
mod util;
pub use util::Graph as Graph;
pub use util::TripleStore as TripleStore;
pub use util::OjiQuery as OjiQuery;
pub use util::OjiQueryUnit as OjiQueryUnit;
pub use util::OjiResult as OjiResult;
pub use util::OjiResultUnit as OjiResultUnit;
pub use util::OjiResultCollectio... | true |
190f22e9fd5bbc69947f3510832216db7ec13e3b | Rust | brettinternet/pkgls | /src/app.rs | UTF-8 | 1,665 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::config::Config;
use crate::controller::Controller;
use crate::error::*;
use crate::logger::CliLogger;
#[derive(Debug)]
pub enum Procedure {
List,
Install,
#[allow(dead_code)]
Test,
}
pub struct App<'a> {
pub controller: Controller,
pub config: Config<'a>,
}
impl<'a> App<'a> {
p... | true |
da634a2746b6537efe69a3485b59b242d7c6768e | Rust | Pawel82S/vernam-otp | /src/config.rs | UTF-8 | 1,152 | 2.90625 | 3 | [] | no_license | use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "vernam-otp", about = "Encryption/decryption program using OTP")]
pub struct Config {
/// Import OTP file to database
#[structopt(short = "I", long = "import")]
import_otp: bool,
/// File format is binary ... | true |
d5814618caed7a9c54fad2c418f1ed781181511f | Rust | PicoJr/rustower | /src/validation.rs | UTF-8 | 4,368 | 2.75 | 3 | [] | no_license | use crate::parser::{Input, Output, N};
use thiserror::Error;
#[derive(Error, Debug, Eq, PartialEq)]
pub(crate) enum InvalidOutputError {
#[error("found `{0}` waves but expected `{1}`")]
WaveNumber(N, N),
#[error("wave: `{0}` found `{1}` towers but expected `{2}`")]
WaveTowers(usize, N, N),
#[error... | true |
73dc265be4596c78fc78b16a8a99431bc09d3dea | Rust | DoumanAsh/os-sync | /src/mutex/mod.rs | UTF-8 | 1,127 | 3.515625 | 4 | [
"BSL-1.0"
] | permissive | //! Mutex implementations
mod sem;
pub use sem::Mutex as SemMutex;
///Token passed by [MutexGuard](struct.MutexGuard.html)
pub struct GuardToken {
}
///Describes Mutex interface
pub trait Mutex: Sized {
///Creates new instance
///
///Returns if `Semaphore` is successfully created.
fn new() -> Option<... | true |
1a37be23d8deb158d07eaaac68027d8a98b8d39b | Rust | AndreMouche/algorithms_study | /leetcode/rust/leetcode/src/solutions/nearest_palindromic.rs | UTF-8 | 404 | 2.78125 | 3 | [] | no_license | #[cfg(test)]
mod tests {
// Import the necessary modules
use super::Solution;
// This test writes to a file
#[test]
fn test_missing_two() {
let test_data = vec![
(vec![2,3],vec![1,4]),
];
for (nums,expect) in test_data.iter() {
let got = ... | true |
364e02642c03672eca84cd9ca1df4abf056b23c7 | Rust | Jazzinghen/RuStudy | /rectangle_stuff/src/main.rs | UTF-8 | 383 | 2.75 | 3 | [
"MIT"
] | permissive | mod rect;
fn main() {
let rect_1 = rect::Rectangle::new(30, 50);
let rect_2 = rect::Rectangle::new(10, 40);
let rect_3 = rect::Rectangle::new(60, 45);
println!("Rectangle data: {}", rect_1);
println!("Rectangle area: {}", rect_1.area());
println!("Can 1 hold 2? {}", rect_1.can_hold(&rect_2));... | true |
4073606fe18bd44d6882b6842e965332727eddc1 | Rust | danitrod/semaphores | /src/bin/semaphore.rs | UTF-8 | 408 | 2.921875 | 3 | [] | no_license | use semaphores::Semaphore;
fn main() {
println!("Starting");
let mut val = 0;
let mut sem = Semaphore::new(&mut val);
println!("Semaphore: {}", sem.show());
sem.signal();
sem.signal();
sem.signal();
println!("Semaphore: {}", sem.show());
sem.wait();
println!("Semaphore: {}", se... | true |
47c7d8e206216081b840c0717aada35f1ac24291 | Rust | reiya-hanai/aoj-book-in-rust | /alds1_9_c_priority_queue/src/main_manual.rs | UTF-8 | 4,208 | 3.453125 | 3 | [] | no_license | #![allow(dead_code)]
use std::str::FromStr;
use std::string::ToString;
// ----------------------------------------------------------------------------------------------------
// IO util
// ----------------------------------------------------------------------------------------------------
#[allow(dead_code)]
fn read<T... | true |
bd2c0bf99cc684ddd15c871d25f7c1bcf9743b96 | Rust | arturocs/chip-8 | /src/chip8.rs | UTF-8 | 12,752 | 2.84375 | 3 | [] | no_license | use rand::{thread_rng, Rng};
use std::error::Error;
use std::fs;
pub struct Chip8 {
opcode: (u8, u8, u8, u8),
memory: [u8; 4096],
v: [u8; 16],
i: u16,
pc: u16,
gfx: [[u8; 64]; 32],
delay_timer: u8,
sound_timer: u8,
stack: [u16; 16],
sp: u16,
keys: [u8; 16],
draw_flag: boo... | true |
3f9108b6e2e40e776589a176d78b9072837f6864 | Rust | Hypnagokali/srg-dept-validity | /src/main.rs | UTF-8 | 1,540 | 2.78125 | 3 | [] | no_license | use crate::init_validity::objects::{Dept, Prozedur, Fall};
use std::rc::Rc;
use chrono::{NaiveDateTime, NaiveDate, Duration};
use std::cell::RefCell;
mod init_validity;
fn create_sample_data_srg() -> Vec<Rc<Prozedur>> {
vec![]
}
fn create_sample_data_fab(start_date: &NaiveDateTime, end_date: &NaiveDateTime) -> ... | true |
9fd86aefdcaecbf4534d1e05191318455794d764 | Rust | ThomasBollmeier/umbralux | /src/features/pattern.rs | UTF-8 | 14,241 | 3.078125 | 3 | [
"Apache-2.0"
] | permissive | use std::cell::RefCell;
use std::fmt::Debug;
use std::ops::Deref;
use std::rc::Rc;
use num_traits::ToPrimitive;
use crate::core::{Color, Point};
use crate::matrix::Matrix;
use crate::objects::object3d::Object3D;
use crate::transform::transform;
pub trait Pattern: Debug {
fn color_at(&self, pt: Point) -> Color;
... | true |
603fbebd46b127c0e025e95dd268fa120f067ceb | Rust | rust-bio/rust-bio | /src/stats/bayesian/bayes_factors.rs | UTF-8 | 2,082 | 3.109375 | 3 | [
"MIT"
] | permissive | use crate::stats::LogProb;
pub mod evidence {
/// Scale of evidence as defined by
/// [Kass and Raftery 1995](http://www.andrew.cmu.edu/user/kk3n/simplicity/KassRaftery1995.pdf).
#[derive(
Display,
Debug,
Clone,
Copy,
PartialEq,
Eq,
PartialOrd,
... | true |
7d3ed11b3451728f42a38764f66332ab99b8b749 | Rust | xiongxin/talent-plan | /rust/exercises/meow/bin/03_args.rs | UTF-8 | 2,104 | 3.5 | 4 | [
"MIT"
] | permissive | extern crate clap;
use clap::{App, Arg};
fn main() {
let matches = App::new("MyApp")
// A simple Flg argument example (i.e "-d") using the builder pattern
.arg(Arg::with_name("debug").help("turn on debugging information").short("d"))
// Two arguments, on "Option" argument (i.e. one that... | true |
95d26c777c3515ad54d788ecba4ee5e65827d095 | Rust | behrad-ahmadpour/yum-rust | /src/rust_lang/functional.rs | UTF-8 | 271 | 3.171875 | 3 | [] | no_license | mod test {
#[test]
fn test_imperative() {
let mut sum = 0;
for i in 1..11 {
sum += i;
}
assert_eq!(55, sum);
}
#[test]
fn test_declarative() {
assert_eq!(55, (1..11).fold(0, |a, b| a + b));
}
}
| true |
fac973ed6e9ad2233aba410387a3469b05f5f847 | Rust | kayr7/charting | /backend-new/src/routes.rs | UTF-8 | 9,303 | 2.8125 | 3 | [] | no_license | extern crate chrono;
use crate::models::Measurement;
use crate::models::MeasurementHelper;
use crate::models::MeasurementHelperRaw;
use crate::models::BoolHelperRaw;
use crate::models::FloatHelperRaw;
use crate::models::StringHelperRaw;
use crate::models::MyDatabase;
use crate::schema::measurements::columns::geschle... | true |
98ed0728b7313ab752f0144e399eef376de30223 | Rust | astynax/weathe-rs | /src/types/mod.rs | UTF-8 | 2,538 | 3.890625 | 4 | [] | no_license | //! # Internal datatypes
use std::fmt;
/// Temperature Units
#[derive(Clone)]
pub enum TempUnit {
Celsius,
Fahrenheit,
}
impl fmt::Display for TempUnit {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f,
"{}",
match *self {
TempUnit... | true |
c4a2ef606016787b3220d36279ac08704e5e95e2 | Rust | aaronscode/Chip8 | /src/chip8/decompiler.rs | UTF-8 | 9,373 | 3 | 3 | [] | no_license | use super::constants::RAM_OFFSET;
use std::fs::File;
use std::io::Read;
use std::io::{BufReader, ErrorKind};
pub fn decompile_rom(path: String) -> String {
let file = File::open(path).expect("Cannot Read ROM");
let mut buf = BufReader::new(file);
let mut rom_bytes = [0; (0x1000 - RAM_OFFSET as usize)];
... | true |
804281a44a18a27e8394c20dd0c1eec3d13e116e | Rust | fredrik-jansson-se/rust-advent-of-code-2018 | /src/aoc12.rs | UTF-8 | 6,672 | 2.921875 | 3 | [] | no_license | use std::fs;
use std::ops::{Index, IndexMut};
use nom::branch::alt;
use nom::bytes::complete::tag;
use nom::character::complete::space0;
use nom::character::complete::space1;
use nom::combinator::opt;
use nom::multi::{many1, many_m_n};
use nom::*;
pub fn run() {
let input = fs::read_to_string("day12.txt").unwrap(... | true |
5f103abf7aab5a88be935e634dc7928806edfe19 | Rust | Popog/cgmath-rs | /src/parallel.rs | UTF-8 | 7,180 | 2.78125 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2013 The CGMath Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// 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 ... | true |
9f969643d6f50983130513afd83595263e1f2c12 | Rust | CodeGradox/sensehat-rs | /examples/rotate.rs | UTF-8 | 722 | 2.734375 | 3 | [
"CC-BY-4.0",
"MIT",
"Apache-2.0"
] | permissive | extern crate sensehat;
use sensehat::*;
use std::time::Duration;
use std::thread::sleep;
fn main() {
let mut sense_hat = SenseHat::new().unwrap();
sense_hat.clear(None);
sense_hat.set_rotation(Orientation::Deg270, false);
let color = (255, 0, 0);
for i in 0..8 {
sense_hat... | true |
0eb57ded8c55766908045b9160a41cf648e59f10 | Rust | Critical-Impact/xivtools | /xiv/src/lib.rs | UTF-8 | 2,235 | 2.65625 | 3 | [
"MIT"
] | permissive | pub mod ui;
use log;
use std::fmt;
use anyhow::{anyhow, Error, Result};
use std::ffi::CStr;
use winapi::shared::basetsd::LONG_PTR;
use winapi::shared::minwindef::BOOL;
use winapi::shared::windef::HWND;
use winapi::um::winuser::{EnumWindows, GetWindowTextA};
pub const JOB_CNT: usize = 8;
pub const JOBS: [&str; JOB_CN... | true |
37b3263f0c55aa65fbdfaa39dbd9a466918f24a4 | Rust | rustbunker/wry | /src/application/mod.rs | UTF-8 | 17,964 | 2.96875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | #[cfg(not(target_os = "linux"))]
mod general;
#[cfg(not(target_os = "linux"))]
pub use general::WindowId;
#[cfg(not(target_os = "linux"))]
use general::{InnerApplication, InnerApplicationProxy};
#[cfg(target_os = "linux")]
mod gtkrs;
#[cfg(target_os = "linux")]
pub use gtkrs::WindowId;
#[cfg(target_os = "linux")]
use g... | true |
c532ef77e455ff5c10d97c4eaf19f036e82a4858 | Rust | Siegler-von-Catan/fabseal-micro | /micro/src/settings.rs | UTF-8 | 1,079 | 2.828125 | 3 | [] | no_license | use config::{Config, ConfigError, Environment, File};
use fabseal_micro_common::settings::{HttpSettings, Limits, RedisSettings};
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
#[serde(default)]
pub struct Settings {
pub debug: bool,
pub http: HttpSettings,
pub redis: RedisSettings,
pub l... | true |
81f945305ebf8aed9d2120990085fbc79cfbb9f4 | Rust | FH0/stn | /stn/src/origin/out_tcp.rs | UTF-8 | 2,749 | 2.5625 | 3 | [
"MIT"
] | permissive | use super::*;
use log::*;
use std::sync::Arc;
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
net::TcpStream,
time::timeout,
};
#[async_trait::async_trait]
impl crate::route::OutTcp for super::Out {
async fn tcp_connect(
self: Arc<Self>,
saddr: String,
daddr: String,
cli... | true |
a7654866ce1b68d9ebef3c3a4828b8fd5fbf1f86 | Rust | coder/coder.rs | /src/models/images.rs | UTF-8 | 1,648 | 2.515625 | 3 | [
"MIT"
] | permissive | use super::*;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ImageId(pub String);
id_string!(ImageId);
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct Image {
pub id: ImageId,
pub organization_id: S... | true |
681294bbea19f3285d3fc7b8d061a474e63925e7 | Rust | naca-nyan/atcoder | /abc194/src/bin/d.rs | UTF-8 | 183 | 2.984375 | 3 | [] | no_license | fn harmonic(n: u32) -> f64 {
(1..n).map(|i| 1.0 / i as f64).sum()
}
fn main() {
proconio::input! { n: u32 };
let res = n as f64 * harmonic(n);
println!("{}", res);
}
| true |
63c562acb8b9b96c345422e9a5475d3ef205690a | Rust | EFanZh/LeetCode | /src/problem_0378_kth_smallest_element_in_a_sorted_matrix/bfs_2.rs | UTF-8 | 3,538 | 3.046875 | 3 | [] | no_license | pub struct Solution;
// ------------------------------------------------------ snip ------------------------------------------------------ //
use std::mem;
impl Solution {
fn heap_push<T, K: Ord>(heap: &mut Vec<T>, value: T, mut get_key: impl FnMut(&T) -> K) {
let mut i = heap.len();
let key = ge... | true |
1085bd7dfefbb4aaeb53b434798f49d007f994b0 | Rust | mozilla-iam/dino-park-packs | /src/db/logs.rs | UTF-8 | 1,969 | 2.59375 | 3 | [
"MIT"
] | permissive | use crate::db::model::Group;
use crate::db::schema::*;
use crate::db::types::*;
use chrono::NaiveDateTime;
use log::error;
use serde::Serialize;
use serde_json::json;
use serde_json::Value;
use uuid::Uuid;
#[derive(Identifiable, Associations, Queryable, PartialEq, Eq, Debug, Insertable, AsChangeset)]
#[belongs_to(Grou... | true |
f9b04d344aebf74d29ec155e66fd236161e7206f | Rust | johannesegger/AdventOfCode | /2022/Day02/Rust/src/main.rs | UTF-8 | 1,263 | 3.15625 | 3 | [] | no_license | use std::fs::File;
use std::io;
use std::io::BufRead;
use std::io::BufReader;
fn get_score(line: &str) -> i32 {
match line {
"A X" => 1 + 3,
"A Y" => 2 + 6,
"A Z" => 3 + 0,
"B X" => 1 + 0,
"B Y" => 2 + 3,
"B Z" => 3 + 6,
"C X" => 1 + 6,
"C Y" => 2 + 0... | true |
a1cdeeb1c0da6950a39b38dfe5ef3b6b1363a3d4 | Rust | kittoku/rust-phi | /src/bitwise.rs | UTF-8 | 1,437 | 3.15625 | 3 | [] | no_license | use std::{mem::size_of, usize};
pub const USIZE_BITS: usize = size_of::<usize>() * 8;
pub const USIZE_BASIS: [usize; 64] = [
1 << 0, 1 << 1, 1 << 2, 1 << 3, 1 << 4, 1 << 5, 1 << 6, 1 << 7, 1 << 8, 1 << 9,
1 << 10, 1 << 11, 1 << 12, 1 << 13, 1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19,
1 << 20, 1 ... | true |
4bf267a8ad0f4e727afa070e341de4bd61bb8dfe | Rust | japaric-archived/lines.rs | /src/bin/test_lines.rs | UTF-8 | 391 | 2.640625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate lines;
use std::fs::File;
use std::io::BufReader;
use lines::Lines;
fn main() {
let file = BufReader::new(File::open("index.html").unwrap());
let mut lines = Lines::from(file);
let mut checksum = 0;
while let Some(Ok(line)) = lines.next() {
checksum += line.as_bytes().iter().fol... | true |
6ef02c3533de0cad076d4e2892073762a21b5ac2 | Rust | bombsimon/advent-of-code-2020 | /src/grid.rs | UTF-8 | 3,318 | 3.5625 | 4 | [
"WTFPL"
] | permissive | #[derive(Clone, Copy, Debug)]
pub enum Direction {
North,
South,
East,
West,
Unknown(char),
}
impl From<char> for Direction {
fn from(s: char) -> Self {
match s {
'N' => Direction::North,
'S' => Direction::South,
'E' => Direction::East,
'W... | true |
72438a68aff5f6ddca94a929866c14e256860bc2 | Rust | urandom/advent2018 | /day18/src/main.rs | UTF-8 | 4,707 | 3.265625 | 3 | [] | no_license | use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::io::Result;
type Pos = (usize, usize);
#[derive(PartialEq, Copy, Clone, Debug)]
enum Acre {
Open,
Trees,
Lumber,
}
impl Acre {
fn mutate(self, adjacent: Vec<Acre>) -> Acre {
match self {
Acr... | true |
ad2370c7a9f21b3c879e4849a043504328f13fb4 | Rust | Defman/espresso | /src/lib.rs | UTF-8 | 1,265 | 2.640625 | 3 | [] | no_license | use bitflags::bitflags;
mod bytes;
pub mod raw;
#[derive(Debug, PartialEq)]
pub enum MajorVersion {
JavaSE14,
JavaSE13,
JavaSE12,
JavaSE11,
JavaSE10,
JavaSE9,
JavaSE8,
JavaSE7,
JavaSE6_0,
JavaSE5_0,
JDK1_4,
JDK1_3,
JDK1_2,
JDK1_1,
Other(u16),
}
bitflags! {
... | true |
ce08d659c6bf9a67200074b476f5dab84d2a944e | Rust | basavesh/splitspectre | /old_stuff/split_prototype/src/agent_server.rs | UTF-8 | 4,614 | 2.65625 | 3 | [] | no_license | use std::fs;
use std::thread;
use std::path::Path;
use std::collections::HashMap;
use std::io::{Read, Write, Error};
use std::sync::{Arc, Mutex, RwLock};
use std::os::unix::net::{UnixStream, UnixListener};
use std::net::Shutdown;
use secret_integers::*;
use simple::*;
pub mod simple;
use serde::{Serialize, Deserializ... | true |
b0895642763754240426968cb66c9531edc54448 | Rust | doomsparkles/nnshake | /src/lib.rs | UTF-8 | 34,354 | 2.984375 | 3 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | #![deny(missing_docs)]
//! A simple Elliptic Curve Diffie-Hellman channel-binding handshake
//! protocol based on X25519 and ChaCha20-Poly1305.
//!
//! **nnshake** implements a [channel-binding] handshake protocol for
//! establishing forward-secure sessions between ephemeral clients and
//! servers with a well-known ... | true |
fb671648ce25aa5205ae5565184ca99e7179101a | Rust | rslint/rslint | /crates/rslint_rowan/src/green/node.rs | UTF-8 | 5,624 | 2.78125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::{
hash::{Hash, Hasher},
iter::FusedIterator,
slice,
};
use crate::arc::{Arc, HeaderSlice, HeaderWithLength, ThinArc};
use fxhash::FxHasher32;
use crate::{
green::{GreenElement, GreenElementRef, PackedGreenElement, SyntaxKind},
TextSize,
};
#[repr(align(2))] // NB: this is an at-least ann... | true |
967e81ef005b27273295c2bec4184183279acc37 | Rust | emma-k-alexandra/wmata | /src/requests.rs | UTF-8 | 2,614 | 2.953125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Internal requests structs and traits.
use crate::error::{Error, ErrorResponse};
use async_trait::async_trait;
use reqwest;
use serde::de::DeserializeOwned;
use serde_json;
pub struct Request<'a> {
pub api_key: &'a str,
pub path: &'a str,
pub query: Option<Vec<(&'a str, String)>>,
}
impl<'a> Request<'... | true |
ade5a6e58a3a483b2af89e4ffcc6a41c457d673b | Rust | rune-rs/rune | /crates/rune/src/ast/macro_call.rs | UTF-8 | 3,167 | 3.09375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::ast::prelude::*;
#[test]
fn ast_parse() {
use crate::testing::rt;
rt::<ast::MacroCall>("foo!()");
rt::<ast::MacroCall>("::bar::foo!(question to life)");
}
/// A macro call.
///
/// * `<expr>!(<args>)`.
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned, Opaque)]
#[non_exhaustive]
pub stru... | true |
15b04dffed94c5737a95caf052d26ce207d24c78 | Rust | ivanceras/balisong | /src/voxel/voxstream.rs | UTF-8 | 2,094 | 3.125 | 3 | [
"MIT"
] | permissive | /// voxstream will be used for fetching on demand additional details at a certain voxel location.
/// can also be used to contain material lookup such as color, specular, diffuse, refraction,reflection info.
use voxel::vox::Vox;
use lod::LOD;
pub struct Voxstream<T>{
bitset:Vec<u64>,
content:Vec<T>,
}
impl <... | true |
6528669e58a8b26e93ff4eb831437e72bd610b65 | Rust | gbutler69/rust-exercism | /perfect-numbers/src/lib.rs | UTF-8 | 2,393 | 3.375 | 3 | [] | no_license | #[derive(Debug, PartialEq, Eq)]
pub enum Classification {
Abundant,
Perfect,
Deficient,
}
pub fn classify(num: u64) -> Option<Classification> {
match (num, determine_factors(num).sum::<u64>()) {
(0, _) => None,
(num, aliquot_sum) if aliquot_sum == num => Some(Classification::Perfect),
... | true |
5abf14f1ebd10b6ed0edd7ef49861a21402549c1 | Rust | Zengor/list_to_anki | /src/cards.rs | UTF-8 | 3,750 | 3.484375 | 3 | [] | no_license | use crate::fileio::Term;
use crate::jisho::{self, Japanese};
use std::fmt;
/// Character used to separate each field for a card in the card fileio
///
/// `\t` is being used to allow semi-colons to be used in cards
const SEPARATOR: char = '\t';
/// Represents an Anki flashcard.
/// Currently only a single front and b... | true |
28bfc2b30b6c5ecad090ed9e45798355043bfc7e | Rust | kbeaulieu/ockam | /implementations/rust/ockam/ockam/src/profile.rs | UTF-8 | 21,982 | 2.53125 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | use crate::{Address, OckamError};
use history::ProfileChangeHistory;
use ockam_core::lib::HashMap;
use ockam_node::Context;
use ockam_vault_core::{Hasher, KeyIdVault, PublicKey, Secret, SecretVault, Signer, Verifier};
use ockam_vault_sync_core::VaultSync;
mod authentication;
use authentication::Authentication;
mod con... | true |
e7f52c9757dc0632ad1ca1a837877308ee0b0ca6 | Rust | fulara/pusz | /calc_plugin/src/lib.rs | UTF-8 | 1,970 | 2.953125 | 3 | [
"MIT"
] | permissive | use plugin_interface;
use plugin_interface::{PluginResult, PuszRow, PuszRowIdentifier, PuszRowBuilder};
#[derive(Debug)]
struct CalcPlugin {
}
impl plugin_interface::Plugin for CalcPlugin {
fn query(&mut self, query: &str) -> PluginResult {
match meval::eval_str(&query) {
Ok(result) => {
... | true |
3bb294a4fee617ae05b252c25e6a62de914a849c | Rust | MarcusGrass/pong | /src/paddle/paddle.rs | UTF-8 | 3,659 | 2.734375 | 3 | [
"MIT"
] | permissive | use amethyst::core::{Transform, Time};
use amethyst::derive::SystemDesc;
use amethyst::ecs::{Join, Read, ReadStorage, System, SystemData, WriteStorage};
use amethyst::input::{InputHandler, StringBindings};
use crate::paddle::component::{Paddle};
// You'll have to mark window_settings.paddle_height() as public in pong.... | true |
a5f214681a711e91a31ff6e2d76427069d6e476d | Rust | Godan/learn_rust | /src/main.rs | UTF-8 | 1,607 | 3.71875 | 4 | [] | no_license | extern crate rand;
use rand::Rng;
use std::cmp::Ordering;
use std::io;
const NUM: i32 = 100000;
fn game() {
println!("Hello, world!");
let secret_number = rand::thread_rng().gen_range(1, 101);
println!("数あてゲーム");
loop {
let mut guess = String::new();
io::stdin()
.read_lin... | true |
9e6e41734184dd8825574a6bf44acfb90ca939bf | Rust | ikornaselur/huffy | /src/node.rs | UTF-8 | 3,811 | 3.78125 | 4 | [] | no_license | use bit_vec::BitVec;
use std::cmp::Ordering;
type ChildNode = Option<Box<Node>>;
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Node {
pub value: Option<u8>,
pub weight: usize,
pub left: ChildNode,
pub right: ChildNode,
}
impl PartialOrd for Node {
fn partial_cmp(&self, other: &Self) -> Option<... | true |
d38f36d133c150c45d0f31ab2facbb3b29b9832a | Rust | sfackler/heapsize | /derive/lib.rs | UTF-8 | 4,039 | 2.671875 | 3 | [] | no_license | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#[cfg(not(test))] extern crate proc_macro;
#[macro_use] extern crate quote;
extern crate syn;
extern crate synstru... | true |
e660989fa1666eb56cf0b305dc8c2e424bb6a68d | Rust | jeffomatic/scheme-rs | /src/parse/expr.rs | UTF-8 | 11,108 | 2.875 | 3 | [] | no_license | use super::error::Error;
use super::sexpr::Sexpr;
use crate::lex::{SrcSpan, Token, TokenType};
use std::cell::RefCell;
use std::rc::Rc;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum UnaryOperator {
Car,
Cdr,
IsNull,
IsBoolean,
IsString,
IsNumber,
IsClosure,
IsPair,
}
impl Unary... | true |
4a4a2a2837a32bfeccc2dc7e5abbc08b424de38f | Rust | Overmuse/datastore | /server/src/handlers/last.rs | UTF-8 | 934 | 2.546875 | 3 | [] | no_license | use crate::redis::Redis;
use tracing::debug;
use warp::Rejection;
#[tracing::instrument(skip(redis))]
pub async fn get_last_price(ticker: String, redis: Redis) -> Result<impl warp::Reply, Rejection> {
let key = format!("price/{}", ticker);
let price = redis.get::<Option<f64>>(&key).await?;
debug!(?price);
... | true |
4954041b92c387822e3332670ced934d4b5d3fec | Rust | sharpvik/idioma | /src/bin/basic.rs | UTF-8 | 618 | 2.9375 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"MIT"
] | permissive | extern crate idioma;
use colored::Colorize;
use idioma::*;
/// This function demonstrates use of the library.
/// Run this using `cargo run --bin basic`. Execution will exit with error - don't panic.
fn main() {
success("Yay, you actually managed to compile this!").print();
info("This is just a demo of what id... | true |
5fd65dfa10c4e7c3db0c900e4cecf96c0facbca8 | Rust | bumblepie/advent-of-code-2018 | /day-18/part-1/src/main.rs | UTF-8 | 6,895 | 3.15625 | 3 | [] | no_license | use std::collections::HashMap;
use std::env;
use std::fmt;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::process;
fn main() {
let args: Vec<String> = env::args().collect();
let filename = &args[1];
let file = File::open(filename).expect("Unable to open file");
let (lines,... | true |
f3fe47271638087fe29942fba9af8390542f59fd | Rust | GrantJenk/ShieldBattery | /game/src/bw_scr/file_hook.rs | UTF-8 | 10,328 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::ffi::CStr;
use std::ptr::null_mut;
use arrayvec::ArrayVec;
use lazy_static::lazy_static;
use libc::c_void;
use super::scr;
use super::thiscall::Thiscall;
pub fn open_file_hook(
out: *mut scr::FileHandle,
path: *const u8,
params: *const scr::OpenParams,
orig: unsafe extern fn(
*mut sc... | true |
54ec1723832abd1d1d3779542154ba3b30bc6398 | Rust | forkkit/semaphore | /server/src/actors/controller.rs | UTF-8 | 7,673 | 3.40625 | 3 | [
"MIT"
] | permissive | //! Defines an actor to control system run and shutdown.
//!
//! See the [`Controller`] struct for more information.
//!
//! [`Controller`]: struct.Controller.html
use std::time::Duration;
use ::actix::actors::signal;
use ::actix::fut;
use ::actix::prelude::*;
use futures::future;
use futures::prelude::*;
use crate:... | true |
52ba045b9aaa8f13b386c4be322238a942903f73 | Rust | johampel/logico | /src/parser.rs | UTF-8 | 15,230 | 3.28125 | 3 | [
"MIT"
] | permissive | use crate::expression;
use crate::expression::{BinaryExpression, BinaryOperator, UnaryExpression, UnaryOperator};
use crate::tokens::{ParseError, Token, token_len, token_name, token_pos};
pub fn parse(tokens: &[Token]) -> Result<Box<dyn expression::Expression>, ParseError> {
match tokens.len() {
0 => Err(P... | true |
d4e6b523dd206805e696d810ada9d50788b6307c | Rust | bevyengine/bevy | /crates/bevy_transform/src/systems.rs | UTF-8 | 19,908 | 2.921875 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | use crate::components::{GlobalTransform, Transform};
use bevy_ecs::{
change_detection::Ref,
prelude::{Changed, DetectChanges, Entity, Query, With, Without},
query::{Added, Or},
removal_detection::RemovedComponents,
system::{Local, ParamSet},
};
use bevy_hierarchy::{Children, Parent};
/// Update [`G... | true |
d3f88053c75de2c9d59d7a7d1ada8ebb4a01cf6a | Rust | dineshadepu/org-rs | /rust/element/src/headline.rs | UTF-8 | 4,964 | 3.328125 | 3 | [
"MIT"
] | permissive | //! Headlines and Sections
//! https://orgmode.org/worg/dev/org-syntax.html#Headlines_and_Sections
//! A headline is defined as:
//!
//! STARS KEYWORD PRIORITY TITLE TAGS
//!
//! STARS is a string starting at column 0, containing at least one asterisk (and up to
//! org-inlinetask-min-level if org-inlinetask library is... | true |
965441cfcafbd8a62609366f7e6189140a7c98ac | Rust | elpnt/rust-rtow | /src/camera.rs | UTF-8 | 1,944 | 3.203125 | 3 | [] | no_license | use crate::ray::Ray;
use crate::vec3::Vec3;
use rand;
use std::f32::consts::PI;
#[derive(Debug, Clone, Copy)]
pub struct Camera {
pub origin: Vec3,
pub lower_left_corner: Vec3,
pub horizontal: Vec3,
pub vertical: Vec3,
pub u: Vec3,
pub v: Vec3,
pub w: Vec3,
pub lens_radius: f32,
}
impl... | true |
89c9042799a66beb0961c7b1413679879c726d3d | Rust | dougli1sqrd/queus | /src/device/mod.rs | UTF-8 | 770 | 2.78125 | 3 | [] | no_license | use std::sync;
use super::Packet;
use std::fmt;
struct Process {
input: sync::mpsc::Receiver<Packet>,
output: sync::mpsc::Sender<Packet>
}
trait Run {
fn run();
}
pub struct Device {
id: String,
connected_devices: Vec<Device>,
parent_device: Option<Box<Device>>
}
#[derive(Eq, PartialEq, Clon... | true |
bc1c39e65ea53f605b506dbe840fa8786019367a | Rust | rewitt94/bank | /tests/integration_test.rs | UTF-8 | 1,649 | 3.484375 | 3 | [] | no_license | extern crate bank;
use bank::account::Account as Account;
use bank::writer::output_statement as output_statement;
#[derive(Debug,PartialEq)]
struct Statement {
bytes: Vec<u8>,
}
#[test]
fn account_stores_all_transactions() {
let mut account = Account::new(0);
account.deposit(200);
account.deposit(400)... | true |
164ee2ee7d4148fa7e0d225ae05833c3bb5de442 | Rust | Jasperav/cdrs-tokio | /src/transport.rs | UTF-8 | 5,660 | 2.953125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //!This module contains a declaration of `CdrsTransport` trait which should be implemented
//!for particular transport in order to be able using it as a transport of CDRS client.
//!
//!Currently CDRS provides to concrete transports which implement `CDRSTranpsport` trait. There
//! are:
//!
//! * [`TransportTcp`] is de... | true |
c8fab334e693b8db3b55e204b834e0329ed36e1b | Rust | spacedragon/rlox | /src/output.rs | UTF-8 | 363 | 2.984375 | 3 | [] | no_license | use std::io::{Write, Stdout};
pub trait Output {
fn write_string(&mut self, s: String);
}
impl Output for String {
fn write_string(&mut self, s: String) {
self.push_str(s.as_str())
}
}
impl Output for Stdout {
fn write_string(&mut self, s: String) {
self.lock().write_all(s.as_bytes())... | true |
a3d12da7a86d95fa8cb635c98128fca7f6da081f | Rust | PsichiX/emergent | /src/consideration.rs | UTF-8 | 6,120 | 3.609375 | 4 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Considerations are used to tell possibility, how important certain fact about the world is.
//!
//! See [`Consideration`] for more info about considerations.
//!
//! See [`crate::evaluators`] for more info about evaluators (operations on sets of considerations).
use crate::{condition::*, score_mapping::*, Scalar};... | true |
a6501a70df3d69fde2b55afd24a401934aacab7e | Rust | bartsmykla/exercism | /rust/difference-of-squares/src/lib.rs | UTF-8 | 266 | 3.421875 | 3 | [] | no_license | pub fn square_of_sum(n: usize) -> usize {
let sum: usize = (1..n + 1).sum();
sum.pow(2)
}
pub fn sum_of_squares(n: usize) -> usize {
(1..n + 1).map(|n| n.pow(2)).sum()
}
pub fn difference(n: usize) -> usize {
square_of_sum(n) - sum_of_squares(n)
} | true |
7d85561a76770e6a6b396132d4eee8cdbd5428a4 | Rust | lazareviczoran/advent-of-code-2020 | /day-22/src/main.rs | UTF-8 | 3,899 | 3.359375 | 3 | [] | no_license | use std::collections::{HashSet, VecDeque};
use std::fs::read_to_string;
fn main() {
let mut game = read("input.txt");
game.play_simple();
println!("part1 solution: {:?}", game.calculate_score());
game.reset();
game.play_recursive();
println!("part2 solution: {}", game.calculate_score());
}
#[... | true |
512f8654c7ed98cadd69321c4b88c0f9ea682b69 | Rust | yyyk/wave-generator | /src/main.rs | UTF-8 | 1,983 | 2.671875 | 3 | [] | no_license | use std::env;
use std::path::Path;
use std::error::Error;
use std::fs::File;
use std::io::BufReader;
#[macro_use]
extern crate serde_derive;
use hound;
mod sig;
fn read_user_from_file<P: AsRef<Path>>(path: P) -> Result<sig::Wave, Box<dyn Error>> {
let file = File::open(path)?;
let reader = BufReader::new(fil... | true |
62150b6bda9a0f959989974d21685ad5c8a29502 | Rust | david415/cryptopals | /rust/tests/set1_test.rs | UTF-8 | 4,662 | 2.6875 | 3 | [] | no_license | extern crate rustc_serialize as serialize;
extern crate cryptopals;
use serialize::base64::{self, FromBase64, ToBase64};
use serialize::hex::FromHex;
use serialize::hex::ToHex;
use std::fs::File;
use std::io::prelude::*;
use std::io::{BufReader};
#[test]
fn challenge1() {
let input = "49276d206b696c6c696e6720796... | true |
3fa13c86602ce046219daf721dbfbf245935622d | Rust | marco-c/gecko-dev-comments-removed | /third_party/rust/rayon/src/iter/multizip.rs | UTF-8 | 6,204 | 2.546875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT",
"Apache-2.0"
] | permissive | use super::plumbing::*;
use super::*;
#[derive(Debug, Clone)]
pub struct MultiZip<T> {
tuple: T,
}
macro_rules! reduce {
($a:expr, $b:expr, $c:expr, $d:expr, $( $x:expr ),+ => $fn:path) => {
reduce!(reduce!($a, $b, $c,... | true |
da197f479029e29a8b1b3e7777bb58145b542326 | Rust | robamu/unix-system-popen | /rust-app-dir/src/main.rs | UTF-8 | 165 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use std::{thread, time};
fn main() {
println!("Sleeping for two seconds!");
thread::sleep(time::Duration::from_secs(2));
println!("Sleeping done!");
}
| true |
03814b9aaef73d2290073a573c54f5f87c826e97 | Rust | Centril/jellyschema | /src/schema/version.rs | UTF-8 | 1,560 | 3.28125 | 3 | [
"Apache-2.0"
] | permissive | use serde::{de, ser};
use serde_json::Number;
#[derive(Debug, PartialEq)]
pub struct Version {
value: u8,
}
impl Version {
/// Returns schema version value
pub fn value(&self) -> u8 {
self.value
}
}
impl Default for Version {
fn default() -> Version {
Version { value: 1 }
}
}
... | true |
78eeeed26d17f2d4ace35562172475674003e9e1 | Rust | bitshifter/bevy_mod_picking | /src/lib.rs | UTF-8 | 18,134 | 2.9375 | 3 | [] | no_license | use bevy::{
prelude::*,
render::camera::Camera,
render::color::Color,
render::mesh::{VertexAttribute, VertexAttributeValues},
render::pipeline::PrimitiveTopology,
window::CursorMoved,
};
pub struct PickingPlugin;
impl Plugin for PickingPlugin {
fn build(&self, app: &mut AppBuilder) {
... | true |
6a3d36d4c047d2f82f0a6da68976a1f20069c110 | Rust | AtsukiTak/bitcoinrs-codec | /src/net.rs | UTF-8 | 959 | 3 | 3 | [] | no_license | use error::*;
pub const MAINNET_START_STRING: [u8; 4] = [0xf9, 0xbe, 0xb4, 0xd9];
pub const TESTNET3_START_STRING: [u8; 4] = [0x0b, 0x11, 0x09, 0x07];
pub const REGTEST_START_STRING: [u8; 4] = [0xfa, 0xbf, 0xb5, 0xda];
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NetworkType {
Main,
Test,
RegTe... | true |
037d32a2e33496052d5178749dcdfc42bdcfe18a | Rust | oconnor663/blake2_simd | /run_all_tests/src/main.rs | UTF-8 | 2,103 | 2.953125 | 3 | [
"MIT"
] | permissive | use std::env;
use std::path::{Path, PathBuf};
use std::process::{self, Command};
fn project_root() -> &'static Path {
Path::new(env!("CARGO_MANIFEST_DIR"))
.parent()
.expect("parent failed")
}
fn run_cmd(project: &str, cmd: &[&str]) {
let project_dir = Path::new(project_root()).join(project);
... | true |
c6e7829a153e6b88d2d59002f61bb3d98fcd9178 | Rust | nbigaouette/advent_of_code_2017 | /day05/src/lib.rs | UTF-8 | 10,737 | 3.8125 | 4 | [] | no_license | //! # Day 5: A Maze of Twisty Trampolines, All Alike
//!
//! ## Part One
//!
//! An urgent interrupt arrives from the CPU: it's trapped in a maze of jump instructions, and it would like assistance from any programs with spare cycles to help find the exit.
//!
//! The message includes a list of the offsets for each jump... | true |
6b87c3f8b9a30eaaaf172ead8bb24194fef1c2fd | Rust | bluejekyll/tokio | /tokio/src/tests/mock_schedule.rs | UTF-8 | 3,067 | 2.828125 | 3 | [
"MIT"
] | permissive | #![allow(warnings)]
use crate::task::{Header, Schedule, Task};
use std::collections::VecDeque;
use std::sync::Mutex;
use std::thread;
pub(crate) struct Mock {
inner: Mutex<Inner>,
}
pub(crate) struct Noop;
pub(crate) static NOOP_SCHEDULE: Noop = Noop;
struct Inner {
calls: VecDeque<Call>,
pending_run: ... | true |
c977894fb194602a94d7779e3bfb2ad1aae7c75a | Rust | Calsign/collab | /src/collabignore.rs | UTF-8 | 2,355 | 2.734375 | 3 | [] | no_license | use crate::common::*;
use ignore::{
gitignore::{Gitignore, GitignoreBuilder},
Match, Walk, WalkBuilder,
};
use std::{
collections::HashSet,
ffi::OsStr,
mem,
path::{Path, PathBuf},
};
pub struct Ignore {
root: PathBuf,
files: HashSet<PathBuf>,
gitignore: Gitignore,
}
impl Ignore {
... | true |
2057a01c1a5863a74f965e63567179a9c0364e62 | Rust | AnvilMC/anvil_bedrock | /mcpe_protocol/src/objects/utils/zig_zag.rs | UTF-8 | 1,493 | 3.703125 | 4 | [
"Apache-2.0"
] | permissive | //! Zig-zag encoding of integral values
/// A trait for enabling zig-zag encoding of various values
pub trait ZigZag<T> {
/// Encodes this ZigZag-enabled type into the type specified by implementation
fn zigzag(&self) -> T;
}
impl ZigZag<u8> for i8 {
/// Encodes this i8 as a zigzagged u8
fn zigzag(&se... | true |
d7fe6821e50ed0bfe8a23040cc729205e7addd62 | Rust | marc47marc47/leetcode-cn | /973KClosest/k-closest-quicksort/src/main.rs | UTF-8 | 1,545 | 3.5625 | 4 | [] | no_license | fn main() {
println!("Hello, world!");
assert_eq!(Solution::k_closest(vec![vec![1,3],vec![-2,2]], 1),vec![vec![-2,2]]);
assert_eq!(Solution::k_closest(vec![vec![-2,2]], 1),vec![vec![-2,2]]);
assert_eq!(
Solution::k_closest(vec![vec![3, 3], vec![5, -1], vec![-2, 4]], 2),
vec![vec![-2, 4],... | true |
99672095057b39051293c57a7e9684e77d781203 | Rust | briandeboer/elevator_rs | /lib/core/person/src/components/gun.rs | UTF-8 | 755 | 2.640625 | 3 | [] | no_license | use amethyst::ecs::{Component, DenseVecStorage};
#[allow(dead_code)] // remove when all variants are finished
#[derive(Debug, Eq, Hash, PartialEq, Clone, Copy)]
pub enum GunState {
Shooting,
JumpShooting,
Holstered,
}
#[derive(Component)]
#[storage(DenseVecStorage)]
pub struct Gun {
pub shots_fired: i... | true |
f7489757170d457dafde99b9118340d1c773e93c | Rust | ayosec/summer | /src/summarizer/sorting.rs | UTF-8 | 5,252 | 3.171875 | 3 | [
"Apache-2.0"
] | permissive | //! This module provides the [`sort`] function, which is used to sort the files
//! in a [`FilesGroup`], according to the sort specification defined by the
//! configuration.
//!
//! The implementation to compute the sorting key tries to be as cheap as possible.
//!
//! [`sort`]: self::sort
//! [`FilesGroup`]: super::F... | true |
4383e78df28aa1c05feed314720b45194f21583b | Rust | stellar/slingshot | /starsig/src/transcript.rs | UTF-8 | 1,395 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use curve25519_dalek::ristretto::CompressedRistretto;
use curve25519_dalek::scalar::Scalar;
use merlin::Transcript;
/// Extension trait to the Merlin transcript API that allows committing scalars and points and
/// generating challenges as scalars.
pub trait TranscriptProtocol {
/// Commit a domain separator for a... | true |
e0664d960ba246ec2f1b95c8c283eaffd80cda22 | Rust | 8l/vulkano | /vulkano/src/buffer.rs | UTF-8 | 28,344 | 3.09375 | 3 | [] | no_license | //! Location in memory that contains data.
//!
//! All buffers are guaranteed to be accessible from the GPU.
//!
//! The `Buffer` struct has two template parameters:
//!
//! - `T` is the type of data that is contained in the buffer. It can be a struct
//! (eg. `Foo`), an array (eg. `[u16; 1024]` or `[Foo; 1024]`), or... | true |
5f2ba7115f67f13a8e9a93fc73705ec12d99021f | Rust | chenenjie/request_util | /src/main.rs | UTF-8 | 676 | 2.546875 | 3 | [] | no_license | extern crate hyper;
extern crate regex;
use std::io;
use hyper::Client;
use hyper::header::Connection;
fn main() {
let url = "http://hk-bici.net/forum.php";
let client = Client::new();
let mut res = client.get(url)
.header(Connection::close())
.send().unwrap();
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.