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
ad88d22f6be6acdcd8de1e99fa53375d197195ec
Rust
briangreenery/with-clean-env
/src/main.rs
UTF-8
3,446
2.96875
3
[ "Unlicense" ]
permissive
extern crate winapi; extern crate kernel32; extern crate advapi32; extern crate userenv; use std::error::Error; use std::ffi::OsString; use std::io; use std::io::Write; use std::os::windows::ffi::OsStringExt; use std::process::Command; use kernel32::{CloseHandle, GetCurrentProcess}; use advapi32::OpenProcessToken; use...
true
3db8605481b13b132bd983ab84707cfa179050ee
Rust
Merlotec/imperium
/src/input/mod.rs
UTF-8
4,299
3.296875
3
[]
no_license
use crate::*; #[derive(Copy, Clone)] pub enum Trigger { KeyTrigger(window::winit::VirtualKeyCode, window::winit::ElementState), MouseButtonTrigger(window::winit::MouseButton, window::winit::ElementState), } #[derive(Copy, Clone)] pub enum TriggerType { Once, Toggle, } #[derive(Clone)] pub struct Move...
true
734c22486a3b3fd618bac6ffe555b51b5eead3a9
Rust
randomPoison/gunship-rs
/src/old/resource/mod.rs
UTF-8
7,150
2.578125
3
[ "MIT" ]
permissive
use component::{MeshManager, TransformManager}; use ecs::Entity; use scene::Scene; use std::cell::RefCell; use std::collections::HashMap; use std::fs; use std::path::{Path, PathBuf}; use std::rc::Rc; use polygon::{GpuMesh}; use polygon::geometry::mesh::Mesh; use polygon::material::*; use wav::Wave; pub mod async; pub ...
true
61a8873a3f5e2685101e8877ef26ef989b8e89cc
Rust
mkpankov/jwt-prototype
/src/main.rs
UTF-8
3,811
2.71875
3
[]
no_license
use biscuit::jwa::{ ContentEncryptionAlgorithm, EncryptionOptions, KeyManagementAlgorithm, SignatureAlgorithm, }; use biscuit::jwe; use biscuit::jwk::JWK; use biscuit::jws::{self, Secret}; use biscuit::{ClaimsSet, Empty, RegisteredClaims, SingleOrMultiple, JWE, JWT}; use serde::{Deserialize, Serialize}; use std::st...
true
f3fa1f166ea981ec5e61b1128b35483dc61a70e4
Rust
Bugin10/rust_ray_tracer_book_2
/.history/src/ray_20210814191722.rs
UTF-8
332
2.984375
3
[]
no_license
use ultraviolet::*; #[derive(Clone, Copy, Debug)] pub struct Ray { pub origin: Vec3x8, pub direction: Vec3x8 } impl Ray { pub fn new(origin: Vec3x8, direction: Vec3x8) -> Ray { Ray { origin, direction } } pub fn at_parameter(&self, t: f32) -> Vec3x8 { self.origin + t * self.direc...
true
caac03a6ee2d0f89d89a3d7d84c515e5d2c5f7c4
Rust
Zoomulator/rust-sorted
/tests/usage.rs
UTF-8
6,853
3.5625
4
[ "MIT" ]
permissive
#[macro_use] extern crate sorted; use sorted::*; order_by_key! { Key0AscOrder: fn (K: Ord + Copy, T)(entry: (K,T)) -> K { entry.0 } } order_by_key! { KeySecondOrder: fn (K: Ord + Copy, T)(entry: (T,K)) -> K { entry.1 } } #[test] fn sorted_array() { let arr = [7, 2, 9, 6]; // Sort the array, resultin...
true
b2702f68e56d537f7a0fe6fedb3dd6b086bd2d45
Rust
zaksky7/Rust-project
/src/year2016/day22.rs
UTF-8
2,077
2.78125
3
[]
no_license
use ahash::AHashMap; use regex::Regex; use std::cmp::max; use crate::utils::*; #[derive(Clone)] struct Node { coord: Coord<i32>, used: i64, avail: i64, } fn parse_nodes(input: &str) -> Vec<Node> { let re = Regex::new(r"/dev/grid/node-x(\d+)-y(\d+)\s+(\d+)T\s+(\d+)T\s+(\d+)T\s+(\d+)%").unwrap(...
true
29dd1c7057ff3e07d1967bb70577ee0281d462e1
Rust
blitzmann/euler-rust
/src/p005.rs
UTF-8
2,373
3.921875
4
[]
no_license
pub fn solve(max: u64) -> u64 { improved_version(max) } pub fn improved_version(max: u64) -> u64 { let mut multiple: u64 = 1; let mut number: u64 = multiple; let mut min: u64 = 1; 'main: loop { // our main loop. This will check each number from 1 to x to see if it's divisible by 1..=max ...
true
fc1f50100edac9dae5c2b5ea5e9c2478bbc01179
Rust
yinshuwei/trying
/rust/hello_cargo/src/demo/box_demo.rs
UTF-8
833
3.4375
3
[]
no_license
enum List { Cons(i32, Box<List>), Nil, } impl List { fn print(&self) { if let List::Cons(i, c) = self { println!("{}", i); c.print(); } } } struct MyList<'a> { list: &'a List, } impl MyList<'_> { fn new<'a>(list: &'a List) -> MyList<'a> { MyList...
true
a88022d65d82c476443207c518dd33b69fa90f18
Rust
cameronfyfe/ripple
/src/util.rs
UTF-8
551
2.765625
3
[]
no_license
pub fn u16_from_bytes(b: [u8; 2]) -> u16 { ((b[1] as u16) << 8) + ((b[0] as u16) << 0) } pub fn u16_from_u8_slice(b: &[u8]) -> u16 { u16_from_bytes([b[0], b[1]]) } pub fn u32_from_bytes(b0: u8, b1: u8, b2: u8, b3: u8) -> u32 { ((b3 as u32) << 24) + ((b2 as u32) << 16) + ((b1 as u32) << 8) +...
true
9dfd36d1a47e5ca0574521d52f9fdc08178fb0c3
Rust
eduardonunesp/river-jet-rs
/src/scene.rs
UTF-8
3,087
3.34375
3
[]
no_license
use ggez; /// Based on ggez goodies scene manager /// A command to change to a new scene, either by pushing a new one, /// popping one or replacing the current scene (pop and then push). #[allow(dead_code)] pub enum SceneSwitch<Ev> { None, Push(Box<dyn Scene<Ev>>), Replace(Box<dyn Scene<Ev>>), Pop, } pub tra...
true
8f693f951ebbda771a256ae0f8128d5e23213b85
Rust
xiuxiu62/rust-workshop
/calculator/src/main.rs
UTF-8
1,643
3.515625
4
[]
no_license
use std::io::{stdin, stdout, Write}; use std::panic::panic_any; fn main() { loop { prompt(); match prompt_continue() { true => continue, false => return, } } } fn prompt_continue() -> bool { let mut res = String::new(); print!("Continue? [y/n]: "); r...
true
583df7f5dba8f9eb5f95e5c15bdd4589ecd09ca5
Rust
nagyf/rs-chess
/src/engine/board/piece/sliding/mod.rs
UTF-8
5,946
3.421875
3
[ "MIT" ]
permissive
//! This module is used to calculate attack targets for sliding pieces (queen, rook, bishop). //! //! The module uses the `Hyperbola Quintessence` method to calculate the targets without lookups. //! //! For more information: [https://www.chessprogramming.org/Hyperbola_Quintessence](https://www.chessprogramming.org/Hyp...
true
9821dc20f4923ad31b202224a408c6f87ac22e39
Rust
mvidner/exercism-rust
/isbn-verifier/src/lib.rs
UTF-8
1,796
3.6875
4
[]
no_license
/// Determines whether the supplied string is a valid ISBN number pub fn is_valid_isbn(isbn: &str) -> bool { let rv: Result<Vec<u8>, String> = parse_isbn(isbn); let r: Result<(), String> = rv.and_then(check_valid_isbn_num); match r { Ok(()) => true, Err(s) => { println!("{...
true
4a6da8bce92a342477909357d02f9c88affdc1ff
Rust
ankurhimanshu14/novarche
/src/apis/rm_store/gate_entry.rs
UTF-8
14,775
2.640625
3
[ "Apache-2.0" ]
permissive
pub mod gate_entry { use chrono::NaiveDate; use mysql::*; use mysql::prelude::*; use crate::apis::utils::parse::parse::parse_from_row; use crate::apis::utils::gen_uuid::gen_uuid::generate_uuid; #[derive(Debug, Clone)] pub struct GateEntry { pub grn: usize, pub grn_date: Na...
true
c3cfec396750dcc397e6679b1be8a2bdde2065da
Rust
Tiv0w/chip8-emulator
/src/desktop/input.rs
UTF-8
1,734
3.25
3
[]
no_license
use sdl2::event::Event; use sdl2::keyboard::Keycode; use sdl2::EventPump; pub struct SdlInput { event_pump: EventPump, } impl SdlInput { pub fn new(sdl_context: &sdl2::Sdl) -> SdlInput { SdlInput { event_pump: sdl_context.event_pump().unwrap(), } } pub fn read_input(&mut s...
true
cbcc0dc18598e8d58ec48e8d3a7ac990598eb19e
Rust
svenstaro/minitraderoute
/src/main.rs
UTF-8
2,881
2.65625
3
[ "MIT" ]
permissive
use std::{sync::mpsc::channel, thread}; use anyhow::{Context, Result}; use audio::AudioEvent; use pixels::{Pixels, SurfaceTexture}; use rand::{Rng, RngCore}; use rand_xoshiro::rand_core::SeedableRng; use rand_xoshiro::Xoroshiro128StarStar; use raqote::*; use rayon::prelude::*; use shipyard::*; use winit::{ dpi::{L...
true
0280401e7b2047370dc96b379f3f05bd4ab5e007
Rust
ummarikar/wzsh
/src/builtins/env.rs
UTF-8
2,393
2.703125
3
[ "MIT" ]
permissive
use crate::builtins::Builtin; use crate::shellhost::FunctionRegistry; use cancel::Token; use failure::Fallible; use shell_vm::{Environment, IoEnvironment, Status, WaitableStatus}; use std::io::Write; use std::path::PathBuf; use std::sync::Arc; use structopt::*; #[derive(StructOpt)] /// Set the export attribute for var...
true
48db37c94a6267ce0efbd83a116ea590b6d010af
Rust
terakun/quoridor_judge
/src/main.rs
UTF-8
24,605
2.59375
3
[]
no_license
extern crate bit_vec; extern crate uuid; extern crate ws; mod base64; mod websocket; use uuid::Uuid; use bit_vec::BitVec; use base64::{append, bitvec_to_base64, from_u16, from_u8}; use ws::{CloseCode, Factory, Handler, Message, Sender}; use std::net::{TcpListener, TcpStream}; use std::thread; use std::io::{Read, Writ...
true
b75836839b949518198afad9ce512982107c3f14
Rust
GopherSecurity/plonky
/src/bigint/bigint_inverse.rs
UTF-8
1,334
2.828125
3
[]
no_license
#![allow(clippy::many_single_char_names)] use std::cmp::Ordering::Less; use crate::{add_no_overflow, cmp, div2, is_even, is_odd, sub, one_array}; pub(crate) fn nonzero_multiplicative_inverse<const N: usize>(a: [u64; N], order: [u64; N]) -> [u64; N] { // Based on Algorithm 16 of "Efficient Software-Implementation ...
true
f060e36ff7f13a429ddea1be18566329b22123a1
Rust
mrhota/icu4rs
/src/version.rs
UTF-8
1,411
2.765625
3
[ "Unlicense", "MIT" ]
permissive
use std::convert::TryFrom; use std::io; pub type PiecewiseVersion = (u8, u8, u8, u8); #[allow(non_camel_case_types)] #[derive(Clone, Copy, Debug, Ord, PartialOrd, Eq, PartialEq)] pub enum Version { Unicode1_0(PiecewiseVersion), Unicode1_0_1(PiecewiseVersion), Unicode1_1_0(PiecewiseVersion), Unicode1_1...
true
9640ca12603ee9dfb290f0ddf171c7371f07baa5
Rust
TyOverby/spatial
/quad.rs
UTF-8
6,142
3.125
3
[]
no_license
#![feature(struct_variant)] use std::num::FromPrimitive; use std::default::Default; trait QTNumber: Num + Ord + FromPrimitive + Copy + Default {} trait Point<N> { fn x(&self)-> N; fn y(&self)-> N; } struct Cardinal<T> { nw: T, ne: T, sw: T, se: T } impl <T> Cardinal<T> { fn new( nw: T, ...
true
09ab12fb7098fd63949bad4609c72142888eb4fe
Rust
enarx/enarx
/crates/shim-kvm/src/snp/cpuid_page.rs
UTF-8
3,198
2.828125
3
[ "Apache-2.0" ]
permissive
// SPDX-License-Identifier: Apache-2.0 //! Structures and methods to handle the SEV-SNP CPUID page use core::arch::x86_64::CpuidResult; use crate::snp::snp_active; use crate::_ENARX_CPUID; /// See [`cpuid_count`](cpuid_count). #[inline] pub fn cpuid(leaf: u32) -> CpuidResult { cpuid_count(leaf, 0) } /// Return...
true
63b00d98d1ecea8e8bdccd329b8c9bc2ce89ece5
Rust
iquiw/gitcop
/src/main.rs
UTF-8
3,375
2.84375
3
[]
no_license
use std::env; use std::process::exit; use clap::{crate_name, crate_version, Arg, ArgAction, Command}; use gitcop::cmd; use gitcop::config; use gitcop::print; #[tokio::main] async fn main() { print::color_init(); let matches = Command::new(crate_name!()) .version(crate_version!()) .arg_requir...
true
395379d7052454dd15b6d79912372aabe46e007c
Rust
mfkiwl/WGFEM-Rust
/dense_matrix.rs
UTF-8
7,180
2.90625
3
[ "MIT" ]
permissive
use common::*; use la; use std::libc::{c_ulong}; use std::ptr; use std::iter::{range_inclusive}; use std::cast::transmute; use extra::c_vec::CVec; /// Column major dense matrix type. pub struct DenseMatrix { priv data: CVec<R>, priv num_rows: uint, priv num_cols: uint, priv capacity_cols: uint, } impl DenseM...
true
9f8274c8ce345c4168aeb29f6ef0f7060702516c
Rust
bytecodealliance/wasmtime
/cranelift/codegen/src/ir/instructions.rs
UTF-8
36,667
3.078125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
//! Instruction formats and opcodes. //! //! The `instructions` module contains definitions for instruction formats, opcodes, and the //! in-memory representation of IR instructions. //! //! A large part of this module is auto-generated from the instruction descriptions in the meta //! directory. use alloc::vec::Vec; ...
true
231b36d77fc78bbd99751f3fb36e4c70db61b7b0
Rust
janpauldahlke/fhir-rs
/src/model/DiagnosticReport.rs
UTF-8
30,248
2.640625
3
[ "MIT" ]
permissive
#![allow(unused_imports, non_camel_case_types)] use crate::model::Attachment::Attachment; use crate::model::CodeableConcept::CodeableConcept; use crate::model::DiagnosticReport_Media::DiagnosticReport_Media; use crate::model::Element::Element; use crate::model::Extension::Extension; use crate::model::Identifier::Ident...
true
1935a6a9de43b5c9db0957700b41dce0fe326d4e
Rust
dangerousplay/file-server
/client/src/main.rs
UTF-8
3,168
2.75
3
[]
no_license
use cursive::views::{Dialog, TextView, ListView, SelectView, TextArea}; use tokio::net::{TcpStream, ToSocketAddrs}; use std::io; use std::borrow::Cow; use futures::stream::StreamExt; use tokio_util::codec::{FramedRead, FramedWrite}; use tokio::net::tcp::{WriteHalf, ReadHalf, OwnedReadHalf, OwnedWriteHalf}; use core::pr...
true
2b0f73567427a4f207fa8ab5216a42e0ab853727
Rust
rv32m1-rust/rv32m1_ri5cy-pac
/src/lptmr0/csr.rs
UTF-8
18,779
2.53125
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = "Reader of register CSR"] pub type R = crate::R<u32, super::CSR>; #[doc = "Writer for register CSR"] pub type W = crate::W<u32, super::CSR>; #[doc = "Register CSR `reset()`'s with value 0"] impl crate::ResetValue for super::CSR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 ...
true
adf9779c7c5700aa950fe59d81bf2a220fe6a896
Rust
LukeMathWalker/build-your-own-jira-with-rust
/jira-wip/src/koans/01_ticket/07_derive.rs
UTF-8
1,535
3.46875
3
[ "MIT" ]
permissive
/// Cool, we learned what a trait is and how to implement one. /// I am sure you agree with us though: implementing PartialEq was quite tedious /// and repetitive, a computer can surely do a better job without having to trouble us! /// /// The Rust team feels your pain, hence a handy feature: derive macros. /// Derive ...
true
7d81dbbac059a51f2a747a61cbe2f6a4aa3a730d
Rust
cyber-meow/ReactiveRs
/src/signal/valued_signal/emit.rs
UTF-8
2,483
2.984375
3
[ "MIT" ]
permissive
use runtime::{Runtime, SingleThreadRuntime, ParallelRuntime}; use continuation::{ContinuationSt, ContinuationPl}; use process::{Process, ProcessMut, ProcessSt, ProcessMutSt}; use process::{ProcessPl, ProcessMutPl, ConstraintOnValue}; use signal::signal_runtime::SignalRuntimeRefBase; use signal::ValuedSignal; /// Proce...
true
531451e2c9f46849812ee5481655ff72130fcc4f
Rust
binh-vu/rython
/src/types/and_semantic.rs
UTF-8
772
2.875
3
[]
no_license
use std::borrow::Cow; use crate::types::Str; pub trait AndSemantic<RHS=Self> { fn and(self, rhs: RHS) -> Self; } impl AndSemantic for bool { fn and(self, rhs: bool) -> Self { self && rhs } } impl AndSemantic for Str { fn and(self, rhs: Str) -> Self { unimplemented!() } } impl AndSemantic for i64 {...
true
9272c80c194d3a40478d1c6d604faebf55bf2541
Rust
solana-labs/solana
/accounts-db/src/storable_accounts.rs
UTF-8
23,475
3.046875
3
[ "Apache-2.0" ]
permissive
//! trait for abstracting underlying storage of pubkey and account pairs to be written use { crate::{account_storage::meta::StoredAccountMeta, accounts_db::IncludeSlotInHash}, solana_sdk::{account::ReadableAccount, clock::Slot, hash::Hash, pubkey::Pubkey}, }; /// abstract access to pubkey, account, slot, targe...
true
b2898c034e1d2e45f4755604f5cadf4e8a83e79d
Rust
MitchellHansen/advent-2019
/src/main.rs
UTF-8
1,395
2.546875
3
[]
no_license
extern crate reqwest; extern crate tempfile; use crate::problem1::part1::Problem1; use crate::problem2::part1::Problem2; use crate::problem3::part1::Problem3; use crate::problem4::part1::Problem4; use crate::problem5::part1::Problem5; use crate::problem6::part1::Problem6; use crate::problem7::part1::Problem7; mod pro...
true
7d99cbbb27bb844ea84508c34e892dc841b01aac
Rust
rust-lang-ja/rust-by-example-ja
/src-old/std_misc/file/open/open.rs
UTF-8
1,079
3.703125
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::error::Error; use std::fs::File; use std::io::prelude::*; use std::path::Path; fn main() { // 目的ファイルに対する`Path`を作成 let path = Path::new("hello.txt"); let display = path.display(); // pathを読み込み専用モードで開く。これは`io::Result<File>`を返す。 let mut file = match File::open(&path) { // `io::Error`...
true
490612e0285d2c6377a75e209b4db1758caa4ceb
Rust
DaixuanLi/UndergradCourseProject
/OperatingSystem_Rust/os/src/memory/page_replace/fifo.rs
UTF-8
1,522
2.6875
3
[]
no_license
use { super::*, alloc::{collections::VecDeque, sync::Arc}, spin::Mutex, }; #[derive(Default)] pub struct FifoPageReplace { frames: VecDeque<(usize, Arc<Mutex<PageTableImpl>>)>, pointer: usize, } impl PageReplace for FifoPageReplace { fn push_frame(&mut self, vaddr: usize, pt: Arc<Mutex<PageTab...
true
4c0efaa928a82a2c716ef9ecd83a40c68895e349
Rust
z1queue/smartcore
/src/linalg/mod.rs
UTF-8
23,629
3.203125
3
[ "Apache-2.0" ]
permissive
#![allow(clippy::wrong_self_convention)] //! # Linear Algebra and Matrix Decomposition //! //! Most machine learning algorithms in SmartCore depend on linear algebra and matrix decomposition methods from this module. //! //! Traits [`BaseMatrix`](trait.BaseMatrix.html), [`Matrix`](trait.Matrix.html) and [`BaseVector`](...
true
e6b8bb9ad5951c4991e830d83e471ccfc8e79a74
Rust
kruschk/intcode
/src/instruction.rs
UTF-8
4,281
3.96875
4
[ "MIT" ]
permissive
use crate::{ machine::Machine, opcode::{OpCode, OpCodeType, Operand}, }; // Intcode instructions come in two parts: an opcode and one or more operands. // This enum specifies an instruction, which collects the opcode and its // arguments into a convenient data structure. #[derive(Debug)] pub enum Instruction {...
true
cd8973d0c4fa2062a7fb04244c7bcdfbef08d4ee
Rust
JMAlego/rusty_jello
/src/machine.rs
UTF-8
6,990
3.140625
3
[ "BSD-3-Clause" ]
permissive
//! Representation of the Rusty Jello machine use std::fmt; use instructions; use std::time::Duration; use std::thread; pub enum Register { R0 = 0, R1 = 1, R2 = 2, R3 = 3, } pub struct Flags { pub halt: bool, pub carry: bool, pub overflow: bool, pub test: bool, } impl fmt::Debug for Flags { fn fmt...
true
541ebf070482bbb671be9c652d6058c8736c4194
Rust
LuisAyuso/quepintoyo
/qpy_core/src/error.rs
UTF-8
647
2.6875
3
[]
no_license
#[derive(Debug)] pub enum Conversion { BsonFailed, JsonFailed, VersionUnknown, } impl std::convert::From<crate::error::Conversion> for rocket::http::Status { fn from(error: crate::error::Conversion) -> rocket::http::Status { println!("error: {:?}", error); rocket::http::Status::Internal...
true
b6d49bd075e2ca07d127b632375dd2a70a6acc56
Rust
infiniteprairie/rust-newbie
/simple_tree/src/main.rs
UTF-8
1,508
3.328125
3
[]
no_license
//! This sample program, `simple_tree`, is taken from the Rust Book, //! chapter 15.6 (https://doc.rust-lang.org/book/ch15-06-reference-cycles.html) //! on smart pointers, strong and weak references //! use std::cell::RefCell; use std::rc::{Rc, Weak}; #[derive(Debug)] struct Node { value: i32, parent: RefC...
true
db1dce83fbacd7cf542337480a82a5323a4d28d8
Rust
acmfi/AdventCode
/2022/andsanmar/src/day12.rs
UTF-8
2,434
3.25
3
[]
no_license
use std::collections::HashSet; type Struct = Vec<Vec<u64>>; fn find(c: char, l : &Struct) -> (usize, usize){ let code = c as u64; for i in 0..l.len() { for j in 0..l[i].len() { if l[i][j] == code { return (i,j) } } } (0,0) } fn update_elems((i,...
true
441c70d1e98f833516d26360ba2e8625ce77e50f
Rust
mlsteele/wavebrush
/lib/src/sample.rs
UTF-8
1,339
3.265625
3
[]
no_license
// Convert between sample representations. pub trait SampleConvertTrait<X,Y> { fn convert(x: X) -> Y; } pub struct SampleConvert {} impl SampleConvertTrait<i32, f64> for SampleConvert { fn convert(x: i32) -> f64 { match x as f64 / std::i32::MAX as f64 { y if y > 1. => 1., y if...
true
114eb3c07c904e9c56296749f97080ed6038696a
Rust
aDotInTheVoid/noria
/server/src/controller/security/group.rs
UTF-8
1,971
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::controller::security::policy::Policy; use nom_sql::parser as sql_parser; use nom_sql::SqlQuery; use serde_json; use serde_json::Value; #[derive(Clone, Debug, Hash, PartialEq, Serialize, Deserialize)] pub struct Group { name: String, membership: SqlQuery, policies: Vec<Policy>, } impl Group { ...
true
befa2cd77fb441bccd068f1df0ccfa9a0d7d496d
Rust
etclabscore/jade-signer-rpc
/src/util/rlp.rs
UTF-8
15,289
3.53125
4
[ "Apache-2.0" ]
permissive
//! RLP (Recursive Length Prefix) is to encode arbitrarily nested arrays of binary data, //! RLP is the main encoding method used to serialize objects in Ethereum. //! //! See [RLP spec](https://github.com/ethereumproject/wiki/wiki/RLP) use super::{bytes_count, to_bytes, trim_bytes}; /// The `WriteRLP` trait is used ...
true
8d13cc0f5b545e66b929e4da0d385db4d0d5543d
Rust
voximity/omegga-discord-lite
/src/format.rs
UTF-8
2,276
3.234375
3
[]
no_license
use lazy_static::lazy_static; use regex::Regex; #[derive(Debug, Clone)] pub struct Formatter { pub key: &'static str, pub value: String, } impl Formatter { pub fn format(&self, source: String) -> String { source.replace(&format!("${}", self.key), self.value.as_str()) } } /// Compose a Vec<T> ...
true
074ab67a2e492ef6b68bef372008d94bec85a414
Rust
PaulRaUnite/RME
/src/urm.rs
UTF-8
7,356
3.078125
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::{Debug, Formatter}; use std::ops::{Index, IndexMut}; use itertools::{enumerate, Itertools}; use pest::Parser; use std::collections::HashMap; #[derive(Debug)] pub enum Instruction { Zero(usize), Increase(usize), Translate { from: usize, to: usize, }, Jum...
true
b4ba76f8e547f2094c61c52f53235e9f68bb340c
Rust
bailion/ophelia
/logic/src/parse/template.rs
UTF-8
1,649
2.84375
3
[]
no_license
use std::{fmt::Display, path::PathBuf}; use super::{block::Block, Parse, ParseResult}; #[derive(Debug, Clone, PartialEq)] pub struct Template<'i> { path: Option<PathBuf>, expressions: Vec<Block<'i>>, } impl<'i> Parse<'i> for Template<'i> { fn parse(mut input: &'i str) -> super::ParseResult<Self> { ...
true
9b766e990672edd0852912efc8e9fe340ae9dd15
Rust
concurrentes/tp2
/src/main.rs
UTF-8
11,153
2.515625
3
[]
no_license
#[macro_use] extern crate log; extern crate fern; extern crate chrono; extern crate libc; mod configuration; use configuration::ServerData; use configuration::ClientData; use std::sync::mpsc; use std::thread; use std::time; use std::time::SystemTime; use std::env; /*================================================...
true
faf99213b2e8fb23a45f56db715651501819f87e
Rust
pjohansson/advent_of_code
/src/day2.rs
UTF-8
3,028
3.875
4
[]
no_license
struct Rectangle { x: i32, y: i32, z: i32 } // Lesson learned: How to implement methods impl Rectangle { fn new(input: &str) -> Rectangle { let mut sides = Vec::new(); let input_split: Vec<&str> = input.split('x').collect(); for cs in input_split { // Lesson learne...
true
897717cc051f962e36f359fe895508a1b5c415d0
Rust
CGF95/WindWakerDebugMenu
/src/src/utils.rs
UTF-8
2,010
2.890625
3
[ "MIT" ]
permissive
use libtww::prelude::*; use libtww::Link; use libtww::link::CollisionType; use libtww::game::Console; use main_menu; use warp_menu; use flag_menu; use inventory_menu; use cheat_menu; use controller; use spawn_menu; pub fn clear_menu() { let console = Console::get(); let mut lines = &mut console.lines; for...
true
1b06a42bceb7ec7f35a65d170428e5baf80fe1f6
Rust
iprs-dev/iprs
/src/peer_id.rs
UTF-8
8,369
2.765625
3
[ "MIT" ]
permissive
//! Module implement Peer ID for libp2p network. _Refer [peer-id] spec //! for details. //! //! [peer-id]: https://github.com/libp2p/specs/blob/master/peer-ids/peer-ids.md use bs58; use multibase::Base; use rand::Rng; use std::{fmt, hash}; use crate::{ identity::PublicKey, multibase::Multibase, multicode...
true
855764f02539ba7bba91c9f7d0765122728e75b8
Rust
wtommyw/haste-cli
/src/haste/options.rs
UTF-8
7,711
3.5625
4
[ "MIT" ]
permissive
use regex::Regex; pub struct Options { pub filename: String, pub url: String, pub mode: Mode } pub enum Mode { Upload, Download } impl Options { pub fn new(args: &[String]) -> Result<Options, &'static str> { if args.len() < 2 { return Err("Missing arguments"); } ...
true
fc0f77bbc221ebc7d4dbc1628c435955bc5440a0
Rust
ouranoshong/rust_by_example
/scope_borrow_ref/src/main.rs
UTF-8
956
3.71875
4
[]
no_license
#[derive(Clone, Copy)] struct Point{ x: i32, y: i32 } fn main() { // println!("Hello, world!"); let c = 'Q'; let ref ref_c1 = c; let ref_c2 = &c; println!("ref_c1 equals ref_c2: {}", *ref_c1 == *ref_c2); let point = Point {x: 0, y: 0}; let _copy_of_x = { let Point {x: ref ref_...
true
f6bf82fad8fdf8a06378e2a79d3b73a90e82f6c0
Rust
ayourtch/pachev_ftp
/ftp_server/src/main_commands.rs
UTF-8
13,524
2.578125
3
[ "MIT" ]
permissive
use rand::Rng; use rand; use std::fs::OpenOptions; use std::io::BufReader; use std::string::String; use std::net::{TcpStream, TcpListener, Shutdown}; use std::path::Path; use std::fs; use std::fs::File; use user::User; use server::FtpMode; use server; /// # The FTP List command /// This function implements the list ...
true
e98c930a124d60a0afdfdd7d87f26ce5e4df4f3e
Rust
toumorokoshi/disp
/src/function_loader/mod.rs
UTF-8
4,193
3.15625
3
[]
no_license
use super::{parse_macro, Compiler, DispError, DispResult, MacroMap, Token}; use std::collections::HashMap; use std::rc::Rc; #[derive(Debug)] pub struct UnparsedFunction { pub args: Vec<String>, pub body: Token, } impl UnparsedFunction { pub fn new(args: Vec<String>, body: Token) -> UnparsedFunction { ...
true
3127a80bf26d0c96f3d207b4df584ebedebbd25c
Rust
buratina/Network-Programming-with-Rust
/Chapter07/futures-ping-pong/src/main.rs
UTF-8
846
2.75
3
[ "MIT" ]
permissive
extern crate futures; extern crate rand; extern crate tokio_core; use std::thread; use std::fmt::Debug; use std::time::Duration; use futures::Future; use rand::{thread_rng, Rng}; use futures::sync::mpsc; use futures::{Sink, Stream}; use futures::sync::mpsc::Receiver; fn sender() -> &'static str { let mut d = thr...
true
31d9d7324d990e2ce8aff64560e5a7af6ff872ba
Rust
ZorinArsenij/nginx
/src/pool/pool.rs
UTF-8
713
2.671875
3
[]
no_license
use super::worker::Worker; use std::net; use std::sync::{mpsc, Arc, Mutex}; pub struct Pool { _workers: Vec<Worker>, sender: mpsc::Sender<net::TcpStream>, } impl Pool { pub fn new(root: String, cap: usize) -> Pool { let (s, r) = mpsc::channel(); let receiver = Arc::new(Mutex::new(r)); ...
true
29af68e1abf94652267a60f5537cbd4eefc635c4
Rust
richo/rs-beef
/src/parser.rs
UTF-8
1,457
3.390625
3
[]
no_license
use std::io::Read; use std::fs::File; pub type Program = Vec<OpCode>; #[derive(Debug)] pub enum OpCode { Lshift, Rshift, Putc, Getc, Inc, Dec, Loop(Vec<OpCode>), } pub fn parse_file(filename: &str) -> Option<Program> { let mut program: Program = vec!(); let mut loop_stack: Vec<Vec...
true
fa367de9f388259ac550b0c5dce4cfd12088df6b
Rust
KodrAus/fluent_builder
/src/lib.rs
UTF-8
7,055
4.1875
4
[ "MIT" ]
permissive
/*! A simple builder for constructing or mutating values. This crate provides a simple `FluentBuilder` structure. It offers some standard behaviour for constructing values from a given source, or by mutating a default that's supplied later. This crate is intended to be used within other builders rather than consumed b...
true
1c50680d0969cfa8a5cd1f3b5d4efff70ccb48b3
Rust
carrotflakes/silver
/src/rng.rs
UTF-8
789
2.796875
3
[]
no_license
use std::cell::UnsafeCell; use rand::SeedableRng; use rand_pcg::Lcg128Xsl64; pub type MainRng = Lcg128Xsl64; thread_local!( pub static THREAD_RNG_KEY: UnsafeCell<MainRng> = { let rng = SeedableRng::seed_from_u64(0); UnsafeCell::new(rng) } ); #[inline] pub fn with<F: FnOnce(&mut MainRng) -> R...
true
365e2d9bed300ea99b2d32a38fabd26caa0e6470
Rust
imp/httptin
/src/get/origin.rs
UTF-8
962
2.71875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::net::IpAddr; use hyper::header::ContentType; use hyper::server::{Request, Response}; use serde_json::to_string_pretty; use makeresponse::MakeResponse; #[derive(Serialize)] pub struct Origin { ip: IpAddr, port: u16, ipv4: bool, ipv6: bool, } impl Origin { pub fn from_request(request: &Re...
true
9da16a6716c09ce88cc2750a548572a732d50ad9
Rust
shaipe/rust-tools
/crawler/examples/req.rs
UTF-8
1,773
3.140625
3
[]
no_license
extern crate reqwest; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; use std::env; use reqwest::Client; use reqwest::Error; use std::time::Duration; use reqwest::ClientBuilder; fn main() -> Result<(), Error> { let _ = run1(); let _ = run(); Ok(()) } fn run1() -> Result<()...
true
68333cb72f77f16be009b46cc5578bdd3323724a
Rust
wcpannell/kea-hal
/src/adc.rs
UTF-8
26,336
3.203125
3
[ "MIT" ]
permissive
//! The ADC Interface //! //! The ADC is disabled at startup and must be enabled (by calling //! [Adc<Disabled>::enable]) before any of its registers can be accessed //! (read or write). Attempts to access these registers will trigger a hardware //! generated HardFault, which by default resets the microcontroller. //! ...
true
11825a9621f704a2aed2504b4ac86b89a58ccc8a
Rust
sahil-blulabs/learning_rust
/Lesson1/45_option_enum.rs
UTF-8
305
3.578125
4
[]
no_license
fn main() { let name = String::from("Domenic"); println!( "Character at index 8: {}", match name.chars().nth(6) { Some(c) => c.to_string(), None => "No character at index 8!".to_string(), } ); // FYI: name.chars().nth(8) return either `Some` or `None` case. }
true
16dc1a6a5b6223003724dfa30d8fb0edb5ff708c
Rust
fmdkdd/asobiba
/rust/nil-checker/src/bin/check.rs
UTF-8
1,060
2.953125
3
[]
no_license
extern crate nil_checker; use std::io::{self, Read}; use nil_checker::parser::{Node, NodeKind, Parser, ParseTree}; #[derive(Debug)] struct Constraint { desc: String, } struct Checker<'a> { parse_tree: &'a ParseTree, } impl<'a> Checker<'a> { fn new(p: &'a ParseTree) -> Self { Checker { parse_tree: p...
true
a225e996318ca659646b491521c368ceb8fe1da4
Rust
yasu0001/rbre
/core/src/vulkano_surface_context.rs
UTF-8
2,905
2.609375
3
[]
no_license
use vulkano::instance::{Instance, PhysicalDevice}; use vulkano::device::{Queue, Device}; use vulkano::image::SwapchainImage; use vulkano::swapchain::{Swapchain, Surface, SurfaceTransform, PresentMode, SwapchainAcquireFuture}; use vulkano::swapchain; use vulkano::format::Format; use winit::Window; use std::sync::Arc; ...
true
1f853f999d48a127055f19e9f649fadab0c2581c
Rust
Disasm/stm32f4xx-hal
/src/usb.rs
UTF-8
2,418
2.5625
3
[ "0BSD", "BSD-3-Clause" ]
permissive
//! USB peripheral //! //! Requires the `synopsys-usb-otg` feature and one of the `usb_fs`/`usb_hs` features. //! See https://github.com/stm32-rs/stm32f4xx-hal/tree/master/examples //! for usage examples. use crate::stm32; #[cfg(feature = "usb_fs")] use crate::gpio::{Alternate, AF10, gpioa::{PA11, PA12}}; #[cfg(featu...
true
c4d3cead19dbcbcf447fb7e1d8b1573753ff6ed3
Rust
trayanr/fvm
/src/alias.rs
UTF-8
3,546
2.9375
3
[]
no_license
use crate::{installation_path::get_installation_path, releases::Release}; use std::io::prelude::*; use std::{fmt, fs::File, fs::OpenOptions, io::ErrorKind, io::Read, path::PathBuf}; pub struct AliasFile { aliases: Vec<Alias>, } impl AliasFile { pub fn open() -> AliasFile { let aliases = get_aliases_pa...
true
6d561ed87e768ef38217950c59b34d9b65633e74
Rust
anasahmed700/Rust-examples
/ch04.1_ownership/src/main.rs
UTF-8
1,685
4.125
4
[]
no_license
fn main() { // types of string (&str and String) // 1. hard coded string literal (&str) are immutable which stores memory on the stack which known at compile time let mut _primitive_str = "Hello Literals"; // _primitive_str = _primitive_str + "some"; // can't concatenate // 2. string complex (Stri...
true
3f46f594738f85b0c1524f14a13a1e9d795eda3a
Rust
rkat0/AtCoder
/ABC095_ARC096/B.rs
UTF-8
691
3.125
3
[]
no_license
use std::io::*; fn read<T: std::str::FromStr>() -> T { let stdin = stdin(); let mut buf = String::new(); stdin.lock().read_line(&mut buf); buf.trim().parse().ok().unwrap() } fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>().trim().split_whitespace() .map(|w| w.parse().ok().unwrap())....
true
055c6b875a6f97406354fc1f86893c2dbb397995
Rust
xiaochai/batman
/RustProject/example/src/lib.rs
UTF-8
485
2.90625
3
[]
no_license
//! # Art //! //! 测试用于艺术建模的库 pub use crate::kinds::PrimaryColor; pub use crate::kinds::SecondaryColor; pub use crate::utils::mixed; pub mod kinds { pub enum PrimaryColor { Red, Yellow, Blue, } pub enum SecondaryColor { Orange, Green, Purple, } } pub mo...
true
7d79f3d0e0ed1b31f7d447f12c949a28f821916e
Rust
GaiaWorld/pi_lib
/deque/src/deque.rs
UTF-8
7,591
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
//! 双端队列核心逻辑,通常不单独使用,而是需要与一个索引工厂配合使用。 //! 关于索引的意义,请参考:https://github.com/GaiaWorld/pi_lib/tree/master/dyn_uint //! 由于需要从任意位置删除元素,我们未采用标准库使用vec作为双端队列内部容器的做法。 //! 如果要从任意位置删除,链表是个不错的选择。 //! //! 简单的使用本双端队列,请使用slab_deque模块提供的双端队列 //! 要查看本模块的用法,可以参照slab_deque模块,和https://github.com/GaiaWorld/pi_lib/tree/master/task_pool库 us...
true
094a4e95b417a09a47fb4f85668145233aff7b3f
Rust
tillrohrmann/rust-challenges
/euler-67/src/lib.rs
UTF-8
975
3.296875
3
[ "Apache-2.0" ]
permissive
use std::fs::File; use std::io::{BufReader, BufRead}; use std::io::Error; use std::io::Result; pub fn find_maximum_path(filename: &str) -> Result<u64> { let file = File::open(filename)?; let buffered = BufReader::new(file); let result: Vec<String> = buffered.lines().map(|line| line.unwrap()).collect(); ...
true
d6046c20893ebc547213b050954ff45b4fbed705
Rust
RonquilloAeon/cryptopanic-portfolio-tracker-rust
/src/main.rs
UTF-8
6,193
3.0625
3
[]
no_license
use std::collections::HashMap; use std::fs::create_dir; use std::path::PathBuf; use chrono::Utc; use clap::{App, Arg, ArgMatches}; use dirs::home_dir; use preferences::{AppInfo, Preferences, PreferencesMap}; use reqwest; use serde_json; use tokio::fs::File; use tokio::io::AsyncWriteExt; const AUTHOR: &str = "Ronquill...
true
b055d929e9715f026a9e20814c225ee5863f39de
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-18783.rs
UTF-8
674
3.34375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std::cell::RefCell; fn main() { let mut y = 1; let c = RefCell::new(vec![]); c.push(Box::new(|| y = 0)); c.push(Box::new(|| y = 0)); //~^ ERROR cannot borrow `y` as mutable more than once at a time } fn ufcs() { let mut y = 1; let c = RefCell::new(vec![]); Push::push(&c, Box::new(|| y...
true
54a706367fbf0e7cf0f52a4bbba8a7de36f774c7
Rust
justinj/last-layer-algs
/src/corner_permutation.rs
UTF-8
3,857
2.671875
3
[]
no_license
use prunable::Prunable; pub const CP_SOLVED: usize = 0; const NUM_CORNERS: usize = 8; const FACTORIAL: [u16; 8] = [ 1, 1, 2, 6, 24, 120, 720, 5040, ]; pub type CPIndex = usize; const NUM_PERMUTATIONS: usize = 40320; #[derive(Debug, Copy, Clone)] struct CornerPermutation { state:...
true
3588a7e3519601c7d5ee15988ffd09bf6d12767e
Rust
Rahix/shared-bus
/src/mutex.rs
UTF-8
7,028
3.6875
4
[ "MIT", "Apache-2.0" ]
permissive
use core::cell; /// Common interface for mutex implementations. /// /// `shared-bus` needs a mutex to ensure only a single device can access the bus at the same time /// in concurrent situations. `shared-bus` already implements this trait for a number of existing /// mutex types. Most of them are guarded by a featur...
true
47e3d6871df1e7b0bbb7cd4bb956ec066bd87eed
Rust
azriel91/autexousious
/crate/collision_model/src/config/hit_repeat_delay.rs
UTF-8
627
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use amethyst::ecs::{storage::VecStorage, Component}; use derivative::Derivative; use derive_more::{Add, AddAssign, Display, From, Sub, SubAssign}; use numeric_newtype_derive::numeric_newtype; use serde::{Deserialize, Serialize}; /// Default number of ticks to wait before another hit may occur. const HIT_REPEAT_DELAY_D...
true
9175fb6d702d78363bdd3e2c8294194b8fd3dc18
Rust
jasilven/chat
/src/main.rs
UTF-8
9,745
2.875
3
[]
no_license
use anyhow::Result; use async_std::channel::{bounded, Receiver, Sender}; use async_std::io::BufReader; use async_std::net::{TcpListener, TcpStream}; use async_std::prelude::*; use async_std::task; use std::collections::HashMap; use std::net::{SocketAddr, SocketAddrV4}; use rand::distributions::Alphanumeric; use rand::...
true
78dbde10ae31c2d0e8315fd6dfa61d20e9fcbc44
Rust
arbaregni/resolution-prover
/src/prover/mod.rs
UTF-8
18,170
3.1875
3
[]
no_license
#[macro_use] mod clause; pub use clause::*; mod term_tree; pub use term_tree::*; mod clause_set; pub use clause_set::*; use crate::ast::{Expr, SymbolTable}; use crate::error::BoxedErrorTrait; /// Uses proof by contradiction to search for a proof of `goal` from `givens` /// If it runs without internal error, returns ...
true
58a2752da3a52346144cc4d47d447c1d777511b4
Rust
trolleyman/Portal2
/src/key.rs
UTF-8
883
2.984375
3
[]
no_license
#[allow(unused_imports)] use prelude::*; use std::collections::HashSet; use glutin::VirtualKeyCode as Key; use glutin::ElementState; pub struct KeyboardState { pressed_keys: HashSet<Key>, } impl KeyboardState { pub fn new() -> KeyboardState { KeyboardState { pressed_keys: HashSet::new(), } } pub fn key_st...
true
31840f944151f7cef630e173cb0b497c0be11568
Rust
MovAh13h/mkv
/src/main.rs
UTF-8
3,001
2.609375
3
[]
no_license
mod record; mod hash; mod remote; mod mkv; use mkv::Minikeyvalue; use clap::{App, Arg}; fn main() { let matches = App::new("Minikeyvalue") .version("0.1.0") .author("Tanishq Jain <tanishqjain1002@gmail.com>") .about("A Rust port of minikeyvalue (https://github.com/geohot/minikeyvalue)") .usage("...
true
7c2048d9edc58f5dbbcc6251ab158cf388d68592
Rust
llogiq/openpgp
/src/lib.rs
UTF-8
25,757
3.015625
3
[]
no_license
//! The goal of this crate is to interact with the OpenPGP-format, //! i.e. parse it and produce correct PGP files. OpenPGP can describe //! so many things that parsing is much more pleasant to write in an //! event-driven way, and the resulting API is also smaller. //! //! This version is not yet able to produce encr...
true
bf121fc422bcf809d9a81b8b03a7d4b57d4d4eb8
Rust
donaldducky/advent-of-code
/2019/day9/src/main.rs
UTF-8
596
2.859375
3
[]
no_license
use std::sync::mpsc; use std::thread; use intcode; fn main() { let program = intcode::read_program("input.txt"); println!("Part 1: {}", boost_keycode(program.clone(), 1)); println!("Part 2: {}", boost_keycode(program.clone(), 2)); } fn boost_keycode(program: Vec<i128>, input: i128) -> i128 { let mut ...
true
edea352e282c4ab7533674d291778e8bc3a4b0f1
Rust
hexgolems/td
/src/background.rs
UTF-8
2,868
2.796875
3
[]
no_license
use crate::algebra::{Point, Vector}; use crate::assets::{Data, ImgID}; use crate::playing_state::PlayingState; use ggez::graphics; use ggez::graphics::Color; use ggez::{Context, GameResult}; use rand::prelude::*; use rand::thread_rng; pub struct Wave { pos: Point, disp: ImgID, time: f32, } impl Wave { ...
true
879deeaf0a3174dcfcd8b5a8193d06d7161fe53f
Rust
gontard/rchess
/crate-wasm/src/utils.rs
UTF-8
1,140
3.109375
3
[]
no_license
use chess::{ChessMove, Square}; pub fn set_panic_hook() { // When the `console_error_panic_hook` feature is enabled, we can call the // `set_panic_hook` function at least once during initialization, and then // we will get better error messages if our code ever panics. // // For more details see ...
true
32259e0b98bf38aa813e47e0a5e9b8e3ec7ca1ee
Rust
ocstl/project_euler
/src/bin/problem46.rs
UTF-8
440
3.203125
3
[]
no_license
use primal::is_prime; /// What is the smallest odd composite that cannot be written as the sum of a prime and twice a /// square? fn main() { let answer = (5u64..) .step_by(2) .find(|&n| { !is_prime(n) && (1..) .take_while(|&x| 2 * (x * x) < n) ...
true
a9cd2a089747223a3afc4b3a11b9a13d9b098e93
Rust
DjDeveloperr/dapi-rs
/v8-format/src/ser.rs
UTF-8
27,278
2.8125
3
[ "Apache-2.0" ]
permissive
#![allow(dead_code)] #![allow(unused_variables)] use crate::common::Error; use serde::ser; use serde::Serialize; use std::collections::HashMap; use std::collections::HashSet; use integer_encoding::VarInt; use crate::common::ArrayBufferViewType; use crate::common::ErrorType; use crate::common::Value; pub const FORMA...
true
297c66637d8575968a1b71d51014ff762ed223ba
Rust
Pfarrer/rust-jvm
/_deprecated/src/vm/eval/istore_x.rs
UTF-8
869
3.046875
3
[]
no_license
use vm::Vm; use vm::primitive::Primitive; /// Can handle instructions istore and istore_<n>. pub fn eval(vm: &mut Vm, code: &Vec<u8>, pc: u16) -> Option<u16> { // Check which instruction triggered this call, if it was istore, then one byte should be read, // when it was istore_<n>, the index is implicit le...
true
7738cff61f52623ec1eddb7332c80ccf2fa7ba60
Rust
schoenenberg/oauth2-rs
/examples/auth0_async_devicecode.rs
UTF-8
3,148
3.09375
3
[ "Apache-2.0", "MIT" ]
permissive
//! //! This example showcases the Auth0 device authorization flow using the async methods. //! //! Before running it, you'll need to create an API and an Application on [auth0.com](https://auth0.com). Take a look at this tutorial, for the details: [Call Your API Using the Device Authorization Flow](https://auth0.com/d...
true
37b63b26738e41f86f3741c814a59abb6ae243ef
Rust
rust-lang/rustlings
/exercises/if/if1.rs
UTF-8
565
3.3125
3
[ "MIT" ]
permissive
// if1.rs // // Execute `rustlings hint if1` or use the `hint` watch subcommand for a hint. // I AM NOT DONE pub fn bigger(a: i32, b: i32) -> i32 { // Complete this function to return the bigger number! // Do not use: // - another function call // - additional variables } // Don't mind this for now :...
true
fee443453284be0c30e4cb0ee44b2a15249592d6
Rust
glurbi/rustwars
/count-of-positives-slash-sum-of-negatives/src/lib.rs
UTF-8
677
3.546875
4
[]
no_license
// https://www.codewars.com/kata/count-of-positives-slash-sum-of-negatives/ #[allow(dead_code)] fn count_positives_sum_negatives(input: Vec<i32>) -> Vec<i32> { if input.is_empty() { return vec![] } let positives = input.iter().filter(|&i| *i > 0).count() as i32; let negatives = input.iter().fi...
true
33fefff5a15042aeb73a9df84d159ed088357b01
Rust
simrit1/scrappybot
/src/notification.rs
UTF-8
1,550
2.640625
3
[]
no_license
use crate::api::telegram_api::{SendMessage, TelegramClient}; use anyhow::Result; use core::fmt::Display; use super::state::Diff; pub trait NotificationService { fn notify<T: Display>(&mut self, diff: Diff<T>) -> Result<()>; } pub struct TelegramService { client: TelegramClient, chat_id: String, } impl Te...
true
7201c9cc56d6f80fee5bf21a5a151de9565f7844
Rust
arvo/arvo
/src/lexer/token_test.rs
UTF-8
5,946
3.09375
3
[ "MIT" ]
permissive
use super::span::{Span}; use super::token::{Token}; #[test] fn tokenise_literals() { assert_eq!( Token::tokenise("", "true"), vec![Token::Bool(true, Span::new("", 1, 1, 1, 4))] ); assert_eq!( Token::tokenise("", "false"), vec![Token::Bool(false, Span::new("", 1, 1, 1, 5))] ...
true
6b31a4fcffb41502d83155fa1249c530257a39bf
Rust
fhnw-rust-group/begin-rust-book-examples-tricktron
/02/chapter2/src/main.rs
UTF-8
1,119
3.796875
4
[]
no_license
fn main() { // this is a comment let apples: i32 = { println!("I'm about to figure out how many apples there are"); let x = 10 + 5; println!("Now I know how many apples there are"); x }; println!("I will be evaluated after the fist statement with its side-effects"); p...
true
b7fdb624e71317a64111066d46298604e739120b
Rust
facebookexperimental/MIRAI
/checker/tests/run-pass/lazy_const_array.rs
UTF-8
550
2.5625
3
[ "MIT" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the root directory of this source tree. // // A test that generates a ConstValue::Unevaluated reference to a constant array // and that checks that MIRAI finds the constant in th...
true
574429a5c244100faa599d83072bccf5a862b514
Rust
rusticata/asn1-rs
/src/asn1_types/oid.rs
UTF-8
16,757
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::*; use alloc::borrow::Cow; #[cfg(not(feature = "std"))] use alloc::format; use alloc::string::{String, ToString}; use alloc::vec::Vec; use core::{ convert::TryFrom, fmt, iter::FusedIterator, marker::PhantomData, ops::Shl, str::FromStr, }; #[cfg(feature = "bigint")] use num_bigint::BigUint; use num_trait...
true
db82cbc3352a20b09ba2588a869e8e86a119cd16
Rust
ExpressGradient/learn-rust-monorepo
/concurrency/src/bin/message_passing.rs
UTF-8
1,024
3.375
3
[]
no_license
use std::sync::mpsc; use std::thread; use std::time::Duration; fn main() { let ( tx, rx ) = mpsc::channel(); let tx_clone = mpsc::Sender::clone(&tx); thread::spawn(move || { let messages: Vec<String> = vec![ "Hello World!".to_string(), "I'm Express".to_string(), ...
true
e5e19b219f604c87c699ad26ca338c98971afcbd
Rust
SnakeSolid/rust-team-activity
/src/stream/convert.rs
UTF-8
5,640
3.21875
3
[ "MIT" ]
permissive
use rand; use rand::Rng; use serde_yaml; use std::collections::HashMap; use std::collections::HashSet; use std::hash::Hash; use config::ActivityConfig; use config::Config; use config::IgnoreConfig; use config::MessageGroup; use entity::Entry; use entity::Object; #[derive(Debug)] pub struct FeedToActivity<'a> { ig...
true