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
462ddd2e96328fe4c84c5b21432cd6687a2615b2
Rust
StoriqaTeam/payments-gateway
/src/models/receipt.rs
UTF-8
377
2.765625
3
[]
no_license
use uuid::Uuid; #[derive(Deserialize, Serialize, Clone, PartialEq, Eq, Hash, Debug)] #[serde(rename_all = "camelCase")] pub enum ReceiptType { Account, Address, } #[derive(Deserialize, Serialize, Clone, PartialEq, Eq, Hash, Debug)] pub struct Receipt(String); impl Default for Receipt { fn default() -> Se...
true
888cf8955c8d193a1d4852648096d55963df1990
Rust
peterhj/extar
/src/lib.rs
UTF-8
4,219
2.765625
3
[ "BSD-2-Clause" ]
permissive
#![feature(align_offset)] use std::ffi::{CStr}; use std::io::{Read, Seek, SeekFrom}; use std::mem::{align_of, size_of}; use std::path::{PathBuf}; use std::slice::{from_raw_parts}; use std::str::{from_utf8}; const BLOCK_SZ: u64 = 512; fn cast_bytes_as_u32_slice(buf: &[u8]) -> &[u32] { assert_eq!(0, buf.as_ptr().ali...
true
95253fa937bcb4b1770cada1a28b8c38cade230f
Rust
simon-auch/rust_GrandiOS
/GrandiOS/src/driver/system_timer.rs
UTF-8
3,783
2.921875
3
[]
no_license
//Dokumentation: S.305 use core::ptr::{read_volatile, write_volatile}; use core::u16; pub const ST_BASE_ADDRESS : u32 = 0xFFFF_FD00; static mut SYSTEM_TIMER: Option<STController> = None; pub unsafe fn init(){ SYSTEM_TIMER = Some(STController::new(ST_BASE_ADDRESS)); } pub unsafe fn get_system_timer...
true
e21961e70f48a46a41d5a97cb2bdf4d6ae73b9df
Rust
paul-schaaf/legal_chess
/src/pieces/pawn.rs
UTF-8
22,051
2.890625
3
[]
no_license
use super::position; use super::{piece, piece::Piece, piece::PieceEnum}; use crate::{board, chessmove, color}; #[derive(Debug, PartialEq)] pub struct Pawn { pub position: position::Position, pub color: color::Color, } impl piece::Piece for Pawn { fn piece(&self) -> piece::PieceEnum { piece::PieceE...
true
2b751d88f74feb17025afe7a1c47093324f0d2d1
Rust
GINK03/atcoder-solvers
/abc033_a.rs
UTF-8
497
3.015625
3
[]
no_license
use std::io::{self, Read}; use std::io::prelude::*; use std::collections::BTreeSet; use std::collections::HashSet; fn main(){ let stdin = std::io::stdin(); let mut it = stdin.lock().lines(); //let mut bs = BTreeSet::new(); let mut s:HashSet<char> = HashSet::new(); let a = &it.next().unwrap().unwrap()...
true
aedcf9e9610f6e9257b62a44e783f455dc17e626
Rust
willcrichton/cauldron
/cauldron/tests/cur.rs
UTF-8
252
2.53125
3
[]
no_license
#![feature(proc_macro)] extern crate cauldron; use cauldron::auto_gc; use std::rc::Rc; #[test] fn closure() { auto_gc! { let x = 1; let y = |a: i32, b: i32| { x + a + b }; let z = y(x, 1); }; assert_eq!(z, 3); }
true
f60c12e8b122c5fc8564b213fff6f21e1885e602
Rust
mjkaufer/Project-Euler
/rust/007.rs
UTF-8
540
3.71875
4
[]
no_license
fn main(){ let mut count: u32 = 1; let mut num: u64 = 1; let mut primes: Vec<u64> = Vec::new(); primes.push(2); // for i in 3..50{ // let b: bool = vectorIsPrime(i, &primes); // if b{ // primes.push(i); // } // println!("{},{}", i,b); // } while count < 10001{ num += 2; if vectorIsPrime(num, ...
true
b591d455470477b582a43de64bcabcdf3cdaf5c1
Rust
cskd8/monkey-r
/src/lexer/lexer.rs
UTF-8
4,120
3.390625
3
[]
no_license
use crate::token::token::*; #[derive(Debug)] pub struct Lexer<'a> { input: &'a str, position: usize, read_position: usize, ch: u8, } impl<'a> Lexer<'a> { pub fn New(input: &'a str) -> Self { let mut l = Self { input, position: 0, read_position: 0, ...
true
82066849ea3c04a2a82a368ca1fa3ed6fad5c0cc
Rust
LuciEngine/Lucien
/render/src/depth_texture.rs
UTF-8
1,613
2.859375
3
[]
no_license
use std::sync::Arc; #[derive(Debug)] pub struct DepthTexture { pub texture: Arc<wgpu::Texture>, pub size: wgpu::Extent3d, pub view: wgpu::TextureView, pub sampler: wgpu::Sampler, } impl DepthTexture { pub fn new(device: &wgpu::Device, width: u32, height: u32, label: Option<&str>) -> Self { ...
true
a5c11911a89a35608c0de1dfb1873a93b1486d52
Rust
rstevenson555/helm_foil
/src/installcommand.rs
UTF-8
1,807
2.609375
3
[]
no_license
use std::process::{Command as ProcessCommand, Stdio}; use crate::command::Command; use crate::helmruntime::HelmRuntime; use clap::ArgMatches; pub(crate) struct InstallCommand<'a> { helm_runtime: &'a mut HelmRuntime, } impl<'a> InstallCommand<'a> { pub(crate) fn new(execute_helm_command: &'a mut HelmRuntime) ...
true
fdbffc48481236b12bf0c680d83b60f7240a4534
Rust
gcnhax/bmd-rs
/src/sections/evp1.rs
UTF-8
699
2.71875
3
[]
no_license
use byteorder::{ReadBytesExt, BE}; use std::io::{Read, Seek, SeekFrom}; use crate::error::Error; use crate::util::SeekExt; pub struct Evp1 {} impl Evp1 { pub fn parse<R>(r: &mut R) -> Result<Evp1, Error> where R: Read + Seek, { let section_begin_offset = r.whereami()?; // assert ...
true
739f27c374ecfff09eff3f4aed339eea78c59abb
Rust
DouliDev/rustacean
/src/commands/exec/lua.rs
UTF-8
698
2.625
3
[]
no_license
use std::path::PathBuf; use commands::exec::language::Language; use duct::{ cmd, Expression }; #[derive(Debug)] pub struct Lua; impl Lua { fn get_interpreter(&self) -> String { if cfg!(windows) { "lua53".into() } else { "lua5.3".into() } } } impl Language for ...
true
eb06bfefc240b8fe75e477ed32787e72b8ee3412
Rust
Liby99/llir
/src/values/constant/vector.rs
UTF-8
1,402
2.828125
3
[ "MIT" ]
permissive
use llvm_sys::core::{LLVMGetNumOperands, LLVMGetOperand}; use llvm_sys::prelude::LLVMValueRef; use std::marker::PhantomData; use crate::types::*; use crate::values::*; use crate::*; /// [Vector Constant](https://llvm.org/docs/LangRef.html#complex-constants) #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struc...
true
022b165e487bf016c0e25c3da23860c92c3e960a
Rust
olly/redirect.zone
/src/handler.rs
UTF-8
1,743
2.734375
3
[]
no_license
use iron::headers; use iron::middleware::Handler; use iron::prelude::*; use iron::status; use url::Host; use url::Host::Domain; use redirector::Redirector; use redirector::RedirectorError; macro_rules! bad_request( ($text:tt) => {{ return Ok(Response::with((status::BadRequest, format!("400 Bad Request: {}...
true
57899ea460c6f85d17aafd4236721b0096b05464
Rust
nilsmartel/calender
/src/util.rs
UTF-8
1,589
3.265625
3
[]
no_license
use crate::Weekday; pub fn days_of_month(year: u16, month: u16) -> u16 { if month == 2 { return days_of_feb(year); } match month { 1 | 3 | 5 | 7 | 8 | 10 | 12 => 31, _ => 30 } } fn is_leap_year(year: u16) -> bool { ((year % 4 == 0) && (year % 100!= 0)) || (year%400 == 0) }...
true
ceb9c49dc6fb832d6f2d35d8b08955efc8c42313
Rust
dseevr/assassin
/src/assassin/feeds/discount_option_data.rs
UTF-8
3,829
2.84375
3
[ "BSD-3-Clause" ]
permissive
use std::io::BufReader; use std::io::BufRead; use std::fs::File; use assassin::quote::Quote; use assassin::traits::*; extern crate chrono; use self::chrono::prelude::*; extern crate greenback; use greenback::Greenback as Money; pub struct DiscountOptionData { enumerator: BufReader<File>, line: String, } im...
true
db9a101705f3448d280cb22b204613c51389b606
Rust
MoritzKn/nd-raytracer
/web/src/color.rs
UTF-8
3,086
3.203125
3
[]
no_license
use ndrt_lib::Float; use wasm_bindgen::prelude::*; pub type ColorInt = [u8; 4]; #[wasm_bindgen] #[derive(Debug, Clone, Copy, PartialEq)] pub struct Color { pub(crate) array: [Float; 4], } #[wasm_bindgen] impl Color { pub fn rgba(r: Float, g: Float, b: Float, a: Float) -> Self { Self { ar...
true
09d741f6dcc3fd63af56035447ead60fa8e2b1c5
Rust
TerryOShea/rust-exercism
/sum-of-multiples/src/lib.rs
UTF-8
913
3.546875
4
[]
no_license
fn sum_of_multiple(limit: u32, factor: u32) -> u32 { let biggest_factor_multiple = if limit % factor > 0 { limit - (limit % factor) } else { limit - factor }; (biggest_factor_multiple * (biggest_factor_multiple + factor)) / (2 * factor) } pub fn sum_of_multiples(limit: u32, factors: &[u...
true
722bff1ca878d605a7c4d0ab4876dfd20de4e626
Rust
GryphonClaw/mysteriousbot
/src/mysterious_message_handler.rs
UTF-8
775
2.984375
3
[ "BSD-2-Clause" ]
permissive
use serenity::model::channel::Message; use serenity::prelude::Context; use std::error::Error; pub type MMHResult<T> = Result<T, Box<dyn Error>>; pub trait MysteriousMessageHandler : Send + Sync { /// Tells whether this event handler is "exclusive," which is to say that, /// when an event matches this handler...
true
973769f7220196daa04d8bd0e8900483d011280a
Rust
yukihane/hello-rust
/202103実践Rustプログラミング入門/01-03/trait/src/main.rs
UTF-8
768
3.671875
4
[]
no_license
fn main() { let dog = Dog {}; let cat = Cat {}; show_animal_data(dog); show_animal_data(cat); } fn show_animal_data<T: Animal>(animal: T) { println!("Lifespan: {} years", animal.lifespan()); println!("Scientific name: {}", animal.scientific_name()); } trait Animal { // 寿命を返す fn lifesp...
true
39b687542dc894f3d00f14b1942fd5c3c89f4767
Rust
arturomf94/cryptopals
/set1/chal1/src/main.rs
UTF-8
534
2.78125
3
[]
no_license
extern crate base64; extern crate hex; use base64::encode; use hex::decode; fn hex2base64(hex: &str) -> String { let bytes = decode(hex).expect("Invalid hex string"); encode(bytes) } fn main() { let hex = "49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d"; ...
true
3452fce36db31ec194829b5e794936d811175d92
Rust
davidszotten/advent-of-code-2018
/src/bin/day25.rs
UTF-8
2,967
3.15625
3
[]
no_license
use aoc2018::{dispatch, Result}; use std::collections::HashMap; fn main() { dispatch(&part1, &part2) } #[derive(Debug, PartialEq, Eq, Clone, PartialOrd, Ord)] struct Point { x: i32, y: i32, z: i32, w: i32, } impl Point { fn distance(&self, other: &Point) -> i32 { (other.x - self.x).ab...
true
a4aa1547c559627a52e8f58631d5644165d4290b
Rust
CerulanLumina/sqpack
/tests/integration.rs
UTF-8
3,529
2.703125
3
[ "Apache-2.0" ]
permissive
extern crate md5; extern crate sqpack; extern crate walkdir; const FFXIV_SQPACK_PATH: &'static str = "FFXIV_SQPACK_PATH"; use sqpack::{io::index::IndexReader, SqPath}; use std::{ collections::HashMap, env, fs::{File, FileType}, io::{BufRead, BufReader, Read}, }; fn get_env_vars() -> HashMap<String, S...
true
171959f41ede78ff404b5c1a8f41005d66c62adc
Rust
ipetkov/conch-parser
/tests/case.rs
UTF-8
12,984
2.6875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![deny(rust_2018_idioms)] use conch_parser::ast::builder::*; use conch_parser::parse::ParseError::*; use conch_parser::token::Token; mod parse_support; use crate::parse_support::*; #[test] fn test_case_command_valid() { let correct = CaseFragments { word: word("foo"), post_word_comments: vec![], ...
true
939ff124545183445da673c27bd54384c1d393f1
Rust
MitinPavel/http_event_store
/src/lib.rs.in
UTF-8
2,770
2.96875
3
[ "MIT" ]
permissive
pub mod write { use serde_json; use uuid::Uuid; #[derive(Serialize, Deserialize, Debug)] pub struct Event { #[serde(rename = "eventId")] pub event_id: Uuid, #[serde(rename = "eventType")] pub event_type: String, #[serde(skip_serializing_if = "Option::is_none")] ...
true
f50ede7dd457315791b008fd3b348c1cd3f94c8d
Rust
xiaolongn100/fselect
/src/util/mod.rs
UTF-8
11,042
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
mod top_n; mod wbuf; use std::cmp::Ordering; use std::error::Error; use std::fmt::Display; use std::io; use std::path::Path; use std::rc::Rc; use std::string::ToString; use chrono::DateTime; use chrono::Duration; use chrono::Local; use chrono::LocalResult; use chrono::TimeZone; use chrono_english::{parse_date_string,...
true
e382aebbe2ee5b539fa68c1b8887cfc9c6c576d3
Rust
Romchik38/HPW-Labs-Rust
/Labs-2019/Reusable/6-square.rs
UTF-8
150
3.171875
3
[]
no_license
fn main() { let x: i32 = 10; let s1: i32 = square(10); println!("square from {} is {}", x, s1); } fn square(x: i32) -> i32 { x * x }
true
37ccc3890245c97dd32332ba8ae7c5af8e3865bc
Rust
6174/three-d
/src/core/cpu_mesh.rs
UTF-8
3,137
3.09375
3
[ "MIT" ]
permissive
use crate::core::*; #[derive(Default, Debug)] pub struct CPUMesh { pub name: String, pub material_name: Option<String>, pub positions: Vec<f32>, pub indices: Option<Vec<u32>>, pub normals: Option<Vec<f32>>, pub uvs: Option<Vec<f32>> } impl CPUMesh { pub fn compute_normals(&mut self) { ...
true
0a94aac003eb1c4f786afea384f1ec88fd679518
Rust
mrobakowski/mulperc
/src/gzip.rs
UTF-8
1,879
2.953125
3
[]
no_license
extern crate flate2; extern crate libc; use self::flate2::read::GzDecoder; use std::fs::File; use std::io::Read; use std::io; use self::libc::*; use std::mem; /// Struct to decompress gzip streams. pub struct GzipData { v: Vec<u8>, idx: usize } impl GzipData { pub fn from_file(fname: &str) -> Result<Gzip...
true
fc97ba8563da97ac4f32b167512e26b378e39f10
Rust
ev-wilt/advent-of-code-2018
/day_2/src/main.rs
UTF-8
1,630
3.5625
4
[]
no_license
use std::io::{self, BufRead}; fn part_one() { let stdin = io::stdin(); let mut threes = 0; let mut twos = 0; for line in stdin.lock().lines() { let mut has_two = false; let mut has_three = false; let id = line.unwrap(); // Iterate through each char and count the ...
true
09815555fe287bf8715403afb0d51a5e20d676fa
Rust
13h3r/highloadcup
/src/database.rs
UTF-8
2,913
3.03125
3
[]
no_license
use std::collections::{HashMap, BTreeMap}; use std::error::Error; use std::path::Path; use std::fs::File; use std::fmt::Display; use std::io::Read; use serde_json; use zip::ZipArchive; use data::*; #[derive(Default)] pub struct Database { pub users: HashMap<UserId, User>, pub locations: HashMap<LocationId, L...
true
9a916ce0c139fe8eac4c9812cfddfa285b620ca7
Rust
tversteeg/commentective
/src/language/bash.rs
UTF-8
1,425
3
3
[ "MIT" ]
permissive
use language; use language::FindResult; use std::fs::File; use std::io::Error; use std::io::ErrorKind; use std::path::Path; use utils::comments::find_comments; use utils::comments::MultiCommentOpts; use utils::path::filename; use utils::string::s; use utils::string::string_contains_any_of; #[derive(Debug)] pub struct ...
true
917bb857a8a775d10ac650cc6cf2fa9f6f171891
Rust
gqf2008/longan-nano
/src/epd27b.rs
UTF-8
6,311
2.578125
3
[ "ISC" ]
permissive
use embedded_hal::blocking::delay::DelayMs; use embedded_hal::blocking::spi::Write; use embedded_hal::digital::v2::*; use gd32vf103xx_hal::gpio::gpioa::PA4; use gd32vf103xx_hal::gpio::gpioa::PA5; use gd32vf103xx_hal::gpio::gpioa::PA6; use gd32vf103xx_hal::gpio::gpioa::PA7; use gd32vf103xx_hal::gpio::gpiob::PB0; use gd3...
true
7072f4dff12bb378ee3b00247bb9d327137e0583
Rust
digitalbitbox/bitbox02-firmware
/src/rust/vendor/digest-0.9.0/src/dev.rs
UTF-8
6,836
2.875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Development-related functionality pub use blobby; use super::{ExtendableOutput, Reset, Update, VariableOutput, XofReader}; use core::fmt::Debug; /// Define test #[macro_export] #[cfg_attr(docsrs, doc(cfg(feature = "dev")))] macro_rules! new_test { ($name:ident, $test_name:expr, $hasher:ty, $test_func:ident) ...
true
189b616109454a48337038174b0a4519fd2638b1
Rust
isabella232/advent-of-code-2016
/src/day_12.rs
UTF-8
4,950
3.21875
3
[]
no_license
#![allow(dead_code)] use std::{error::Error, str::FromStr}; use regex::Regex; #[derive(Debug, Copy, Clone, PartialEq, Eq)] enum Register { A, B, C, D, } impl FromStr for Register { type Err = Box<dyn Error>; fn from_str(line: &str) -> Result<Self, Self::Err> { let result = match line { "a" => ...
true
977c8df83c9ad4f2f271eb10dabb226d9af316d1
Rust
mindfulvector/hsctl
/src/main.rs
UTF-8
6,593
2.671875
3
[ "MIT" ]
permissive
extern crate clap; #[macro_use] extern crate prettytable; #[macro_use] extern crate serde_derive; use clap::{App, Arg, SubCommand}; mod api; mod device; mod http; mod output; fn main() { let matches = App::new("hsctl") .about("A CLI tool for interacting with HomeSeer") .version("0.1") .a...
true
164339fc9864886256f5912a9e847fdaa88d0763
Rust
jinlf/wukong
/src/compiler.rs
UTF-8
20,615
2.5625
3
[]
no_license
use crate::ast; use crate::wasm; pub static ENTRY_POINT: &str = "main"; #[derive(Clone)] struct VarInfo { localidx: u32, closure_typeidx: wasm::TypeIdx, } pub struct Compiler { pub module: wasm::Module, mem_pos: u32, elem_offset: u32, } impl Compiler { pub fn compile_program(&mut self, progra...
true
3489a6ea6316c9b3f669b9dc64cacfda070709cd
Rust
heartpunk/datastructures.rs
/stack.rs
UTF-8
692
3.59375
4
[]
no_license
#[deriving(Eq, ToStr)] enum Chain<T> { Link(T, ~Chain<T>), Break } // this is lies memory usage wise, it's really a linked list. I should rename it. trait MutStack<T> { fn push(self, item : T) -> ~Self; fn pop(self) -> Option<T>; fn new() -> Self; } impl<T> MutStack<T> for Chain<T> { fn push(...
true
5a9a2bcc9b4800d97c74744aca47630511769e6c
Rust
EqualMa/forward
/lib/forward/src/socks5/auth.rs
UTF-8
1,416
2.859375
3
[]
no_license
use std::io; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; pub async fn password_authentication<S: AsyncRead + AsyncWrite + Unpin>( socket: &mut S, username: &str, password: &str, ) -> io::Result<()> { if username.len() < 1 || username.len() > 255 { return Err(io::Error::...
true
609410159d9d4ab42f409adf84207fefe86c0f90
Rust
jaynus/balls
/game/core/src/camera.rs
UTF-8
3,289
2.90625
3
[]
no_license
use crate::{ math::{self, geometry::Ray, Mat4, Vec2, Vec3}, transform, }; use legion::prelude::*; #[derive(Clone, Copy)] pub struct CameraQueryResult { pub camera: Camera, pub translation: transform::Translation, pub scale: transform::Scale, } pub type CameraQueryFn = Box<dyn FnMut(&World) -> Came...
true
100e1b50cc032af2f7daa3e08bcecac023d46dfe
Rust
canova/profiler-get-symbols
/src/pdb.rs
UTF-8
3,001
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::error::{GetSymbolsError, Result}; use compact_symbol_table::CompactSymbolTable; use pdb_crate::{FallibleIterator, ProcedureSymbol, PublicSymbol, SymbolData, PDB}; use std::borrow::Cow; use std::collections::HashMap; use std::io::Cursor; fn annotate(invocation_description: &'static str) -> impl Fn(pdb::Error...
true
aa1fc33db8154017c32a8472ec39cda47c85ecc7
Rust
sayrer/rust
/src/test/run-pass/lib-ivec.rs
UTF-8
5,239
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "BSD-1-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "MIT", "BSD-2-Clause", "bzip2-1.0.6" ]
permissive
// xfail-stage0 use std; import std::ivec; import std::option::none; import std::option::some; fn square(uint n) -> uint { ret n * n; } fn square_alias(&uint n) -> uint { ret n * n; } pred is_three(&uint n) -> bool { ret n == 3u; } fn test_reserve_and_on_heap() { let int[] v = ~[ 1, 2 ]; assert (!ivec::on_...
true
571cf881601c64f4f2e2b88567093f222f2062b8
Rust
Lpwsm/Rust
/rust_learning/src/variables.rs
UTF-8
238
3.109375
3
[]
no_license
// variables.rs fn main(){ let mut tartget = "world"; let mut greeting = "Hello"; println!("{}, {}", greeting, tartget); greeting = "How are you doing"; tartget = "mate"; println!("{}, {}", greeting, tartget); }
true
431bede1313a7778eb00bff2c110053d7a01110b
Rust
yutiansut/Waffle
/src/runtime/config.rs
UTF-8
2,400
2.703125
3
[ "Apache-2.0" ]
permissive
use structopt::StructOpt; #[derive(StructOpt, Clone)] #[structopt(name = "waffle")] pub struct Config { #[structopt(name = "FILE", parse(from_os_str))] pub main_name: Option<std::path::PathBuf>, #[structopt( long = "perm-size", help = "Permanent heap size (default 1024 * 8 * 2)", de...
true
183a785230e2bbef84555bcdac7d55b83b843c65
Rust
yshalenyk/byteserver
/src/index.rs
UTF-8
2,069
2.796875
3
[ "MIT" ]
permissive
// File-storage index-file and mmap index use std::collections::btree_map::BTreeMap; use util::*; pub type Index = BTreeMap<Oid, u64>; static MAGIC: &'static [u8] = b"fs2i"; pub fn save_index(index: &Index, path: &str, segment_size: u64, start: &Tid, end: &Tid) -> io::Result<()> { ...
true
d8ae9316456f238b70625748010f5d4e11442dab
Rust
mattlknight/rust-win32-bindgen
/src/features/archs.rs
UTF-8
2,170
2.90625
3
[ "MIT" ]
permissive
/*! Defines the Architectures feature set component. */ use std::fmt; bitflags! { /** A bit vector of all possible target architectures. */ flags Architectures: u8 { const None = 0b000, const Bits64 = 0b010, const X86_32 = 0b001, const X86_64 = 0b010, ...
true
e37f4124e47c482167762c35123b5d5b24cce1fb
Rust
ansome22/Ansome-AI-Collection
/src/pathfinding/Heuristic.rs
UTF-8
355
3.078125
3
[]
no_license
pub struct Heuristic{ // Stores the goal node that this heuristic is estimating for. goalNode: Node } // Estimated cost to reach the stored goal from the given node. fn estimate(fromNode: Node) -> f64{ return estimate(fromNode, goalNode) } // Estimated cost to move between any two nodes. fn estimate(fro...
true
335b12c8554ee779661098d99b85654307c4bc1e
Rust
daboross/rust-screeps-api
/src/websocket/types/room/objects/mod.rs
UTF-8
6,697
2.84375
3
[ "MIT" ]
permissive
//! Room object parsing. //! //! If you just want to use the module, reading the rustdocs documentation is very recommended. //! All types generated with macros will also have documentation for them available. //! //! Reading the source code is definitely possible. But there may be some investment in reading //! each o...
true
7e6d6de6f32508e46fccc1fb470d3c14f672c83c
Rust
iCodeIN/lpfx-rs
/src/devices/launchpad.rs
UTF-8
2,118
2.734375
3
[ "MIT" ]
permissive
// launchpad.rs // rewrite from original to add support for Traits use crate::traits::*; use crate::devices::device::*; use crate::aliases::*; pub struct Launchpad { pub device: DeviceT, } impl Launchpad { pub fn new(name: &str) -> Result<Launchpad, String> { match DeviceT::new(name) { Err(e) => { ret...
true
daca27f43452074e227abc1f78ccdf3677121321
Rust
kdy1/rweb
/macros/src/openapi/mod.rs
UTF-8
15,501
2.59375
3
[ "Apache-2.0" ]
permissive
//! //! //! //! # Rules //! //! - We abuse `Parameter.ref_path` to store type name. pub use self::derive::derive_schema; use crate::{ parse::{Delimited, Paren}, path::find_ty, route::EqStr, }; use pmutil::{q, Quote, ToTokensExt}; use proc_macro2::TokenStream; use quote::ToTokens; use rweb_openapi::v3_0::{...
true
7df8623e5ddcc9a12583ec02ec4843c2ee3ef810
Rust
shaoxp/hello_rust
/generic/src/main.rs
UTF-8
1,096
3.6875
4
[ "MIT" ]
permissive
fn main() { let v = vec![23,432,34,50,098]; let v2 = vec![3,4,5,9,10,2]; let c1 = vec!['a','g','e','f']; let c2 = "abcdefg"; println!("largest:{}",largest(&v[2..])); println!("largest:{}",largest(&v2[..4])); println!("largest:{}",largest(&c1)); // println!("largest:{}",largest(&Strin...
true
8ef01c0d0ff7204bda3cf1f66e19c394672b846e
Rust
TyOverby/rust-graphics
/src/relative_source_rectangle.rs
UTF-8
2,163
3.09375
3
[ "MIT" ]
permissive
use vecmath::{ relative_source_rectangle, }; use internal::{ CanSourceRectangle, HasSourceRectangle, SourceRectangle, }; /// Should be implemented by contexts that /// have source rectangle information. pub trait RelativeSourceRectangle<'a, T> { /// Adds a source rectangle. fn src_rect(&'a sel...
true
aae4dd2614304d9afefb4e79e55c4fd1d1eccbc5
Rust
charlieyqin/optimal-image
/src/optimal_image/compress/image.rs
UTF-8
5,808
2.609375
3
[]
no_license
extern crate image; extern crate imgref; extern crate libc; extern crate rgb; use dataclients::ImageData; use std::error::Error; use std::ffi::{CStr, CString}; use std::marker::PhantomData; use std::os::raw::{c_char, c_void}; use std::ptr::null; use std::slice; use vips; const NULL_LIST: *const c_char = null() as *con...
true
85adee2e3088a9c99bdde0c8622319cd0bde17f5
Rust
micakce/rs_the_book
/src/main.rs
UTF-8
2,322
2.78125
3
[]
no_license
use std::{io, process}; use eight::{add_employees::add_employee_ti, pig_latim::str2pig_latim}; use nine::panico; mod eight; mod nine; mod closures; fn main() { // eight::init_shit(); // eight::vectors::vector_indexes(); // println!("Hello, world!"); // let data = vec![1,2,3,4,5,6,7,8]; // print...
true
a9bcfedcd6efcf9c1126d71548cc4037a374a9d9
Rust
eshikafe/relayd-rs
/src/config/expand.rs
UTF-8
4,420
3.0625
3
[ "ISC" ]
permissive
use crate::config::{ parser::{comment, line, quoted, string, CResult}, Variable, Variables, }; use nom::{ branch::alt, bytes::complete::{is_not, tag}, character::complete::{char, multispace1}, combinator::{map, opt}, error::{VerboseError, VerboseErrorKind}, multi::many0, sequence::{p...
true
abbcb26e97a0e08c0ac9565fab0e0a0c15ba8d7f
Rust
joshleeb/unitval
/unitval-derive/src/precond.rs
UTF-8
1,064
2.59375
3
[]
no_license
use proc_macro2::TokenStream; use quote::quote_spanned; pub fn unit_enum(data: &syn::Data) -> Result<&syn::DataEnum, TokenStream> { match data { syn::Data::Enum(enum_data) => { all_unit_variants(&enum_data)?; Ok(enum_data) } syn::Data::Struct(struct_data) => Err(quot...
true
70a79ff63393b98f3b4b3ab9377dbd8f1171662d
Rust
mre/bn
/src/fields/fp.rs
UTF-8
6,152
3.171875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use rand::Rng; use std::ops::{Add, Sub, Mul, Neg}; use std::fmt; use std::marker::PhantomData; use super::FieldElement; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; use arith::U256; pub trait FpParams { fn name() -> &'static str; fn modulus() -> U256; fn inv() -> u64; fn rsquared() ...
true
9aa96b0ecdf1631d726162797c3bd7d77243f03a
Rust
bmitchelmore/aoc2020
/src/day16/mod.rs
UTF-8
5,864
2.953125
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::ops::RangeInclusive; use std::collections::{HashMap,HashSet}; use super::Day; #[derive(Debug, Clone)] pub struct TicketRule { name: String, valid_ranges: Vec<RangeInclusive<u64>> } #[derive(Debug)] pub struct TicketInfo { rules: ...
true
ae61738e4233552983caab9699ebfeb32a64dfd8
Rust
CryptoPandas/cryptopandasdb
/slpdexdb_base/src/errors.rs
UTF-8
3,049
2.640625
3
[]
no_license
use diesel::data_types::PgNumeric; #[derive(Debug)] pub enum SLPError { NotSLPSafe, // SLP ops must be bigger than 0x00 and less than 0x4f TooFewPushops(usize), // SLP output must have at least 6 pushops TooManyAmounts(usize), // SLP output must have at most 19 outputs InvalidSLPType(String), In...
true
39576c12996b4e7e2fa47a694cfbdb524e4ad6f8
Rust
sshyran/thruster-grpc
/src/error.rs
UTF-8
2,040
2.765625
3
[]
no_license
use thruster::errors::ThrusterError as Error; use crate::context::ProtoContext as Ctx; use crate::status::ProtoStatus; pub trait ProtoErrorSet { fn already_exists_error(context: Ctx) -> Error<Ctx>; fn parsing_error(context: Ctx, error: &str) -> Error<Ctx>; fn generic_error(context: Ctx) -> Error<Ctx>; ...
true
7639179725b1ce42429dff3effe00abdbccda2b8
Rust
pagino/pagino-rust
/src/lib.rs
UTF-8
3,993
3.21875
3
[ "MIT" ]
permissive
const FIRST: i32 = -1; const PREVIOUS: i32 = -2; const START_ELLIPSIS: i32 = -3; const END_ELLIPSIS: i32 = -4; const NEXT: i32 = -5; const LAST: i32 = -6; pub struct Pagino { pub show_first: bool, pub show_previous: bool, pub show_next: bool, pub show_last: bool, pub page: i32, pub count: i32, pub siblin...
true
517d70190d6000d8fca27737a4467e9556cf2cc3
Rust
ReedOei/SetTheory
/set_lang/src/math.rs
UTF-8
12,296
3.203125
3
[]
no_license
use num_bigint::{BigInt, ToBigUint}; use num_traits::{Zero, One, Pow}; use std::collections::{BinaryHeap, HashSet, HashMap, VecDeque}; use std::cmp::{max, Ordering}; use std::hash::Hash; use std::ops; use std::fmt; use crate::ast::{AST, as_int}; pub fn to_usize(n : &BigInt) -> Result<usize, String> { match ToBig...
true
cb1cb53c606a0427556b132452ea52e8f9d4812a
Rust
chrissimpkins/measureme
/analyzeme/src/lightweight_event.rs
UTF-8
2,435
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::event::Event; use crate::profiling_data::ProfilingData; use crate::timestamp::Timestamp; use std::hash::{Hash, Hasher}; use std::time::Duration; #[derive(Clone, Debug)] pub struct LightweightEvent<'a> { pub data: &'a ProfilingData, pub event_index: usize, pub thread_id: u32, pub timestamp: T...
true
34c6c5993d0952743a610911b3db7831c55e96cb
Rust
kubos/kubos
/services/scheduler-service/src/error.rs
UTF-8
4,315
2.609375
3
[ "Apache-2.0" ]
permissive
/* * Copyright (C) 2019 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 ...
true
d03b1fe5f03930021782a38cc8183c669ae62c2c
Rust
mystor/slag
/old_syntex/src/visit.rs
UTF-8
33,205
2.765625
3
[ "MIT" ]
permissive
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
true
af2581269b0cea815c67ed8e928919cb113ac76a
Rust
iCodeIN/edu-json-parser
/edu-json-parser/src/traits.rs
UTF-8
1,400
3.234375
3
[]
no_license
use crate::{Node, parse_json}; pub trait Parsable { fn parse_node(json: &Node) -> Result<Self, String> where Self: Sized; fn parse_node_array(json: &Node) -> Result<Vec<Self>, String> where Self: Sized { if !json.is_array() { return Err("Node is not array".to_string()); ...
true
bcdd72bb6a1f2b0cc1998c02b2d4996005289162
Rust
teruuuuuu/TicketModelingRust
/src/ticket/late_specification.rs
UTF-8
766
3.125
3
[]
no_license
use super::specification::Specification; use super::structs::LocalDateTime; use chrono::Timelike; pub const LateSpec8: LateSpecification = LateSpecification { start_hour: 20 }; pub struct LateSpecification { pub start_hour: i32, } impl Specification<LocalDateTime> for LateSpecification { fn is_satisfied_by(...
true
eb3b5934d80f0f2fc96f43dc86c0d7d05b3ffd57
Rust
mdlayher/monkey-rs
/src/compiler/symbol.rs
UTF-8
5,704
3.59375
4
[ "MIT" ]
permissive
//! Symbol types for the `compiler` module. use std::{cell::RefCell, collections::HashMap, rc::Rc}; use crate::object; /// A table that can be used to define and resolve `Symbols`. #[derive(Debug, Default)] pub struct SymbolTable { pub num_definitions: usize, pub free: Vec<Symbol>, store: HashMap<String,...
true
5818755a13385a4be633629a496cd5596766295a
Rust
kitsuneninetails/config-rust
/tests/get_tree.rs
UTF-8
1,205
2.78125
3
[]
no_license
extern crate config; extern crate serde; extern crate float_cmp; #[macro_use] extern crate serde_derive; use std::collections::HashMap; use float_cmp::ApproxEqUlps; use config::*; fn make() -> Config { let mut c = Config::default(); c.merge(File::new("tests/Settings", FileFormat::Yaml)) .unwrap(); ...
true
e4d81b0b26fd303424e9205b6af56552979379c9
Rust
pombredanne/spdx-rs
/src/license_list.rs
UTF-8
3,412
2.65625
3
[ "BSD-3-Clause" ]
permissive
// SPDX-FileCopyrightText: 2020 HH Partners // // SPDX-License-Identifier: MIT use serde::{Deserialize, Serialize}; use crate::error::SpdxError; #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "camelCase", deny_unknown_fields)] pub struct LicenseList { pub license_list_version: String, #[serde(...
true
0c9482eeaf047ade7ef19845fa2dce962647a47c
Rust
tebari/rayitos
/src/rng.rs
UTF-8
433
2.765625
3
[]
no_license
use crate::vector::Vector3; use rand::{thread_rng, Rng}; pub fn random_f64() -> f64 { thread_rng().gen_range(0.0, 1.0) } fn random_f64x3() -> [f64; 3] { [random_f64(), random_f64(), random_f64()] } pub fn random_in_unit_sphere() -> Vector3 { loop { let p = 2.0 * Vector3::from_array(random_f64x3()...
true
2cde697d5f950c0929526bb8a0d50770b4fe287d
Rust
batazor/MyExampleAndExperiments
/Rust/rust-tutorial/simple_project/rust_image/src/canvas.rs
UTF-8
3,831
2.875
3
[ "MIT" ]
permissive
use std::mem; use geometry::Vector3D; use tgacanvas::TgaCanvas; fn get_gray(color: u32, intensity: f32) -> u32 { debug!("get color {:X} with intensity {}", color, intensity); let mut result = ((color as u8) as f32*intensity) as u32; result += (((color >> 8) as u8) as f32*intensity) as u32*256; result +...
true
9585a8f55af24832a0a1e79c63dd9880d03f3930
Rust
kritzcreek/siml
/src/pretty.rs
UTF-8
408
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use pretty::{BoxDoc, Doc}; pub fn parens_if(p: bool, s: String) -> String { if p { format!("({})", s) } else { s } } pub fn render_doc(doc: Doc<BoxDoc<()>>) -> String { render_doc_width(doc, 80) } pub fn render_doc_width(doc: Doc<BoxDoc<()>>, width: usize) -> String { let mut w = ...
true
feecdde77209026d83bebc9e81b8917036e6e66b
Rust
mass10/rust.note
/code/stdin/src/main.rs
UTF-8
560
3.0625
3
[]
no_license
use std::io::{Write}; fn read(reader: std::io::Stdin) -> std::result::Result<(), Box<dyn std::error::Error>> { loop { print!("? "); std::io::stdout().flush().unwrap(); // line には 0d,0a も入ってきます。 let mut line = String::new(); let read = reader.read_line(&mut line)?; if read == 0 { // シグナル発生 break; }...
true
1da35ee549ce0af6577cfa9a5fcf8a274ab3fb9d
Rust
dailypipsgxj/timely-dataflow
/src/communication/observer.rs
UTF-8
8,922
3.375
3
[ "MIT" ]
permissive
use std::rc::Rc; use std::cell::RefCell; // TODO : Using an Observer requires a &mut reference, and should have the "No races!" property: // TODO : If you hold a &mut ref, no one else can call open/push/shut. Don't let go of that &mut! // TODO : Probably a good place to insist on RAII... (see ObserverSession) // obse...
true
4e3263c7e200e5a8c1240f54f4a3b00a40ff4f98
Rust
andremaha/library_catalogue
/src/book/mod.rs
UTF-8
1,181
3.390625
3
[]
no_license
use crate::book::isbn::ISBN; use crate::book::read::Read; pub mod isbn; pub mod read; #[derive(Debug)] pub struct Book { pub title: String, pub isbn: ISBN, pub pages: u32, pub read: Read } impl Book { /// Marks a book as finished /// /// # Affected fields /// /// - read ///...
true
28f4736f667356e9f71dfcc665d180bd7d5d4199
Rust
DevinR528/genawaiter
/tests/stack.rs
UTF-8
849
2.6875
3
[]
no_license
#![cfg_attr(feature = "nightly", feature(async_await, async_closure))] #![warn(future_incompatible, rust_2018_compatibility, rust_2018_idioms, unused)] #![warn(missing_docs, clippy::pedantic)] #![cfg_attr(feature = "strict", deny(warnings))] use genawaiter::{ generator_mut, stack::{Co, Gen, Shelf}, }; async f...
true
726eb30790f26d970947fe6ebccd5e16da37dd82
Rust
zmwangx/rust-ffmpeg
/src/codec/encoder/prediction.rs
UTF-8
690
2.65625
3
[ "WTFPL" ]
permissive
use ffi::*; use libc::c_int; #[derive(Eq, PartialEq, Clone, Copy, Debug)] pub enum Prediction { Left, Plane, Median, } impl From<c_int> for Prediction { fn from(value: c_int) -> Prediction { match value { FF_PRED_LEFT => Prediction::Left, FF_PRED_PLANE => Prediction::Pl...
true
da03adc3d0b62ac5b35e91dd9a03f51010935bc2
Rust
joanrieu/project-euler
/037-truncatable-primes.rs
UTF-8
553
3.15625
3
[]
no_license
use std::collections::btree_set::*; fn main() { let is_prime = |p| p > 1 && (2..=((p as f32).sqrt() as usize)).all(|d| p % d != 0); let mut sum = 0; for p in 10.. { let mut splits = vec![]; let mut p1 = p; while p1 > 0 { splits.push(p1); p1 /= 10; } let mut mask = (10 as f32).powf...
true
7c61920d2ca04532adc45bb0ef698b8b6ad08778
Rust
nathaniel-may/rust-quarto
/src/piece.rs
UTF-8
3,093
3.15625
3
[]
no_license
use std::fmt; pub use Color::*; pub use Height::*; pub use Shape::*; pub use Top::*; #[derive(Copy, Clone)] #[derive(PartialEq, Eq, Hash)] #[derive(Debug)] pub enum Color { White, Black, } #[derive(Copy, Clone)] #[derive(PartialEq, Eq, Hash)] #[derive(Debug)] pub enum Height { Tall, Short, } #[deriv...
true
e7e1df50687b91f058777c4798d609b691ee9e01
Rust
fake-news-detector/fake-news-detector
/api/src/data/link.rs
UTF-8
2,771
2.78125
3
[]
no_license
extern crate diesel; extern crate md5; use diesel::prelude::*; use diesel::update; use data::schema::links::dsl; use data::schema::links; use scrapper::scrapper; #[derive(Serialize, Deserialize, Identifiable, Queryable)] #[table_name = "links"] pub struct Link { pub id: i32, pub url: String, pub title: St...
true
e415703eff0f1d1e1ae581635ca795f6d9f2e951
Rust
datachainlab/hmemu
/core/build.rs
UTF-8
653
2.515625
3
[ "Apache-2.0" ]
permissive
use std::env; use std::path::Path; use std::process::Command; fn main() { // If the package has a build script, this is set to the folder where the build script should place its output. let out_dir = env::var("OUT_DIR").unwrap(); Command::new("go") .args(&[ "build", "-o", ...
true
a1e8684edc72cf6ebcd234f5530c8d3e9eb5fa16
Rust
Harapan21/Lunatictech
/server/src/models/node.rs
UTF-8
2,711
2.640625
3
[]
no_license
use super::page::Page; use super::topic::Topic; use crate::{ errors::SmileError, models::{category::Category, post::Post}, schema::{category, category_node, page_and_topic, post}, }; use diesel::prelude::*; #[derive( juniper::GraphQLObject, Insertable, Queryable, Associations, Identifia...
true
584a8e11b8a97ee20a8a1208a6a8473e26e9491d
Rust
maxfischer2781/aoc2020_rust
/src/day9.rs
UTF-8
2,468
3.53125
4
[]
no_license
use std::io::Error; use std::collections::{VecDeque, HashSet}; use crate::utility::parse_file_lines; pub fn solve() -> Result<(), Error> { let series: Vec<i64> = parse_file_lines("data/day9.txt")?; if let Some(outlier) = find_nonsum(&series, 25) { println!("Non-sum {}", outlier); if let Some(...
true
80fab330f6a2d5001036b2fd7aa381d5b50975b2
Rust
evuez/gleam
/src/docs/source_links.rs
UTF-8
2,236
2.546875
3
[ "Swift-exception", "Apache-2.0" ]
permissive
use crate::{ ast::SrcSpan, config::{PackageConfig, Repository}, line_numbers::LineNumbers, project::Analysed, }; use std::path::{Path, PathBuf}; pub struct SourceLinker { line_numbers: LineNumbers, url_pattern: Option<(String, String)>, } impl SourceLinker { pub fn new( project_roo...
true
fdbd8ae1873dd63a74dd6736513468ee5b2f1384
Rust
wezm/dslite2svd
/crates/tm4c129x/src/emac0/vlnincrep/mod.rs
UTF-8
8,980
2.625
3
[ "0BSD", "BSD-3-Clause" ]
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::VLNINCREP { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w...
true
8f38982267f26d6d28f9d74bec27a6e5e5a79fb0
Rust
redsnapper2006/leetcode-cn
/C/1400-construct-k-palindrome-strings/main.rs
UTF-8
377
3.125
3
[]
no_license
struct Solution {} impl Solution { pub fn can_construct(s: String, k: i32) -> bool { let mut buf: Vec<i32> = vec![0; 26]; s.as_bytes().iter().for_each(|&b| { buf[(b - 'a' as u8) as usize] += 1; }); let mut odd: i32 = 0; buf.iter().for_each(|&v| { if v % 2 == 1 { odd += 1; ...
true
dd00c6eb8ec2a8b531a7e92d0ea3759aaab2fb30
Rust
yulincoder/Controller-Device
/device-connection-rs/src/main.rs
UTF-8
907
2.640625
3
[]
no_license
use log::info; use std::sync::{Arc, RwLock}; use std::thread; mod connection; mod device; mod http_server; mod loge_cfg; mod messagequeue; fn init() -> Result<(), String> { loge_cfg::log_init(Some("info"))?; Ok(()) } fn main() { init().unwrap(); let devicepool = Arc::new(RwLock::new(device::DevicePo...
true
d88427304ab3371a354404910a5d2b2f8a64dcd8
Rust
wbjohnston/mips
/src/core/isa/opcode.rs
UTF-8
4,244
3.625
4
[ "MIT", "Apache-2.0" ]
permissive
//! Mips Opcodes /// A MIPS opcode #[repr(u8)] #[allow(non_camel_case_types)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum OpCode { //////////////////////////////////////////////////////////////////////////// // I-type instructions //////////////////////////////////////////////////////////////////...
true
ddc7aeec90e3a0984c8d11aa96230dceedbed804
Rust
dmgolembiowski/lagoon
/benches/threadpool.rs
UTF-8
1,755
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#[macro_use] extern crate criterion; use criterion::{Criterion, black_box}; const JOBC: usize = 100000; fn lagoon_threadpool(threads: usize) { let pool = lagoon::ThreadPool::build() .with_thread_count(threads) .finish() .unwrap(); for _ in 0..JOBC { pool.run(|| { l...
true
42107517638e5b0e37c6085a11818488e971166a
Rust
0xorial/node-ts-vscode-starter
/rust/src/main.rs
UTF-8
8,968
2.671875
3
[]
no_license
mod solution; use crate::solution::{ get_move, GameState, Inventory, LearnableSpell, Move, Order, Spell, SpellDescriptor, }; use rand::seq::SliceRandom; use rand::SeedableRng; use rand_hc::Hc128Rng; use std::collections::VecDeque; use std::iter::FromIterator; fn make_initial_state<'a>( all_potions: &'a [Order...
true
fe73984adc88eb9ffe93f2a45f67f4f5be0ef42a
Rust
moddyz/RustSandbox
/src/bin/recoverable_errors.rs
UTF-8
1,424
3.1875
3
[ "MIT" ]
permissive
use std::error::Error; use std::fs; use std::io; use std::io::Read; fn read_username_from_file_super_concise() -> Result<String, io::Error> { fs::read_to_string("hello.txt") } fn read_username_from_file_concise() -> Result<String, io::Error> { let mut s = String::new(); fs::File::open("hello.txt")?.read_t...
true
1713165a125e863b07123a9ea5cd181a293a737d
Rust
benfen/stonky-tonks
/db/src/user_models.rs
UTF-8
1,807
2.828125
3
[]
no_license
use ::uuid::Uuid; use diesel::prelude::*; use diesel::SqliteConnection; use serde::{Deserialize, Serialize}; use super::schema::user; use super::schema::user::dsl::*; #[derive(Debug, Deserialize, Identifiable, Insertable, Queryable, Serialize)] #[table_name = "user"] pub struct User { pub name: String, pub ca...
true
4f2db8762f2fa20c02d93f901f7f25f284b7f40f
Rust
Demindiro/ballscript
/lib/src/script.rs
UTF-8
6,686
2.671875
3
[ "MIT" ]
permissive
// Copyright (C) 2021 David Hoppenbrouwers // // This file is licensed under the MIT license. See script/LICENSE for details. use crate::bytecode::{ByteCode, CallResult}; use crate::std_types::*; use crate::Rc; use crate::{Environment, Tracer, VariantType}; use core::any::{Any, TypeId}; use core::cell::RefCell; use c...
true
6f71a74a09ec9e3dfd61d91b4fdcf23a29c2501f
Rust
slogsdon/rust-cli-editor
/src/terminal.rs
UTF-8
2,020
3.453125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/// Interface for the terminal environment use crossterm::{ event::{DisableMouseCapture, EnableMouseCapture}, execute, terminal::{ disable_raw_mode, enable_raw_mode, size, EnterAlternateScreen, LeaveAlternateScreen, }, Result, }; use std::io::{stdout, Write}; /// Prepares editor environment...
true
2be24f8623d949322b82e226e84e13e71b239758
Rust
igaozp/LearnRust
/base_content/src/if_let.rs
UTF-8
254
3.703125
4
[]
no_license
// if-let let option = Some(5); fn foo(x: i32) { } fn bar() { } if let Some(x) = option { foo(x); // 匹配成功后,x = 5 } else { bar(); } // while-let let mut v = vec![1, 3, 5, 7, 11]; while let Some(x) = v.pop() { println!("{}", x); }
true
c5ba8f94bed25310625fc616848b603b6ccc5bf2
Rust
rust-lang/rust
/tests/rustdoc-gui/src/link_to_definition/lib.rs
UTF-8
651
2.71875
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// compile-flags: -Zunstable-options --generate-link-to-definition pub fn sub_fn() { barbar(); } fn barbar() { bar(vec![], vec![], vec![], vec![], Bar { a: "a".into(), b: 0 }); } pub struct Bar { pub a: String, pub b: u32, } pub fn foo(_b: &Bar) {} // The goal now is to add // a lot of lines so // th...
true
a9d69a09e9f15d8d2f983572382378b5e03c279a
Rust
hnakamur/psgreptree
/src/user.rs
UTF-8
498
2.578125
3
[ "MIT", "Apache-2.0" ]
permissive
use nix::unistd::{Uid, User}; use std::collections::HashMap; use std::io::Result; #[derive(Debug, Clone)] pub struct UserNameCache(HashMap<Uid, Option<String>>); impl UserNameCache { pub fn new() -> UserNameCache { UserNameCache(HashMap::new()) } pub fn get(&mut self, uid: Uid) -> Result<Option<S...
true
37e5245756609f1c8baee1a902056e17306fc807
Rust
devoidfury/rust-rserv
/src/middleware.rs
UTF-8
1,152
3.0625
3
[]
no_license
use request::HTTPRequest; use response::HTTPResponse; use regex::Regex; pub enum MResult { End, Next, Err } pub struct Middleware { pub mount: Regex, pub handle: fn(&HTTPRequest, &mut HTTPResponse) -> MResult, pub index: usize } impl Middleware { pub fn new(mount: &str, handle: fn(&HTTP...
true
3ec88e1073535efeda56b3141c3dbf9f6c78385e
Rust
ISibboI/MarketSim
/model/src/ware.rs
UTF-8
9,344
3.578125
4
[]
no_license
use std::{collections::HashMap, ops::Mul}; custom_derive! { #[derive(Clone, Debug, Copy, Hash, PartialEq, Eq, Ord, PartialOrd, IterVariants(WareTypeVariants), EnumFromStr)] pub enum WareType { Food, Water, Soil, Money, } } impl Default for WareType { fn default() -> Sel...
true