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
fd76c6fd50a1b3e3ed68b3dc587e55c8fb3bc788
Rust
LibRapid/LibRapidRust
/src/compsci/rapidlogging.rs
UTF-8
4,008
3.609375
4
[ "MIT" ]
permissive
//! Basic logging functionality. use chrono::{Utc, SecondsFormat}; use std::{io::prelude::*, fs::OpenOptions}; use crate::math::general::NumTools; /// The structure for the RapidLogger. pub struct Logger { /// The buffer size. If the buffer count exceeds this value, the buffer gets written to the specified file. ...
true
c87cc6bea7b81787a77add818852ba1745eb7a8f
Rust
drklee3/jservice
/src/model.rs
UTF-8
1,923
3.3125
3
[ "MIT" ]
permissive
use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize)] pub struct Category { pub id: u64, pub title: String, pub created_at: Option<DateTime<Utc>>, pub updated_at: Option<DateTime<Utc>>, pub clues_count: u64, pub clues: Option<Vec<Clue>>, } #[deriv...
true
1c6be052616cbfc00fcc5519f5e0934ae23ba4d8
Rust
selmeci/dgraph-tonic
/examples/simple/src/main.rs
UTF-8
3,630
2.765625
3
[ "MIT" ]
permissive
use chrono::prelude::*; use dgraph_tonic::{Client, Mutate, Mutation, Operation, Query}; use maplit::hashmap; use serde::{Deserialize, Serialize}; async fn drop_all(client: &Client) { let op = Operation { drop_all: true, ..Default::default() }; client.alter(op).await.expect("dropped all"); }...
true
7d26034f92a0e5580e3db62ff3f4dca34a851e7e
Rust
snoyberg/routetype-rs
/routetype/src/raw.rs
UTF-8
9,120
3.5
4
[]
no_license
use super::either::Either; use super::{PathSegment, QueryPair}; use std::borrow::Cow; /** Parse a string containing both a path and query string. This function relies on the underlying behavior of [parse_path] and [parse_query]. Please see those functions for details. Importantly here, this function will return `Non...
true
c4878e68edd5239f47e6e6fc2535ca2b1a290524
Rust
jac3km4/rustfu
/gui/src/translations.rs
UTF-8
1,305
3.28125
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io; use std::path::Path; use zip::ZipArchive; pub struct Translations { entries: HashMap<String, String>, } impl Translations { pub fn load(path: &Path) -> io::Result<Translations> { let file = File::open(path)?; let mut archive = ZipA...
true
7b50ef97a42d6604eab3ef143c93ae7acc85b407
Rust
awruef/squadlog
/src/main.rs
UTF-8
23,807
2.78125
3
[]
no_license
extern crate bimap; extern crate chrono; extern crate indicatif; extern crate regex; extern crate serde; extern crate serde_json; use chrono::*; use indicatif::{ProgressBar, ProgressStyle}; use regex::Regex; use serde::{Deserialize, Serialize}; use std::collections::HashMap; use std::collections::HashSet; use std::env...
true
7d27ff7c4c80eaf9d52024dd780114d4e36ae032
Rust
darknight/kv.rs
/src/sled_engine.rs
UTF-8
2,604
3.015625
3
[]
no_license
use std::path::{Path, PathBuf}; use std::fs; use sled::{Db, IVec}; use super::engine::{Result, KvsEngine, KvError}; /// default log file const DEFAULT_PATH: &'static str = "./database"; /// Wrapper for sled Db struct #[derive(Clone)] pub struct SledStore { db: Db, } impl Default for SledStore { fn default(...
true
aace0e7aa5538d65b952c87742d5c466d23a4deb
Rust
m0dulo/Wispha
/src/commandline/mod.rs
UTF-8
791
2.859375
3
[ "MIT", "Apache-2.0" ]
permissive
use structopt::StructOpt; use std::error; mod layout; mod interact; mod generate; pub trait CommandlineOption { fn run(self) -> Result<(), Box<dyn error::Error>>; } #[derive(StructOpt)] pub enum Commandline { /// Display a project layout Layout(layout::LayoutOptions), /// Generate default JSON file...
true
245b24e8b5d01a80e42ba17609834ae18d16c420
Rust
ThomasZumsteg/exercism-rust
/etl/src/lib.rs
UTF-8
308
2.609375
3
[]
no_license
use std::collections::BTreeMap; pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> { let mut result = BTreeMap::new(); for (v, keys) in input.iter() { for k in keys.iter() { result.insert(k.to_lowercase().next().unwrap(), *v); } } result }
true
e8e753a45081af794adda04710410f9c9a02c788
Rust
aludvik/simple-games
/vacuum/src/main.rs
UTF-8
2,800
3.046875
3
[]
no_license
extern crate engine; use std::{thread, time}; use engine::io::screen::Screen; use engine::io::window::Window; use engine::io::keys::*; use engine::world::scene::Scene; type Vec2 = (i32, i32); struct GameState { pub vacuum: Vec2, pub dust: Vec<Vec2>, pub score: i32, } fn main() { let (w, h) = (32, 2...
true
1252529dfb5fb5398b7c1a441d2d1447f92885c0
Rust
Melvillian/advent_of_code_2018_rust
/src/aoc/util.rs
UTF-8
280
2.640625
3
[]
no_license
use std::fs; pub fn get_input_file_as_string(filename: &str) -> String { fs::read_to_string(filename).unwrap() } pub fn get_input_as_vec(freqs: &str) -> Vec<i32> { freqs .lines() .map(|line| line.parse::<i32>().unwrap()) .collect::<Vec<i32>>() }
true
ab2b4faf92f3b9bffebd3bbd5b391c6d29d582fa
Rust
ejrinkus/advent-of-code-2018
/day-two/src/main.rs
UTF-8
1,676
3.34375
3
[]
no_license
use std::collections::HashMap; use std::env; use std::fs::File; use std::io::BufRead; use std::io::BufReader; extern crate trie; use trie::Trie; fn main() { let args: Vec<String> = env::args().collect(); assert_eq!(args.len(), 2, "Incorrect number of args"); let f = File::open(&args[1]).expect("file not f...
true
d4e944f6918a9e65325361a6600733d8a71c290e
Rust
arjandepooter/advent-of-code-2015
/src/bin/aoc02.rs
UTF-8
2,287
3.34375
3
[]
no_license
use std::str::FromStr; use aoc_2015::io::read_input; #[derive(Debug, PartialEq, Default)] struct Present { l: u32, w: u32, h: u32, } #[derive(Debug, PartialEq)] struct ParsePresentError; impl Present { fn smallest_sides(self: &Self) -> (u32, u32) { let mut sides = [self.l, self.w, self.h]; ...
true
b8af622a45b955db684b8980a7addd7c60c120ff
Rust
vuppalac/pquote
/examples/pq.rs
UTF-8
7,507
2.890625
3
[ "Apache-2.0" ]
permissive
use ansi_term::Colour::{Green, Red, Yellow}; use pquote::{Quote, QUOTES}; use rand::Rng; use textwrap::Wrapper; #[derive(Debug)] enum AppArgs { Flags { help: bool, version: bool, verbose: bool, all: bool, id: Option<u32>, author: Option<String>, origin: Optio...
true
0306339321dc68c44d20d5e3056cd9fce950bf38
Rust
ldenefle/rust-embedded-to-backend
/lib-parser/src/lib.rs
UTF-8
6,043
2.671875
3
[]
no_license
#![cfg_attr(not(feature = "std"), no_std)] #[cfg(not(feature = "std"))] extern crate heapless; #[cfg(not(feature = "std"))] use heapless::consts::*; #[cfg(not(feature = "std"))] use heapless::Vec; #[cfg(feature = "serialize")] #[macro_use] #[cfg(feature = "serialize")] extern crate serde_derive; #[cfg_attr(feature =...
true
65cd513a858a44f3e2a3f729998153c4e3f0f76f
Rust
yuv418/multihangman
/hangmanstructs/src/lib.rs
UTF-8
3,005
2.921875
3
[]
no_license
use serde::{Serialize, Deserialize}; use serde::de::DeserializeOwned; use std::net::SocketAddr; use std::cmp::PartialEq; use std::fs; extern crate toml; #[cfg(feature="sql")] #[macro_use] extern crate diesel_derive_enum; #[cfg(feature="sql")] #[macro_use] extern crate diesel; #[cfg(feature="sql")] use diesel::prelude:...
true
ed18196b78bdd5703ba6c495f35be38833ed55f4
Rust
czyczk/LeetCode
/rust/lc-703/src/solution.rs
UTF-8
899
3.765625
4
[]
no_license
pub struct KthLargest { heap: std::collections::BinaryHeap<std::cmp::Reverse<i32>>, capacity: usize, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl KthLargest { pub fn new(k: i32, nums: Vec<i32>) -> Self { ...
true
c843032fb797bf8d7e4c45aa8ba4359f32c2f862
Rust
EleDiaz/way-cooler
/client/src/common/signal.rs
UTF-8
2,872
3.28125
3
[ "MIT" ]
permissive
//! Signals are a list of methods associated with a name that will be called //! when the signal is triggered. //! //! Signals are stored with the object in its metatable, //! the methods defined here are just to make it easier to use. use rlua::{self, Function, Table, ToLuaMulti, Value}; use crate::GLOBAL_SIGNALS; ...
true
ea6f40b01e2b68531c3ea8baedf79d2584189c29
Rust
rfdonnelly/rvs
/parser/src/ast.rs
UTF-8
2,300
3.265625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fmt; #[derive(Debug, Clone)] pub enum BinaryOpcode { Or, Xor, And, Shl, Shr, Add, Sub, Mul, Div, Mod, } #[derive(Debug, Clone)] pub enum UnaryOpcode { Inv, Neg, } #[derive(Debug)] pub enum Type { Pattern, Sequence, Range, Expand, Done, ...
true
ba6390e2bb06f317b54905a1e9075bed2aa8a73a
Rust
brechtcs/kiosk
/src/reject.rs
UTF-8
516
2.640625
3
[]
no_license
use nickel::{Response, MiddlewareResult}; pub fn bad_request<'app>(res: Response<'app>) -> MiddlewareResult<'app> { res.send("Four'O'Zero") } pub fn not_allowed<'app>(res: Response<'app>) -> MiddlewareResult<'app> { res.send("Four'O'Three") } pub fn not_found<'app>(res: Response<'app>) -> MiddlewareResult<'app> ...
true
d26d15bf560820f8d44870193090aff79eb9501c
Rust
russelltg/srt-rs
/srt-tokio/src/socket/mod.rs
UTF-8
5,156
2.609375
3
[ "Apache-2.0" ]
permissive
mod builder; mod call; mod listen; mod rendezvous; pub(crate) mod factory; use std::{ fmt::Debug, io, pin::Pin, sync::Arc, task::{Context, Poll}, time::Instant, }; use bytes::Bytes; use futures::{ channel::mpsc::{self, TrySendError}, prelude::*, ready, stream::Peekable, }; use...
true
8d9f143d3534ca21fad94a2294c8fea0b15f693b
Rust
falkenum/nes
/src/cpu/instructions/mod.rs
UTF-8
15,858
2.875
3
[ "MIT" ]
permissive
use super::{ CPU, Memory, split_bytes, concat_bytes }; #[cfg(test)] mod tests; pub mod decode; // turns out that I didn't need to implement BCD because the // NES version of the 6502 (the 2A03) has it disabled, but here it is fn from_bcd(x : u8) -> u8 { (x & 0x0F) + ((x & 0xF0) >> 4) * 10 } fn to_bcd(x : u8) -> u8 { (...
true
44a75f1146b6319a697468f56187a4459f348799
Rust
ADefossez-Zenika/rustymon
/src/systems/mob.rs
UTF-8
3,291
2.90625
3
[]
no_license
use crate::components::{Active, Hero, Mob, Velocity}; use amethyst::{ core::transform::Transform, ecs::{Entities, Join, ReadStorage, System, WriteStorage}, }; use ncollide2d::math::Vector; const MOB_SPEED: f32 = 0.8; /// Acquire close target. pub struct MobTargetSystem; impl<'a> System<'a> for MobTargetSyste...
true
d534cf4757ac7db25eb60e00c263b6795b85ad80
Rust
ava57r/npchk-rs
/src/models/partner.rs
UTF-8
3,221
3.03125
3
[ "MIT" ]
permissive
use chrono::prelude::*; use std::borrow::Cow; /// Structure describes the data type, which is used by the server #[derive(Debug)] pub struct Partner<'a> { /// Taxpayer identification number pub inn: Cow<'a, str>, /// The reason code of registration pub kpp: Cow<'a, str>, /// Date on which the reque...
true
a2d5fec70222ef9ae5a0bd3cb5cbcba629c46437
Rust
atsushi130/perceptron
/src/learner/perceptron/perceptron.rs
UTF-8
1,828
3.109375
3
[]
no_license
use super::super::Learner; use std::collections::HashMap; use file_operator::{ FileOperator, Parser }; pub struct Perceptron<T: Parser> { word_model: HashMap<String, i8>, file_operator: FileOperator<T> } impl<T: Parser> Learner for Perceptron<T> { fn learn(&mut self) { for line in self.file_ope...
true
a67c3d9ac73ee047addfae30cbfa077f11cfb164
Rust
gilcu2/balltree-search
/src/lib.rs
UTF-8
2,141
3.703125
4
[]
no_license
/// Must satisfy identity of indiscernibles, symmetry and triangle inequality (https://en.wikipedia.org/wiki/Metric_space) pub trait Point { fn distance(&self, other: &Self) -> f64; } pub struct Ball<T: Point> { id: usize, center: T, radio: f64, } impl<T: Point> Ball<T> { fn new(id: usize, center...
true
7d70ffe2dd50eecdf179bf616187202a94b50d6c
Rust
sepiggy/imooc-517
/ch06/demo03methodgenerics/src/main.rs
UTF-8
589
4.09375
4
[]
no_license
struct Point<T> { x: T, y: T, } impl<T: Clone + std::cmp::PartialOrd> Point<T> { fn max(&self) -> T { if self.x > self.y { self.x.clone() } else { self.y.clone() } } } // 为特定类型实现方法 impl Point<f32> { fn dist_from_origin(&self) -> f32 { (self.x...
true
d17c1755338f541b0aec825797cdb01d394db532
Rust
saramic/learning
/lang/rust/rust_in_action/ch5-data-in-depth/chip8-emulator/src/main.rs
UTF-8
2,580
3.671875
4
[ "Unlicense" ]
permissive
struct CPU { registers: [u8; 16], position_in_memory: usize, memory: [u8; 4096], stack: [u16; 16], stack_pointer: usize, } impl CPU { fn run(&mut self) { loop { let op_byte1 = self.memory[self.position_in_memory] as u16; let op_byte2 = self.memory[self.position_...
true
9ea078ca370ab0df0e3a2b732d4c95989ff0a353
Rust
manuel-rhdt/rust-rasterize
/src/geometry.rs
UTF-8
6,277
3.3125
3
[]
no_license
use std::ops::{Add, Sub, Mul, Div, Neg}; use std::convert::From; #[derive(Debug, Copy, Clone, PartialEq, Default)] pub struct Point { pub x: f32, pub y: f32, } impl Sub<Point> for Point { type Output = Vec2d; fn sub(self, rhs: Point) -> Vec2d { Vec2d { x: self.x - rhs.x, ...
true
c41c0b8f1287213ca52dcfb9cb3dbdc8e190a6e3
Rust
nervosnetwork/tockb-cli
/ckb-index/src/kvdb/rocks.rs
UTF-8
6,322
2.671875
3
[ "MIT" ]
permissive
use std::collections::{BTreeMap, HashMap}; use std::mem; use std::ops::Bound; use rocksdb::ops::{GetCF, IterateCF, WriteOps}; use rocksdb::{ColumnFamily, DBIterator, Direction, IteratorMode, WriteBatch, DB}; use super::{KVReader, KVTxn}; pub struct RocksReader<'a> { cf: &'a ColumnFamily, db: &'a DB, } impl<...
true
ddd87bad58576a8031bba6b803beeec01c685b7f
Rust
noocene/core-futures-io
/src/ext/read/mod.rs
UTF-8
2,841
2.59375
3
[]
no_license
use crate::AsyncRead; use bytes::BufMut; mod chain; mod read; mod read_buf; mod read_exact; mod read_int; #[cfg(feature = "alloc")] mod read_to_end; #[cfg(feature = "alloc")] mod read_to_string; mod take; #[cfg(feature = "alloc")] use alloc::{string::String, vec::Vec}; use chain::chain; pub use chain::Chain; use read::...
true
4c0d7a3d574d27a1f09f0fd39df6f828a85c1d22
Rust
SOF3/posrel
/src/scalar.rs
UTF-8
1,478
2.578125
3
[ "Apache-2.0" ]
permissive
// posrel // Copyright (C) SOFe // // 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 i...
true
d82de54cf9973ece36bc939fa68c735856bdf092
Rust
LeoTestard/presentations
/cake.rs
UTF-8
990
3.359375
3
[]
no_license
enum Flavor { chocolate, vanilla } struct Cake { flavor: Flavor, num_slices: int } impl Cake { fn eat_slice(&mut self) { self.num_slices -= 1; } } fn eat_at_least(cake: &mut Cake, threshold: &int) { let mut eaten_so_far = 0; while (cake.num_slices > 0 && eaten_so_far < *threshold) { cak...
true
7ac0c9c5dda2e60ade53a550922885fb7248aeb0
Rust
exacs/rust_four
/src/players/human_player.rs
UTF-8
1,046
3.328125
3
[]
no_license
use crate::board::Color; use crate::game::*; use crate::players::Player; use std::io; #[allow(dead_code)] pub struct HumanPlayer { name: String, color: Option<Color>, } #[allow(dead_code)] impl HumanPlayer { pub fn new() -> HumanPlayer { let mut input = String::new(); println!("What is you...
true
b747f64a1d8d75e15c3e090b31d2c07c0ec615ef
Rust
klcstudy/tide
/src/log/mod.rs
UTF-8
812
3.046875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Event logging types. //! //! # Examples //! //! ```no_run //! use tide::log; //! //! log::start(); //! //! log::info!("Hello cats"); //! log::debug!("{} wants tuna", "Nori"); //! log::error!("We're out of tuna!"); //! log::info!("{} are hungry", "cats", { //! cat_1: "Chashu", //! cat_2: "Nori", //! }); //! ...
true
30539ed0ff32a5132f165401fe98d3242da4d2a8
Rust
XOSplicer/advent-of-code-2019
/src/12-2.rs
UTF-8
5,988
3.34375
3
[]
no_license
use anyhow::Result as AnyResult; use std::cmp::Ordering; use std::cmp::{max, min}; use std::collections::HashMap; use std::fmt; use std::fs; #[derive(Debug, Clone)] struct Vec3D { x: i64, y: i64, z: i64, } impl Vec3D { fn new(x: i64, y: i64, z: i64) -> Self { Self { x, y, z } } } impl Def...
true
e045a872312bf92509db9db775e36d0943fc6892
Rust
agerasev/hypertrace
/viewer/src/window.rs
UTF-8
2,296
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{ handler::{Handler, PollStatus}, Controller, }; use base::Image; use sdl2::{ self, pixels::PixelFormatEnum, render::{Texture, TextureAccess, WindowCanvas}, Sdl, }; use std::rc::Rc; pub struct Window { canvas: Canvas, handler: Handler, } pub struct Canvas { size: (usize,...
true
e5b916a20b557f942940e21420c74494f496e0f3
Rust
fabrlyn/dns_parser
/src/shared.rs
UTF-8
10,923
3.09375
3
[]
no_license
#[derive(Debug, PartialEq, Eq)] pub enum ParseError { HeaderError(String), QueryLabelError(String), QueryError(String), ResourceRecordError(String), } const LABEL_TYPE_MASK: u8 = 0b11000000; const LABEL_MASK_TYPE_VALUE: u8 = 0b00000000; const LABEL_MASK_TYPE_POINTER: u8 = 0b11000000; #[derive(Clone, Debug, Pa...
true
1cfb22ab329f459459de38b4f93317dafae915c0
Rust
stm32-rs/stm32g0xx-hal
/src/time.rs
UTF-8
2,522
3.03125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "LicenseRef-scancode-unknown" ]
permissive
pub use fugit::{ ExtU32, HertzU32 as Hertz, HoursDurationU32 as Hour, MicrosDurationU32 as MicroSecond, MinutesDurationU32 as Minute, RateExtU32, SecsDurationU32 as Second, }; /// Baudrate #[derive(Debug, Eq, PartialEq, PartialOrd, Clone, Copy)] pub struct Bps(pub u32); /// A measurement of a monotonically no...
true
4e7b40e14b9db195c898b97fd3c45c91f054ff49
Rust
Techno-coder/lexica
/src/lexer/lexer.rs
UTF-8
1,552
3.03125
3
[ "MIT" ]
permissive
use crate::declaration::Declaration; use crate::error::Diagnostic; use crate::source::{Source, SourceKey}; use crate::span::Spanned; use super::space_lexer::SpaceLexer; use super::Token; /// Adds one token lookahead. #[derive(Debug, Clone)] pub struct Lexer<'a> { lexer: SpaceLexer<'a>, token: Option<Spanned<Token>>...
true
03393b144edbf20c7f50018e95ec932a8eeec326
Rust
raphaelcohn/security-keys-rust
/workspace/usb-storm/src/interface/video/control/entities/terminal/types/camera/OpticalZoom.rs
UTF-8
3,648
2.796875
3
[ "MIT" ]
permissive
// This file is part of security-keys-rust. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/security-keys-rust/master/COPYRIGHT. No part of security-keys-rust, including this file, may be copied, modified, ...
true
5a455ad2b359d01ab88930009b457b7f8bc4dfba
Rust
yajamon/zaif-api-rust
/src/core/api.rs
UTF-8
4,097
2.984375
3
[ "MIT" ]
permissive
use chrono; use openssl; use reqwest; use self::chrono::Utc; use self::openssl::hash::MessageDigest; use self::openssl::pkey::PKey; use self::openssl::sign::Signer; use self::reqwest::header::Headers; use std::collections::HashMap; use crate::core::{AccessKey, Method}; pub struct Api { uri: String, method: ...
true
24313d0f7ebe496981a2c039a078a90f9bfdb6aa
Rust
losfair/virtual-dom-rs
/src/vnode.rs
UTF-8
6,521
3.03125
3
[]
no_license
use std::collections::BTreeMap; use vtree; use dom; use map_diff; #[derive(Clone, Eq, PartialEq, Debug)] pub struct BasicVNode { pub tag: Option<String>, pub props: BTreeMap<String, String>, pub style: BTreeMap<String, String>, pub text: Option<String> } pub struct InternalVNode<T: dom::Node> { no...
true
4651be7c85d90981304d5da5b3b7075aed6a7480
Rust
darakian/projecteuler
/pe0017/src/main.rs
UTF-8
2,639
3.9375
4
[]
no_license
fn main() { let mut letters = Vec::new(); for i in 1..=1000{ letters.append(&mut n_to_words(i)); } println!("{:?}", letters.len()); // let test = 999; // for i in 1..=20{ // for token in n_to_words(i){ // print!("{:?}", token); // } // println!(" "); ...
true
32676846d23df3cd09abe748b3b81be3e643abed
Rust
ummarikar/yksom
/src/lib/vm/val.rs
UTF-8
27,119
3.328125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Tagged pointer support. #![allow(clippy::new_ret_no_self)] use std::{ convert::TryFrom, mem::{size_of, transmute}, ops::Deref, ptr::NonNull, }; use abgc::{self, Gc}; use num_bigint::BigInt; use num_enum::{IntoPrimitive, UnsafeFromPrimitive}; use num_traits::{FromPrimitive, ToPrimitive, Zero}; us...
true
0f5fa0df88801cd27d71073f4847d36740fc328d
Rust
SandWoodJones/Euler_Rust
/src/problems/tens/p05.rs
UTF-8
533
3.625
4
[ "Unlicense" ]
permissive
/* 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? */ #[allow(dead_code)] pub fn answer() -> i32 { let mut result = 20; loop { if evenly_divisible_by_20(r...
true
b216afe1c48f067bf4118fba039c570d70e9b139
Rust
yusakufr/evdev-rs
/src/util.rs
UTF-8
3,292
2.796875
3
[]
no_license
use nix::libc::c_char; use raw; use std::fmt; use std::ffi::{CStr, CString}; use super::event::*; pub(crate) fn ptr_to_str(ptr: *const c_char) -> Option<&'static str> { let slice : Option<&CStr> = unsafe { if ptr.is_null() { return None } Some(CStr::from_ptr(ptr)) }; ma...
true
1687c7e3211e87078279746a7d5d9952c64b9fd3
Rust
Supermathie/adventofcode
/2022/src/main.rs
UTF-8
2,016
3.375
3
[ "MIT" ]
permissive
mod days; mod etc; mod util; use etc::solution::Solution; use days::{day01, day02, day03, day04, day05, day06, day07, day08, day09, day10, day11, day12, day13, day14, day15, day16, day17, day18, day19, day20, day21, day22, day23, day24, day25}; use std::env; use std::time::I...
true
3ea281f255fd3f79c1dbd71b014bd6bb07c909bf
Rust
modeverv/Rust2019MyWorkSpace
/duo-m3u/src/main.rs
UTF-8
2,197
3.171875
3
[]
no_license
//! # duo-m3u //! duoのm3uを`~/Downloads`に書き出し、オープンします。 //! ### usage //! ```bash //! $ duo-m3u [Disc01|Disc02|Disc03|Disc04|Disc05|review] [skip num] [take num] //! ``` use glob::glob; use std::env; use std::process::Command; use std::process; extern crate my_lib; /// make m3u file and open. fn main() { // args ...
true
e4fe9448fc932520138787e13905b34bd2a7c885
Rust
lawliet89/aws-auth-payload
/src/client.rs
UTF-8
8,319
2.890625
3
[ "MIT" ]
permissive
use std::borrow::{Borrow, Cow}; use std::collections::HashMap; use std::time::Duration; use lazy_static::lazy_static; use log::{debug, info}; use rusoto_core::credential::AwsCredentials; use rusoto_core::param::{Params, ServiceParams}; use rusoto_core::signature::{SignedRequest, SignedRequestPayload}; use rusoto_core:...
true
e61dc49caf94fcf17317b652bd6bb8b00968a0d3
Rust
kubos/kubos
/libs/shell-protocol/src/messages/list.rs
UTF-8
3,831
2.796875
3
[ "Apache-2.0" ]
permissive
// // Copyright (C) 2018 Kubos Corporation // // 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 agree...
true
4f799a4c9d4c5120cd0867b45de34d806048f2d2
Rust
forchain/rust-netproxy
/taptun/examples/tun.rs
UTF-8
2,003
2.578125
3
[]
no_license
#[allow(dead_code, unused_imports)] extern crate pretty_env_logger; #[macro_use] extern crate log; extern crate taptun; extern crate packet; use std::io::Read; use std::net::Ipv4Addr; use taptun::tun; const MTU: usize = 1500; /** sudo route add 10.0.0.1/24 -interface utun10 curl "10.0.0.50:80" pin...
true
6c1255991b29c74e6ce4e91a7f9bfe6c16463889
Rust
Sawchord/strato-fs
/strato/src/driver.rs
UTF-8
5,107
2.671875
3
[ "MIT" ]
permissive
use std::sync::Arc; use std::ffi::OsStr; use libc::*; use fuse::{Filesystem, ReplyDirectory, ReplyData, ReplyEntry, ReplyAttr}; use fuse::Request as FuseRequest; use futures::sync::mpsc::UnboundedSender; use crate::handler::HandleDispatcher::*; use crate::utils::InoGenerator; use crate::link::NodeEntry; use crate::...
true
84bb73e04c5529205a656a10c17da526f2f7449c
Rust
BlueDragon23/advent-of-code2020
/src/bin/day17.rs
UTF-8
4,593
3.28125
3
[]
no_license
use itertools::Itertools; use std::collections::HashMap; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use std::time; #[derive(Clone, Copy, Debug, Eq, PartialEq)] enum State { On, Off, } #[derive(Eq, PartialEq, Hash, Debug, Clone, Copy)] struct Coord { x: i32, y: i32, z: i32,...
true
9cdbc5e7a27392ecec1357afb4b972893ce9c9a8
Rust
TyOverby/ares-2
/ares/src/util.rs
UTF-8
552
3.140625
3
[]
no_license
use std::fmt::Debug; pub fn iterators_same<'a, T: Debug + 'a, A, B, F>(mut iter1: A, mut iter2: B, eq_fn: F) -> bool where A: Iterator<Item = &'a T>, B: Iterator<Item = &'a T>, F: Fn(&T, &T) -> bool { loop { match (iter1.next(), iter2.next()) { (None, None) => return tru...
true
81805087e0565cc20566a5a4f602cdeca43ff540
Rust
danrees/todo
/src/lib.rs
UTF-8
2,746
3.640625
4
[]
no_license
use serde::{Serialize,Deserialize}; use std::fs::{ OpenOptions, File}; use std::io::{ BufRead, BufReader}; use uuid::Uuid; #[derive(Serialize,Deserialize,Debug, PartialEq)] enum Status { Complete, Incomplete, } pub trait Store { fn create(&mut self, description: String) -> Item; // fn update(&mut self...
true
6da10bccbc151e68d0e652edba09fcdc09c71b8b
Rust
jwfy/rust-learn
/src/threadpool/threadpool.rs
UTF-8
2,405
3.78125
4
[]
no_license
use std::thread; use std::thread::JoinHandle; use std::sync::{mpsc, Arc, Mutex}; struct Worker { id : usize, thread: JoinHandle<()> } type Job = Box<dyn FnOnce() + Send + 'static>; // dyn 关键字是表示当前这个Job是依赖动态分派的,以往的情况都是静态分派(zero cost abstraction 零成本抽象) impl Worker { pub fn new(id: usize, receiver: Arc<Mute...
true
8c0d506e0ab33b719015a07ce226cc0339c24049
Rust
smartdev0218/atomicDEX-API
/mm2src/derives/ser_error_derive/src/lib.rs
UTF-8
4,646
2.921875
3
[]
no_license
use proc_macro::{self, TokenStream}; use proc_macro2::{Span, TokenStream as TokenStream2}; use quote::quote; use syn::Meta::{List, NameValue, Path}; use syn::NestedMeta; use syn::{parse_macro_input, Data, DeriveInput, Error}; use ser_error::CONTENT; use ser_error::TAG; const SERDE_IDENT: &str = "serde"; const TAG_ATT...
true
991fb5d92f624f95f867191accfb27054397f938
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-25368.rs
UTF-8
253
2.609375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std::sync::mpsc::channel; use std::thread::spawn; use std::marker::PhantomData; struct Foo<T> {foo: PhantomData<T>} fn main() { let (tx, rx) = channel(); spawn(move || { tx.send(Foo{ foo: PhantomData }); //~ ERROR E0282 }); }
true
a6048997eec2439c2acc35e954af97d5fe9ac2ec
Rust
Otohito-Fuse/mathematical-objects-in-rust
/src/identities.rs
UTF-8
142
2.984375
3
[]
no_license
/// 零元を与える pub trait Zero { fn zero() -> Self; } /// 単位元を与える pub trait Identity { fn identity() -> Self; }
true
ef0053e028d0e69e3a9f222063fee67c061da5f9
Rust
Fadi88/AoC
/2022/day19/main.rs
UTF-8
5,442
2.84375
3
[ "Unlicense" ]
permissive
use regex::Regex; use std::collections::{HashMap, HashSet, VecDeque}; use std::fs; use std::time; type BluePrint = (u16, u16, u16, u16, u16, u16, u16); #[derive(Eq, Hash, PartialEq, Clone, Debug)] struct State { time: u16, ore: u16, ore_bot: u16, clay: u16, clay_bot: u16, obsidian: u16, ...
true
911dde986d46c5697fb6be760f7a7a1e1e14f699
Rust
AgustinCB/emulators
/nes/src/main.rs
UTF-8
685
2.75
3
[ "MIT" ]
permissive
extern crate failure; extern crate mos6502cpu; extern crate nes; use failure::Error; use nes::{Nes, ROM_SIZE}; use std::env::args; use std::fs::File; use std::io::Read; const USAGE: &str = "Usage: nes [game file]"; fn read_file(file_name: &str) -> std::io::Result<[u8; ROM_SIZE]> { let mut f = File::open(file_nam...
true
dd9dcee8c0f5eb1852e883f731f8a7e0e79aa032
Rust
virtualritz/nsi
/crates/nsi-core/src/tests.rs
UTF-8
6,656
2.609375
3
[ "BSD-3-Clause" ]
permissive
#[allow(unused_imports)] use crate as nsi; #[cfg(test)] #[test] fn test_dodecahedron() { let ctx = nsi::Context::new(None).expect("Could not create NSI context."); // Create a dodecahedron. let face_index: [i32; 60] = // 12 regular pentagon faces. [ 0, 16, 2, 10, 8, 0, 8, 4, 14, 12, ...
true
faafbc5595759dd36ecdde46a2da8f4b448b7795
Rust
jarkkom/adventofcode19
/12/part2.rs
UTF-8
6,180
3.125
3
[]
no_license
#[derive(Debug, PartialEq, Clone)] struct Vec3 { x: i64, y: i64, z: i64, } #[derive(Debug, PartialEq, Clone)] struct Body { p: Vec3, v: Vec3, } fn calc_velocity_delta(a: &Vec3, b: &Vec3) -> Vec3 { let mut v = Vec3{ x: 0, y: 0, z: 0, }; if a.x < b.x { v.x = 1}; ...
true
a7066921a3e9523a9d51a0fd0a4ec832cb283391
Rust
kyleburton/sandbox
/examples/rust/book/macro_map_literal/src/main.rs
UTF-8
1,011
3.078125
3
[]
no_license
// https://doc.rust-lang.org/rustc-serialize/rustc_serialize/json/index.html extern crate rustc_serialize; use rustc_serialize::json; macro_rules! map( { $($key:expr => $value:expr),+ } => { { let mut m = ::std::collections::HashMap::new(); $( m.insert($key, $value); )+ m } ...
true
7390deea955eb3645047111e686f53a7f1b97137
Rust
brygga-dev/workdir2
/tools/rusc/src/main.rs
UTF-8
1,784
2.828125
3
[ "MIT" ]
permissive
mod file; mod item; mod stmt; mod expr; use std::path::{Path}; extern crate proc_macro2; use proc_macro2::TokenStream; use syn::{Result, Token}; use syn::Ident; use syn::token; use syn::parse::Parse; use syn::parse::ParseStream; use syn::parenthesized; use syn::punctuated::Punctuated; struct Js { stmts: Vec<Js...
true
d5342366d92ca81ac9d5a88e56737c7f2942f890
Rust
Type-3/rAdmin
/src/acl/auth.rs
UTF-8
2,828
3.03125
3
[]
no_license
use diesel::{PgConnection, SaveChangesDsl}; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use crate::acl::models::Account; use crate::types::PasswordType; use crate::ServerError; pub struct Auth; impl Auth { pub fn get_password_hash(conf: &rocket::Config) -> PasswordType { if let So...
true
36225372e15dbac949bdc3f7de18fbc356be3af3
Rust
silvadanilo/exercism
/rust/robot-name/src/lib.rs
UTF-8
630
3.328125
3
[]
no_license
extern crate rand; use rand::Rng; pub struct Robot { name: String, } impl Robot { pub fn new() -> Robot { Robot { name: Self::random_name() } } pub fn name<'a>(&'a self) -> &'a str { &self.name } pub fn reset_name(&mut self) { self.name = Self::random_name(); } ...
true
f2593bd60c3cbea3849a7e4d3000afe26e5387ac
Rust
jolestar/libra
/language/move-vm/types/src/loaded_data/types.rs
UTF-8
10,638
2.609375
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Loaded representation for runtime types. use libra_types::{ account_address::AccountAddress, vm_error::{StatusCode, VMStatus}, }; use move_core_types::{ identifier::Identifier, language_storage::{StructTag, TypeTag}...
true
5986fee3415dd2e4358c40bd8c68e12e6db03f37
Rust
karlmcguire/leet
/rust/419/main.rs
UTF-8
598
3.109375
3
[ "MIT" ]
permissive
struct Solution {} impl Solution { pub fn func(board: Vec<Vec<char>>) -> i32 { let mut c: i32 = 0; for i in 0..board.len() { for j in 0..board[i].len() { if (board[i][j] == 'X') && (i == 0 || board[i - 1][j] != 'X') && (j == 0 || bo...
true
f455e9cd82b22213fff9d88ea207acdd9f35adbe
Rust
jz4o/codingames
/rust/practice/classic_puzzle/easy/horse-racing-duals.rs
UTF-8
995
3.3125
3
[]
no_license
use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ fn main() { let mut input_line = String::new(); io::stdin().read_line(&mut input_lin...
true
555e1bf5600e305d425a40d317f1cbdb7ab45157
Rust
OpenByteDev/bf-rs
/src/traits.rs
UTF-8
2,075
3.109375
3
[ "MIT" ]
permissive
//! Contains the Interpretable trait, which provides a common interface for running a Brainfuck //! program. use std::io::{Cursor, Read, Write, stdin, stdout}; use common::BfResult; use state::State; pub use rle::RleCompilable; pub use peephole::PeepholeCompilable; pub use bytecode::BytecodeCompilable; #[cfg(feature...
true
5455ecc1ca14582bb3738a9a0aea374faaabb671
Rust
tadic-luka/ftracker
/src/utils.rs
UTF-8
1,023
2.703125
3
[ "MIT" ]
permissive
extern crate users; use std::path::Path; pub fn path_exists(path: &str) -> bool { Path::new(path).exists() } pub fn user_exists(user: Option<&String>) -> bool { user.map_or(true, |u| users::get_user_by_name(u).map(|_| true).unwrap_or(false)) } pub fn group_exists(group: Option<&String>) -> bool { group....
true
46c04df21ca341618973bb1d5a3dda3b2683587d
Rust
fan-tom/nsq-rs
/src/message.rs
UTF-8
2,635
3.21875
3
[ "MIT" ]
permissive
//! The message module contains a type that an nsqd instance writes on the wire for //! a single message. use std::io; use bytes::{BufMut, BytesMut}; use tokio_io::codec::Encoder; const BUFFER_GROW: usize = 1024; const SPACE_NEEDED: usize = 32; /// `Message` represents a message on the wire. #[derive(Builder, Debug)...
true
6cd1ab5e873b6f2f11df521177b23b3f3c8a3e1f
Rust
YusukeHosonuma/workspace
/Rust/tutorial/tutorial_4_34/src/main.rs
UTF-8
3,013
3.625
4
[]
no_license
// 4.34. マクロ fn main() { macro_rules! foo { (x => $e:expr) => (println!("mode X: {}", $e)); (y => $e:expr) => (println!("mode Y: {}", $e)); } foo!(y => 3); // Error: パターンにマッチしないのでコンパイルエラー // foo!(z => 3); // 繰り返し { macro_rules! o_O { ( ...
true
c3506fcf16d6bf5930590ee247a492950dbdd9b6
Rust
a2un/arrow
/rust/arrow/src/compute/kernels/concat.rs
UTF-8
9,285
2.859375
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause", "Zlib", "CC-BY-3.0", "CC0-1.0", "OpenSSL", "ZPL-2.1", "BSL-1.0", "NTP", "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "LicenseRef-scancode-public-domain", "JSON", "CC-BY-4.0", "LicenseRef-scancode-protobuf" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
c41c48bba1a92e712c5a0d4126cbcb164b48088e
Rust
jgillich/chill
/src/path/mod.rs
UTF-8
29,912
4
4
[ "MIT", "Apache-2.0" ]
permissive
//! Types and traits for specifying databases, documents, views, etc. //! //! Chill provides a rich set of types with which an application may specify //! CouchDB documents, views, attachments, and other database resources. By //! using special types—and not plain strings—the application programmer //! benefits from co...
true
ea1f0ed73e2aa875493acbebf243fc6687a9f916
Rust
automerge/automerge
/rust/automerge-c/src/obj.rs
UTF-8
5,435
2.765625
3
[ "MIT" ]
permissive
use automerge as am; use std::any::type_name; use std::cell::RefCell; use std::ops::Deref; use crate::actor_id::AMactorId; macro_rules! to_obj_id { ($handle:expr) => {{ match $handle.as_ref() { Some(obj_id) => obj_id, None => &automerge::ROOT, } }}; } pub(crate) use to...
true
6865de01a6f50adeec67ee08058679654b2c50bb
Rust
ABorse/ProgLang18
/tests/test_predicate.rs
UTF-8
2,175
3.21875
3
[]
no_license
#[cfg(test)] extern crate updated_scheme; use updated_scheme::predicate::*; use updated_scheme::evaluator::*; use updated_scheme::interpreter::*; use updated_scheme::lexer::Token; #[test] fn test_raw_predicate() { let expr_1 = Expression::Number(1.0); let expr_2 = Expression::Number(2.0); let expr_3 = ...
true
0dd172bb5742316691eab2591b762691ba4019fa
Rust
rsbt/rsbt
/_rsbt-app/src/tokio/tokio_mpsc_sender.rs
UTF-8
648
2.71875
3
[ "Unlicense", "MIT", "CC-BY-NC-ND-4.0" ]
permissive
use crate::types::Sender; use futures::{future::BoxFuture, FutureExt, TryFutureExt}; use std::fmt::Debug; pub struct TokioMpscSender<M>(pub(crate) tokio::sync::mpsc::Sender<M>); impl<M> Clone for TokioMpscSender<M> { fn clone(&self) -> Self { Self(self.0.clone()) } } impl<M> Sender<M> for TokioMpscSe...
true
f299398abcf597f3a0bded3b1d7a6a3252ac66ef
Rust
ChristophHaag/wyvern
/src/graphics/texturegl.rs
UTF-8
6,075
2.765625
3
[ "BSD-3-Clause" ]
permissive
// Copyright (c) 2016-2017 Bruce Stenning. All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // // 1. Redistributions of source code must retain the above copyright // notice, this list of co...
true
62555015a0b8567ecf6188cc2171ab20c62791bc
Rust
jiegec/rcore_plus
/kernel/src/drivers/irq/plic.rs
UTF-8
2,343
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
//! RISC-V plic use super::super::DRIVERS; use super::{super::IRQ_MANAGER, IntcDriver, IrqManager}; use crate::drivers::{ device_tree::DEVICE_TREE_INTC, device_tree::DEVICE_TREE_REGISTRY, DeviceType, Driver, }; use crate::memory::phys_to_virt; use crate::{sync::SpinNoIrqLock as Mutex, util::read, util::write}; use...
true
ed8f51ff18c0e1c6deff8088e893d0b4f53111e2
Rust
djc/AzureSDKForRust
/azure_sdk_cosmos/src/consistency_level.rs
UTF-8
2,844
2.71875
3
[ "Apache-2.0" ]
permissive
use crate::responses::{ CreateDocumentResponse, DeleteDocumentResponse, ExecuteStoredProcedureResponse, GetDocumentResponse, ListDocumentsResponse, QueryDocumentsResponse, ReplaceDocumentResponse, }; use serde::de::DeserializeOwned; use std::convert::From; #[derive(Debug, Copy, Clone, PartialEq)] pub enum Cons...
true
cc928358734382419f50c62cf82343178379133b
Rust
wolf1996/ws_battlecity
/src/app/message_manager.rs
UTF-8
2,115
2.578125
3
[]
no_license
extern crate ws; use self::ws::Sender as WsSender; use serde_json; use std::sync::mpsc::channel; use std::thread; use std::sync::mpsc; use app::room_manager::RoomsManager; use std::sync::RwLock; use std::collections::HashMap; use app::game::logic; use std::sync::Arc; use std::sync::Mutex; use std::sync::mpsc::{Sender,...
true
d0d218ae2823a34ca08c4d0f6598e700dd9cd5d6
Rust
pedantic79/Exercism
/rust/nucleotide-count/src/lib.rs
UTF-8
748
3.171875
3
[]
no_license
use std::collections::HashMap; const VALID: [char; 4] = ['A', 'C', 'G', 'T']; pub fn count(nucleotide: char, dna: &str) -> Result<usize, char> { let mut count = 0; for c in dna.chars() { valid_nucleotide(c)?; if c == nucleotide { count += 1; } } Ok(count) } pub fn...
true
69c11daf18c8656ada19ade5155304cfea4d6eab
Rust
owen8877/leetcode-rs
/src/problem_310.rs
UTF-8
1,067
3.203125
3
[]
no_license
pub fn find_min_height_trees(n: i32, edges: Vec<Vec<i32>>) -> Vec<i32> { if n == 1 { return vec![0]; } else if n == 2 { return vec![0, 1]; } use std::collections::*; let n = n as usize; let mut neighbours = vec![HashSet::new(); n]; for edge in &edges { neighbours[edg...
true
459d61d48348008d5f41f283b4a65dad7bb6da27
Rust
daniel-e/rustml
/src/octave.rs
UTF-8
7,074
3.53125
4
[]
no_license
extern crate num; use std::fmt; use std::fs::File; use std::io::{Write, Result}; use std::process::{Command, Output}; use std::iter::Iterator; use matrix::Matrix; static DEFAULT_OCTAVE_BIN: &'static str = "octave"; pub struct OctaveScriptBuilder { buf: Vec<String>, octave_bin: String } impl OctaveScriptBui...
true
cb9b14f52f117564c6386976d13665db06d12c26
Rust
DougLau/mag
/src/quan.rs
UTF-8
6,844
3.296875
3
[ "Apache-2.0", "MIT" ]
permissive
// quan.rs // // Copyright (C) 2021-2022 Douglas P Lau // use core::fmt; use core::marker::PhantomData; use core::ops::{Add, Div, Mul, Sub}; /// Measure of mass. /// /// Mass is a "base quantity", with units such as `kg` and `lb`. /// /// ## Example /// /// ```rust /// use mag::mass::{kg, lb}; /// /// let a = 2.5 * k...
true
b466bafe9e308d47772deadcd611647f06f87304
Rust
soseigocho/AoiChangChaos_rust
/merging_particle_filter/examples/sin_test.rs
UTF-8
1,632
2.53125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::BufWriter; use ndarray::*; use ndarray::Array; use rand::SeedableRng; use rand_distr::Normal; use rand_xoshiro::Xoshiro256StarStar; use merging_particle_filter::*; use read_and_write::*; const S:u64 = 801; const PS:f64 = 0.6; fn warn() { println!("You need 2 arg...
true
b5280274cedca571ae94f96497739424a3b6e1c7
Rust
afaur/artichoke
/artichoke-backend/src/extn/stdlib/securerandom/mod.rs
UTF-8
4,068
2.78125
3
[ "BSD-2-Clause", "MIT" ]
permissive
use rand::distributions::Alphanumeric; use rand::{self, Rng, RngCore}; use std::convert::TryFrom; use uuid::Uuid; use crate::extn::prelude::*; pub mod mruby; pub mod trampoline; const DEFAULT_REQUESTED_BYTES: usize = 16; #[cfg(test)] mod tests { fn rng_must_be_cryptographically_secure<T>(_rng: T) where ...
true
460802fa99a1b10170ecb75be370382a559a8be2
Rust
keleset/tt_str_fil
/src/tests.rs
UTF-8
1,829
3.4375
3
[ "MIT" ]
permissive
#[test] fn test_01_lat() { let test_string = String::from("teststststring"); assert_eq!(super::string_filter(&test_string), "stststst"); } #[test] fn test_02_lat() { let test_string = String::from("tesssssstststring"); assert_eq!(super::string_filter(&test_string), "sssssststst"); } #[test...
true
b8830e3e7ead21d7c901c40d2731f9bf7af63a16
Rust
rust-lang/rust-bindgen
/bindgen-tests/tests/expectations/tests/derive-hash-struct-with-incomplete-array.rs
UTF-8
3,106
2.5625
3
[ "BSD-3-Clause" ]
permissive
#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)] #[repr(C)] #[derive(Default)] pub struct __IncompleteArrayField<T>(::std::marker::PhantomData<T>, [T; 0]); impl<T> __IncompleteArrayField<T> { #[inline] pub const fn new() -> Self { __IncompleteArrayField(::std::marker::P...
true
3e8058ef14e49e900c99c3cd5fbda8f87d083d7d
Rust
BarbaraButz/jubilant-octo-computing-machine-pirfork
/sheet4/task2/calculator.rs
UTF-8
10,675
3.703125
4
[]
no_license
#[derive(Clone, Debug)] enum Token { Number(i32), Operator(Op), OpeningBracket, ClosingBracket, } impl Token { fn tokenize(string: &mut String) -> Result<Vec<Token>,InputError> { let mut tokens = Vec::new(); let mut number = -1; let mut digit = 0; while !string.is_em...
true
457763f91bb20382ccc08962e5324232a38d6c15
Rust
John-Nagle/rust-chrono
/src/offset.rs
UTF-8
22,918
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
// This is a part of rust-chrono. // Copyright (c) 2014-2015, Kang Seonghoon. // See README.md and LICENSE.txt for details. /*! * Offsets from the local time to UTC. */ use std::fmt; use stdtime; use {Weekday, Datelike, Timelike}; use div::div_mod_floor; use duration::Duration; use naive::date::NaiveDate; use naiv...
true
1d8234cb6087d05a07e420feca3e8669461f9693
Rust
mikialex/rendiation
/math/algebra/src/euler.rs
UTF-8
345
3.203125
3
[]
no_license
#[repr(C)] #[derive(Debug, Copy, Clone, Default, Hash, Eq, PartialEq)] pub struct Euler<T> { x: T, y: T, z: T, order: EulerOrder, } #[repr(C)] #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)] pub enum EulerOrder { XYZ, YXZ, ZXY, ZYX, YZX, XZY, } impl Default for EulerOrder { fn default() -> Se...
true
82c3f7a5e43c486572b56671d84631cec0923478
Rust
lachlansneff/typ
/tests/macro/fail_match_attribute.rs
UTF-8
1,178
2.765625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use typ::typ; pub trait AssertSame<Lhs, Rhs> { type Output; } impl<T> AssertSame<T, T> for () { type Output = (); } pub type AssertSameOp<Lhs, Rhs> = <() as AssertSame<Lhs, Rhs>>::Output; struct Alice<X>(X); struct Bob<X>(X); typ! { fn Compare<lhs, rhs>(lhs: _, rhs: _) { let lval = match lhs { ...
true
61e4c58a5645add807d8d1f9d2e038018cd634cb
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/crypto-bigint-0.3.2/src/uint/bit_or.rs
UTF-8
3,643
3.203125
3
[ "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
//! [`UInt`] bitwise or operations. use super::UInt; use crate::{Limb, Wrapping}; use core::ops::{BitOr, BitOrAssign}; use subtle::{Choice, CtOption}; impl<const LIMBS: usize> UInt<LIMBS> { /// Computes bitwise `a & b`. #[inline(always)] pub const fn bitor(&self, rhs: &Self) -> Self { let mut limb...
true
b21a415259607d7123a8202554b57d0a245185b7
Rust
xd009642/tarpaulin
/src/report/safe_json.rs
UTF-8
2,616
3.59375
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use serde_json::ser::CharEscape; use serde_json::ser::CompactFormatter; use std::default::Default; use std::io; struct SafeFormatter(CompactFormatter); impl Default for SafeFormatter { fn default() -> Self { SafeFormatter(CompactFormatter) } } impl serde_json::ser::Formatter for SafeFormatter { f...
true
29a249041707a313096b44b4540a5a7f8f252e65
Rust
ageiersbach/cmdr-log-cli
/src/events/mod.rs
UTF-8
2,361
2.78125
3
[]
no_license
use chrono::prelude::*; use serde_json::*; use std::io; pub mod limpets; pub mod missions; pub mod location; pub mod cargo; pub use self::limpets::*; pub use self::missions::*; pub use self::location::*; pub use self::cargo::*; use chrono::{DateTime, Utc}; #[derive(Serialize, Deserialize, Debug)] pub struct PlayerJ...
true
bf20f9fda88e71e20c3fb187163d5d994fa50565
Rust
m-ou-se/conftaal-rust
/src/parse/end.rs
UTF-8
4,025
3.578125
4
[ "BSD-2-Clause" ]
permissive
use std::fmt::Write; use super::consume::Consume; use super::error::{error, Error, Message}; use super::whitespace::skip_whitespace; /// Determines until what point should be parsed. /// An value of this type is given to the `parse_*` functions. #[derive(Clone, Copy)] pub enum End<'a> { /// Don't stop till the en...
true