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
592edde91975a5315e4ff0d75661f1bbb81373bd
Rust
waldemarnt/elasticsearch-data-generator
/src/generator/mod.rs
UTF-8
746
2.984375
3
[]
no_license
extern crate chrono; extern crate rustc_serialize; use self::chrono::*; use self::rustc_serialize::json::*; use std::collections::BTreeMap; pub fn generate(obj: &Object) -> String { let mut map = BTreeMap::new(); for (key, value) in obj.iter() { let value_type = match Some(&*value.to_string()) { ...
true
0d1b90ef3202dfc46a9e3d0e560e2b23336eaa1f
Rust
duncanrhamill/scos
/src/task/keyboard.rs
UTF-8
3,873
2.890625
3
[]
no_license
// --------------------------------------------------------------------------- // USE STATEMENTS // --------------------------------------------------------------------------- use crate::{print, println}; use conquer_once::spin::OnceCell; use crossbeam_queue::ArrayQueue; use core::{pin::Pin, task::{Poll, Context}}; u...
true
0205f804789b508f32bea16ab3069fa721b08ece
Rust
isgasho/rust-dns
/src/msg/record.rs
UTF-8
3,474
2.765625
3
[ "BSD-2-Clause" ]
permissive
pub use super::{Type,Class,Name,DNSNameReader,DNSNumberReader}; use std::io; #[deriving(PartialEq,Show,Clone)] pub struct Question { pub qname: Name, pub qtype: Type, pub qclass: Class, } impl Question { pub fn new() -> Question { Question { qname: Name::new(), qtype: ...
true
74e25ccd502578b74fc73ac6c8620da2608de1c3
Rust
njeisecke/umya-spreadsheet
/src/structs/drawing/spreadsheet/blip_fill.rs
UTF-8
4,173
2.75
3
[ "MIT" ]
permissive
// xdr:blipFill use super::super::Blip; use super::super::SourceRectangle; use super::super::Stretch; use writer::driver::*; use reader::driver::*; use quick_xml::events::{Event, BytesStart}; use quick_xml::Writer; use quick_xml::Reader; use std::io::Cursor; use tempdir::TempDir; #[derive(Default, Debug)] pub struct B...
true
8e934aad8c7b5430dae71439d535c081b88448d5
Rust
lukaspustina/fastfile
/src/fastfile.rs
UTF-8
13,962
2.90625
3
[ "MIT" ]
permissive
use crate::{errors::*, os, strategy}; use failure::Fail; use memmap::Mmap; use std::{fs::File, io, path::Path}; pub const MIN_READ_BUF_SIZE: usize = os::PAGE_SIZE; pub const MAX_READ_BUF_SIZE: usize = 4 * 1024 * 1024; /// Allocate a memory buffer on the stack and initialize it for the reader /// /// This macro takes...
true
2fa6c555103385ec3c8fad483633efe15e8ef32c
Rust
mjmckinnon/file2addr
/src/main.rs
UTF-8
1,803
3.015625
3
[]
no_license
extern crate bitcoin; extern crate secp256k1; extern crate rand; extern crate crypto; extern crate hex; use bitcoin::util::address::{Address,Privkey}; use secp256k1::Secp256k1; use secp256k1::key::SecretKey; use bitcoin::network::constants::Network; use crypto::digest::Digest; use crypto::sha2::Sha256; use std::env; u...
true
976a5433a80d629c91f4d380a3d54cd2bda6fe6e
Rust
jean553/rust-radix-trie
/rust-radix-trie/src/tests.rs
UTF-8
30,743
3.375
3
[]
no_license
#[cfg(test)] mod tests { use rt::RadixTrie; #[test] fn test_node_creation_and_insertion() { let mut node = RadixTrie::new("hello"); assert_eq!(node.exists("he"), true); assert_eq!(node.exists("hello"), true); assert_eq!(node.exists("hellowor"), false); const INS...
true
231b4b9e23ba2da073c848c9dfa329f4e590b0ca
Rust
theseus-os/Theseus
/kernel/nano_core/src/stack_smash_protection.rs
UTF-8
705
2.9375
3
[ "MIT" ]
permissive
//! Simple C-compatible function that panics after a stack smash has occurred. //! //! This is used by C compiler instrumentation for C code that was compiled with //! support for stack smashing protection. //! Basically, when a stack smash is detected, the `__stack_chk_fail()` function //! is invoked as a callbac...
true
22d25b0cf02e2f2a1b6254c0cc1a3042c33bbb82
Rust
bretzle/kunzite
/crates/kunzite/src/cpu/mod.rs
UTF-8
17,364
2.859375
3
[]
no_license
//! The cpu use crate::{ cpu::instruction::{Flag, Instruction, Register16}, memory::Memory, util::{lower, upper}, }; use self::{instruction::Register8, register::Registers}; mod decode; pub mod instruction; mod register; /// The cpu #[derive(Default)] pub struct Cpu { /// Program counter pub pc: u16, /// Cpu ...
true
dd0bccba2316d408fcc8bc0819b8b87117c45c92
Rust
dongri/team
/src/models/tag.rs
UTF-8
3,528
3
3
[ "MIT" ]
permissive
use postgres::error::Error; use db; use models; use helper; #[derive(Serialize, Debug, Default)] pub struct Tag { pub id: i32, pub name: String, } pub fn select_or_create_tag_id(conn: &db::PostgresConnection, tag_name: &str) -> Result<(i32), Error> { let rows = &conn.query("SELECT id from tags where name ...
true
b0a681704d2a4cae9ca9c8295b55e7a64ff00489
Rust
gzbakku/gzbdb
/gobject/src/lib.rs
UTF-8
6,943
2.625
3
[]
no_license
pub mod build; pub mod value; mod common; pub mod parser; pub mod validater; pub mod reader; pub use value::{gObject,gObjectValue}; pub use common::Error; pub use parser::start as parse; pub use validater::{validate,gSchema,gSchemaValue}; pub use parser::{Blocks,Block}; pub use reader::{gObjectReader,gObjectReaderSta...
true
5f83c3edad7fd158547db20c33b3b9b68598a769
Rust
takushi-m/rust-fid
/src/lib.rs
UTF-8
2,300
3.125
3
[ "MIT" ]
permissive
use std::cmp::min; use std::vec::Vec; pub struct Fid<'a> { raw: &'a [u8] ,big_block_size: usize ,big_blocks: Vec<usize> ,small_block_size: usize ,small_blocks: Vec<usize> } impl<'a> Fid<'a> { pub fn new(bv: &[u8]) -> Fid{ let mut ret = Fid { raw: bv ,big_block_s...
true
1f4a14738b607c1ffd7d31d54f8d710b407b65af
Rust
moonmile/gyakubiki-rust
/ch02/grm041/src/main.rs
UTF-8
613
4
4
[]
no_license
fn main() { // 比較演算子 let x = 10 ; let y = 10 ; println!("x:{} y:{}", x, y ); if x != y { println!("x と y は等しくない"); } else { println!("x と y は等しい"); } let y = 20 ; println!("x:{} y:{}", x, y ); if x != y { println!("x と y は等しくない"); } else { prin...
true
b1131a98d67be3ae2be13ef7ab04892a24cf9921
Rust
redox-os/bootloader
/src/os/bios/macros.rs
UTF-8
538
2.65625
3
[ "MIT" ]
permissive
/// Print to console #[macro_export] macro_rules! print { ($($arg:tt)*) => ({ use core::fmt::Write; #[cfg(feature = "serial_debug")] { let _ = write!($crate::os::serial::COM1.lock(), $($arg)*); } let _ = write!($crate::os::VGA.lock(), $($arg)*); }); } /// Pri...
true
a26f66e560fea84db01527f3394dbe166c884fc7
Rust
makononov/saltwater
/src/header.rs
UTF-8
380
3.25
3
[ "MIT" ]
permissive
use std::fmt; pub struct Header { pub key: String, pub value: String, } impl Header { pub fn new(key: String, val: String) -> Self { Header { key: key, value: val } } } impl fmt::Display for Header { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result...
true
7489d92ef863134d52513b5f17c65e29a45ac5d4
Rust
andysizer/gheap
/benches/heap_benchmarks.rs
UTF-8
16,250
2.546875
3
[ "MIT" ]
permissive
#![allow(unused_parens)] // #![feature(trace_macros)] // trace_macros!(true); use std::time::Duration; use std::cmp::Ordering; use compare::Compare; use criterion::{criterion_group, criterion_main, BatchSize, Criterion, BenchmarkId}; use rand::distributions::{Distribution, Standard}; use rand::Rng; use rand_distr::...
true
8e2fb5a998472e117625dfe475d3815b3e5da7d0
Rust
marty777/adventofcode2019
/src/day8.rs
UTF-8
1,181
2.84375
3
[ "MIT" ]
permissive
// day 8 pub fn run(file_path:&str) { let vec = super::utility::util_fread(file_path); let bytes = vec[0].as_bytes(); let width = 25; let height = 6; let total_pixels = bytes.len(); let layers = total_pixels/(width*height); let mut final_bytes:[u8;150] = [2; 150]; let mut min_zeros = width*height; let m...
true
249edd65e4cf618d50228d0c29e71f4ae01a6936
Rust
nifey/advent_of_code
/src/solutions/day12.rs
UTF-8
5,296
3.609375
4
[]
no_license
use std::fs; enum Direction { North = 0, East, South, West, } pub fn solve_part1(filename: String) { // Manhattan distance let input_data = fs::read_to_string(filename).expect("Could not open file for reading"); let instructions: Vec<(char, i64)> = input_data .lines() .map(...
true
2f7e6c5afc54cdc1ffde6eecc598a924132196d1
Rust
isgasho/panel-protocol
/src/lib.rs
UTF-8
11,761
2.875
3
[]
no_license
#![cfg_attr(not(feature = "std"), no_std)] pub use arrayvec::{ArrayString, ArrayVec}; #[derive(Debug, PartialEq)] #[cfg_attr(feature = "serde_support", derive(serde::Serialize, serde::Deserialize))] pub enum Command { PowerCycler { slot: u8, state: bool }, Brightness { target: u8, value: u16 }, Temperatur...
true
5a04f53c8a77ba21018607d3f1985d64d7756644
Rust
jsim2010/cur_macro
/tests/repeat.rs
UTF-8
7,857
2.96875
3
[ "MIT" ]
permissive
use cur::{Cast, Scent}; use cur_macro::scent; /// Try. #[test] fn try_expr() { #[scent] const TRY: Scent = 'a'?; assert_eq!(TRY, Scent::Union(&[Scent::Atom('a'), Scent::Clear])); } /// Negation of Try. #[test] fn min_try_expr() { #[scent] const MIN_TRY: Scent = -'a'?; assert_eq!(MIN_TRY, Sce...
true
50fca7da57fe5ecb38a6a8ca52febb73dce1df27
Rust
iampiyush/sri-delhi-rust-libcss
/test/libcss/parse.rs
UTF-8
2,860
2.640625
3
[]
no_license
extern mod std; extern mod extra; extern mod css; extern mod wapcaplet; use std::io::*; use css::css::*; use css::stylesheet::*; use css::utils::errors::*; pub fn resolve_url(_:@str, rel:@mut wapcaplet::lwc_string) -> (css_error,Option<@mut wapcaplet::lwc_string>) { return (CSS_OK,Some(rel.clone())); ...
true
d5933ca5932298f6a080e1d89abfada375270a66
Rust
IThawk/rust-project
/rust-master/src/test/ui/try-block/try-block-bad-lifetime.rs
UTF-8
1,170
3.265625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// compile-flags: --edition 2018 #![feature(try_blocks)] #![inline(never)] fn do_something_with<T>(_x: T) {} // This test checks that borrows made and returned inside try blocks are properly constrained pub fn main() { { // Test that borrows returned from a try block must be valid for the lifetime of the...
true
1dcc71d0262ebbb0f5b0922eb33c3aaaedb8fd1e
Rust
adhocmaster/cmps203
/HW4/while_small/src/ast/command.rs
UTF-8
3,403
3.5
4
[]
no_license
/* data C = Skip Bool | Assign Var E | Seq C C | If B C C | While B C | Inc Var */ use std::rc::Rc; use std::collections::HashMap; use super::expression::E; use super::expression::evalE; use super::b_expression::B; use super::b_expression::evalB; #[allow(dead_code)] use...
true
c1fc25844459155301c2e312220959b0b8ec1e1d
Rust
LukasKalbertodt/drencher
/drencher/src/main.rs
UTF-8
4,843
2.796875
3
[]
no_license
extern crate docopt; extern crate rand; extern crate rustc_serialize; extern crate term_painter; extern crate time; extern crate rayon; extern crate pbr; #[macro_use] extern crate log; extern crate env_logger; #[macro_use] extern crate glium; extern crate smallvec; extern crate bit_set; #[macro_use] mod util; mod colo...
true
d1ec658587c442cb91da79cdf08d94d53d874214
Rust
jswalden/unicode-info
/src/bmp.rs
UTF-8
6,572
3.0625
3
[ "MIT" ]
permissive
//! Various information salient to handling _only_ BMP code points. use crate::code_point_table; use crate::constants::{COMPATIBILITY_IDENTIFIER_PART, LINE_TERMINATOR, MAX_BMP, WHITE_SPACE}; use crate::derived_core_properties; use crate::types::{Flags, MappedCodePoint}; use proc_macro2; use quote::quote; use std::coll...
true
904aa066ba9d9771cf62dfa0379814168cfdb66a
Rust
kkang-wr/rips
/packets/examples/basic.rs
UTF-8
1,381
3.359375
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate rips_packets; use rips_packets::ethernet::{EthernetPacket, MacAddr, MutEthernetPacket, EtherType}; fn main() { // Allocate a byte buffer that hold the bytes in the Ethernet frame. let mut buffer = [0; 14]; { // Lend the buffer mutably to `MutEthernetPacket` so it can manipulate the ...
true
1a376e6c8d347502f6284bdb2b5c34c8d327871d
Rust
ruilkqun/AntKingImage
/src/sled_json.rs
UTF-8
2,431
2.828125
3
[ "Apache-2.0" ]
permissive
use serde::{ Deserialize, Serialize }; pub trait Encoder<'a> { type In; type Encoded: AsRef<[u8]>; type Out; fn encode(d: Self::In) -> Self::Encoded; fn decode(bytes: &'a [u8]) -> Option<Self::Out>; } pub struct IVecWrapper<E> where for<'a> E: Encoder<'a>, { ivec: sled::IVec, _e: s...
true
3c46cd0ac83fbb19a8b183d8002a6550c7bfef11
Rust
gnmerritt/photothing-api
/src/db/mod.rs
UTF-8
1,815
2.8125
3
[ "AGPL-3.0-only" ]
permissive
pub mod album; mod pagination; pub mod photo; pub mod user; pub mod schema; pub use self::pagination::{Page, Pagination}; use std::env; use std::ops::Deref; use diesel::PgConnection; use diesel::r2d2::{ConnectionManager, Pool, PooledConnection}; use rocket::http::Status; use rocket::request::{self, FromRequest}; use ...
true
8cb6cf28cad7bb5a10b09b95bfaa8ae1dffff412
Rust
chesedo/cos-700
/Code/Rust/macro-patterns-dec/src/helpers.rs
UTF-8
1,091
2.53125
3
[]
no_license
#[macro_export] macro_rules! expand { ($tpml:ident($($items:tt),+)) => { $($tpml!($items);)+ }; ($tpml:ident($($items:tt,)+)) => { $($tpml!($items);)+ }; } #[macro_export] macro_rules! expand_trim_dyn { ($tmpl:path, dyn $type:ty $(, $extra:path)*) => { paste::paste! { ...
true
d58fd6cb107fd290f09975367c024bdd77f66666
Rust
gbip/rust-render-engine
/bench/bench.rs
UTF-8
1,921
2.6875
3
[]
no_license
#![feature(test)] #![feature()] extern crate lib_render; extern crate test; extern crate colored; use std::time::Instant; use lib_render::*; use colored::*; use std::fs::OpenOptions; use std::io::Write; const OUTPUT_FOLDER: &'static str = "bench_output/"; fn write_bench_to_file(name: &str, time: f64) { let file_...
true
52e309ce940fc329b8dc5ff84f15f0c8be376144
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/past202004-open/src/bin/f.rs
UTF-8
473
2.515625
3
[]
no_license
use proconio::input; use proconio::marker::Usize1; fn main() { input! { n: usize, ab: [(Usize1, i64); n], }; let mut ks = vec![vec![]; n]; for &(a_i, b_i) in ab.iter() { ks[a_i].push(b_i); } let mut pq = std::collections::BinaryHeap::new(); let mut sum = 0; for k...
true
94ea6a8e8e029acc8b85cf5a08bc1964b0048a5b
Rust
asomers/mockall
/mockall/tests/mock_static_method_with_lifetime_parameters.rs
UTF-8
1,098
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
// vim: tw=80 //! A static generic method whose only generic parameter is a lifetime parameter #![deny(warnings)] use mockall::*; use std::sync::Mutex; #[derive(Debug, Eq)] struct X<'a>(&'a u32); impl<'a> PartialEq for X<'a> { fn eq(&self, other: &X<'a>) -> bool { self.0 == other.0 } } mock!{ Fo...
true
1bb34586650e71f289e3ee621b1c3684260cd4f6
Rust
benkay86/matlab-ndarray-tutorial
/rust/src/bin/parfor_permutation.rs
UTF-8
3,502
3.203125
3
[]
no_license
//! Example of using a parallel iterator to perform a permutation test. //! //! See also <parfor.rs> for simpler examples of parallel iteration. //! //! The aim of this example is to show how parfor works in Rust. //! See <least_squares.rs> for examples of how to solve least squares systems. //! To keep this example re...
true
79b1b517949c812d1adc5c772475f5caee1c37ed
Rust
drwilco/aoc
/2019/day1/src/bin/second.rs
UTF-8
655
3.28125
3
[]
no_license
use std::fs::File; use std::io; use std::io::prelude::*; use std::io::BufReader; fn calc_fuel(mass: i32) -> i32 { let fuel = (mass / 3) - 2; if fuel <= 0 { return 0; } fuel + calc_fuel(fuel) } fn main() -> io::Result<()> { let f = File::open("input.txt")?; let f = BufReader::new(f); ...
true
635534a331fd0eed73cfb4ba9c918538b3998cb1
Rust
DelSkayn/toyjs
/toyjs/src/bin/cli.rs
UTF-8
2,970
2.546875
3
[]
no_license
#![feature(allocator_api)] #![allow(unused_imports)] use std::alloc::Global; use std::{ env, io::{self, Write}, }; use ast::SymbolTable; use common::{atom::Atoms, source::Source}; use lexer::Lexer; use toyjs::ToyJs; fn main() -> io::Result<()> { let toyjs = ToyJs::new(); let realm = toyjs::Realm::ne...
true
d4bd91f5410c53a6a47f82393aedd0695818d041
Rust
stefanberndtsson/nmdb-build-rust
/src/id_handler.rs
UTF-8
3,615
3
3
[]
no_license
use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashMap; use std::io::Write; pub const MOVIES: i32 = 0x1; pub const PEOPLE: i32 = 0x2; pub const TESTMOVIES: i32 = 0x1000; pub const TESTPEOPLE: i32 = 0x2000; macro_rules! println_stderr( ($($arg:tt)*) => { { le...
true
8568473a0afb20d60c2b6e03c183204902f44421
Rust
redsnapper2006/leetcode-cn
/M/2383-minimum-hours-of-training-to-win-a-competition/main.rs
UTF-8
685
3.40625
3
[]
no_license
struct Solution {} impl Solution { pub fn min_number_of_hours( initial_energy: i32, initial_experience: i32, energy: Vec<i32>, experience: Vec<i32>, ) -> i32 { let sum_energy: i32 = energy.iter().sum(); let r_e: i32 = if sum_energy >= initial_energy { sum_energy - initial_energy + 1 ...
true
39d25d18312168af51cab4d8abcd013a3cfd7757
Rust
svmk/fund-watch-bot
/src/market/common/model/actual_price.rs
UTF-8
868
3.078125
3
[]
no_license
use crate::market::common::error::price_parse_error::PriceParseError; use crate::market::common::model::price::Price; #[derive(Debug, Clone, PartialEq, ValueObject)] #[value_object(error_type = "PriceParseError", load_fn = "ActualPrice::from_f64")] pub struct ActualPrice(f64); impl ActualPrice { pub fn into_price...
true
d9661a7212e14855a9990d2c968108f601bfd08e
Rust
gudtech/perl-xs
/src/registry.rs
UTF-8
1,538
3.03125
3
[ "BSD-2-Clause" ]
permissive
use core::ptr; use core::sync::atomic::{AtomicPtr, Ordering}; // Not public API. Used by generated code. #[doc(hidden)] pub struct Registry<T: 'static> { head: AtomicPtr<Node<T>>, } struct Node<T: 'static> { item: T, next: Option<&'static Node<T>>, } #[doc(hidden)] impl<T: 'static> Registry<T> { // N...
true
eaa09f0cf317d68be667752de6fe374559be0bf3
Rust
AndrewGaspar/rust-breakout
/breakout-core/src/shape.rs
UTF-8
670
3.296875
3
[ "MIT" ]
permissive
use math::{vec2, Vec2}; pub struct Box { pub left: f32, pub right: f32, pub bottom: f32, pub top: f32, } pub trait Shape { fn bounding_box(&self) -> Box; } pub trait Rectangle { fn dimensions(&self) -> vec2; fn origin(&self) -> vec2; fn left(&self) -> f32 { ...
true
56cbd3f9e96e347940fad9f240258cef1cee4cfa
Rust
tkln/rrt
/src/aabb.rs
UTF-8
3,387
3.359375
3
[]
no_license
use crate::Vec3; use crate::Ray; use crate::hittable::Hittable; #[derive(Copy, Clone)] pub enum Axis { X = 0, Y = 1, Z = 2, } #[derive(Copy, Clone)] #[derive(Debug)] pub struct AABB { pub min: Vec3, pub max: Vec3, } impl AABB { pub fn new(min: Vec3, max: Vec3) -> AABB { assert!(min.x ...
true
ff8ea052d4b6b6b37f4d45bb6a76c96866ca6b99
Rust
rust-osdev/acpi
/acpi/src/platform/interrupt.rs
UTF-8
4,248
2.8125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::ManagedSlice; use core::alloc::Allocator; #[derive(Debug)] pub struct IoApic { pub id: u8, /// The physical address at which to access this I/O APIC. pub address: u32, /// The global system interrupt number where this I/O APIC's inputs start. pub global_system_interrupt_base: u32, } #[d...
true
7551b1443a145b725ce01623eb294e5d3bee92a9
Rust
evanoxu/deno
/serde_v8/src/magic/value.rs
UTF-8
2,109
2.734375
3
[ "MIT" ]
permissive
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use std::fmt; use std::marker::PhantomData; pub const FIELD: &str = "$__v8_magic_value"; pub const NAME: &str = "$__v8_magic_Value"; /// serde_v8::Value allows passing through `v8::Value`s untouched /// when encoding/decoding and allows mixin...
true
2567f951b58d542dc0ebd6c5e6fdfe429d39965d
Rust
rivy/crossterm
/src/terminal/terminal.rs
UTF-8
7,154
3.609375
4
[ "MIT" ]
permissive
//! With this module you can perform actions that are terminal related. //! Like clearing and scrolling in the terminal or getting the size of the terminal. use super::super::shared::functions; use super::super::style; use super::*; use Context; use std::fmt; use std::io::Write; use std::rc::Rc; /// Struct that sto...
true
c6704b8ef2812476ebc9e2ff1a215027c268c9b3
Rust
mxseev/derpiboorust
/src/request/image_list/watched.rs
UTF-8
2,418
3.28125
3
[ "MIT" ]
permissive
use failure::Error; use reqwest::Url; use super::{Bound, Order}; use crate::request::{build_url, response::ImagesResponse, QueryPairs, Request}; /// Request for fetching user watched images (`/images/watched.json`). /// ``` /// use derpiboorust::{Watched, Bound, Order}; /// /// let request = Watched::new("user_accoun...
true
27fe5109da4de2e22042a34fd2b1700ba12adcdb
Rust
Liquid44/chat
/src/client.rs
UTF-8
11,077
2.59375
3
[ "MIT" ]
permissive
use crate::channel::ChannelMessage; use crate::{coordinator::CoordinatorRequest, telnet::Telnet}; use crate::{ coordinator::CoordinatorResponse, ui::{Tab, TabType, Ui, UiTabs}, }; use crate::{ telnet::TelnetMessage::{self, *}, ui::telnet_backend, }; use askama::Template; use chrono::{DateTime, Local}; u...
true
e029c954d290f51fa80e0619c066a8fd7dbd14f8
Rust
willcrichton/rapier
/src/geometry/sat.rs
UTF-8
10,872
2.609375
3
[ "Apache-2.0" ]
permissive
use crate::geometry::{cuboid, Cuboid, Polygon, Segment, Triangle}; use crate::math::{Isometry, Point, Vector, DIM}; use crate::utils::WSign; use na::Unit; use ncollide::shape::SupportMap; #[allow(dead_code)] pub fn support_map_support_map_compute_separation( sm1: &impl SupportMap<f32>, sm2: &impl SupportMap<f3...
true
8d0f4a96b41c9d70169099be781265fc76b6f325
Rust
canndrew/malk-rs
/src/parse/document.rs
UTF-8
4,781
2.890625
3
[]
no_license
use std::collections::HashMap; use render; use core; use parse; use construct; use render::debug_render_term; use parse::{Syntax, Expr, BlockPrecedenceExprKind}; pub struct Document { text: String, parsed: Option<Expr<BlockPrecedenceExprKind>>, stamp: usize, } #[derive(Debug, Clone)] pub struct Diff { ...
true
72336d05523a17fd1e3bc67f123469656179b55b
Rust
Aunmag/rusty-sapper
/src/ui/menu.rs
UTF-8
3,626
3.140625
3
[ "MIT" ]
permissive
use crate::ui::button::Button; use crate::ui::page::Page; use crate::ui::spacer::Spacer; use crate::ui::text::Text; use crate::ui::Event; use termwiz::input::InputEvent; use termwiz::input::KeyCode; use termwiz::input::KeyEvent; use termwiz::surface::Surface; pub struct Menu { pages: Vec<Page>, pages_history: ...
true
565a1aadd46b71b872f73475e0bb49100c7f3029
Rust
furuhama/design_patterns_in_rust
/src/patterns/factory.rs
UTF-8
599
3.3125
3
[]
no_license
// Factory pattern pub fn factory() { let f = Factory; let product_closure = || ConcreteProductX; println!("{}", f.convert(String::from("hoge -> nyan"), product_closure)); } trait Product { fn convert(&self, _: String) -> String; } struct Factory; impl Factory { fn convert<P, F>(&self, s: String...
true
b0bed789abe530ea53f62ff9db50f9020ade9edb
Rust
cryptopossum/gp-v2-services
/orderbook/src/database.rs
UTF-8
1,518
2.609375
3
[]
no_license
mod events; mod fees; mod orders; mod trades; use anyhow::Result; use sqlx::PgPool; pub use events::*; pub use orders::OrderFilter; pub use trades::TradeFilter; // TODO: There is remaining optimization potential by implementing sqlx encoding and decoding for // U256 directly instead of going through BigDecimal. This...
true
a3fdad8d7262e91ae76e685051612d5c2cccf0c1
Rust
IThawk/rust-project
/rust-master/src/test/codegen-units/item-collection/generic-functions.rs
UTF-8
1,610
2.78125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// compile-flags:-Zprint-mono-items=eager #![deny(dead_code)] #![feature(start)] fn foo1<T1>(a: T1) -> (T1, u32) { (a, 1) } fn foo2<T1, T2>(a: T1, b: T2) -> (T1, T2) { (a, b) } fn foo3<T1, T2, T3>(a: T1, b: T2, c: T3) -> (T1, T2, T3) { (a, b, c) } // This function should be instantiated even if no used...
true
40e39f9fc6cab2edd0d64834652f91d4d89d2d44
Rust
wangzk1900/rust-by-example
/rbe10_1/src/main.rs
UTF-8
2,347
3.796875
4
[]
no_license
mod my_mod { // 默认私有,可见范围是当前模块 fn private_function() { println!("called `my_mod::private_function()`"); } // pub 表示公有,可见范围是全局 pub fn function() { println!("called `my_mod::function()`"); } pub fn indirect_access() { print!("called `my_mod::indirect_access()`, that\n...
true
d301e06646d0c4da74e81b2914454a9c7bbf8689
Rust
rust-lang/rust
/tests/ui/borrowck/anonymous-region-in-apit.rs
UTF-8
223
2.890625
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
#![feature(anonymous_lifetime_in_impl_trait)] trait Foo<T> { fn bar(self, baz: T); } fn qux(foo: impl Foo<&str>) { |baz: &str| foo.bar(baz); //~^ ERROR borrowed data escapes outside of closure } fn main() {}
true
a72e3b7aba785246093e4bef3cedc7805d813d02
Rust
boojies/blindsign
/tests/integration.rs
UTF-8
3,635
2.6875
3
[ "MIT" ]
permissive
// Regular imported crates extern crate blindsign; extern crate curve25519_dalek; extern crate rand; extern crate sha3; #[cfg(test)] mod integration_test { use sha3::Sha3_512; use blindsign::{ keypair::BlindKeypair, request::BlindRequest, session::BlindSession, signature::{Unbl...
true
8609c76a4b9b0792dad7604f9cd656a5ca7e54ad
Rust
SnoozeTime/r3dtest
/src/assets/prefab.rs
UTF-8
305
2.609375
3
[]
no_license
//! Prefabs are entities (or list of entities) that can be imported from a file and instantiated. use crate::ecs::serialization::SerializedEntity; use std::path::PathBuf; #[derive(Default, Clone)] pub struct Prefab { entities: SerializedEntity, } pub struct PrefabLoader { base_path: PathBuf, }
true
f2a495fc6b0e1f4d52739921d751ad8c8ad71ddc
Rust
myuon/madder
/core/src/feat/entity/component_ext.rs
UTF-8
2,497
2.609375
3
[]
no_license
extern crate serde_json; extern crate gdk_pixbuf; extern crate gstreamer as gst; use spec::{Component, HaveComponent}; use feat::*; #[derive(Clone, Serialize, Deserialize)] #[serde(tag = "component_type")] pub enum ComponentExt { Video(VideoComponent), Image(ImageComponent), Sound(SoundComponent), Text...
true
353d3eb63d753cc672158d6c7a23a775075663e6
Rust
awegsche/druid-tutorial
/src/data.rs
UTF-8
1,872
2.859375
3
[]
no_license
use std::fs::File; use std::io::BufReader; use anyhow::Error; use druid::{Data, im::Vector}; use druid::{Env, EventCtx, Lens}; use serde::{Deserialize, serde_if_integer128}; use serde::Serialize; #[derive(Debug, Clone, Data, Lens)] pub struct AppState{ new_todo: String, todos: Vector<TodoItem> } impl AppSt...
true
27e0cded8ef6c07f25766f576ee2c370203e87c5
Rust
justinas/fortythree
/tui.rs
UTF-8
2,566
3.0625
3
[]
no_license
use core::fmt; use core::result::Result; use core::result::Result::*; use core::mem; use core::slice::SliceExt; use core::str::StrExt; const MEM_START: *mut u8 = 0xb8000 as *mut u8; const DEFAULT_COLOR: u8 = 0x07; pub static mut CONSOLE: Console = Console::new(); /// A low-level implementation of vga text mode struc...
true
0d029c9cf609f7c6f53a698298812459b6c3d30c
Rust
jester1412/Rust
/grep_cli/src/main.rs
UTF-8
3,107
3.671875
4
[]
no_license
use std::env; //use std::fs; // --> mv to lib.rs use std::process; //use std::error::Error; // --> mv to lib.rs use grep_cli::Config; //use cli::run; /* fn main() { Collect Args to Vector of String args let args: Vec<String> = env::args().collect(); //println!("{:?}", args); let query = &args[1]; let file...
true
1c66f042d5d6b01f453eb9b4e67663f6b5b02de0
Rust
bartsmykla/codewars
/src/katas/k7_form_the_minimum.rs
UTF-8
1,243
3.859375
4
[ "MIT" ]
permissive
#![allow(unused)] /* Kata (7kyu): Form The Minimum Url: https://www.codewars.com/kata/form-the-minimum/train/rust Task Given a list of digits, return the smallest number that could be formed from these digits, using the digits only once ( ignore duplicates). Notes: Only positive integers ...
true
b0844447beb8b701f8d443fb9ad1d097f9be0ee1
Rust
TooManyBees/a_place_on_earth
/src/twitter.rs
UTF-8
3,533
3.046875
3
[]
no_license
use serde::Deserialize; use std::collections::HashMap; use std::error::Error; use std::fmt::{Display, Formatter}; use surf::http::status::StatusCode; struct Keys { consumer_key: String, secret_key: String, access_token: String, secret_token: String, } #[derive(Debug)] pub enum TwitterError { Missi...
true
90a901be312f30d037ba99e681f3be0770598361
Rust
18616378431/myCode
/rust/test8-15/src/main.rs
UTF-8
472
3.296875
3
[]
no_license
//字符串更新 //字符串由于可能是多字节的,所以无法进行索引操作 use std::ascii::{AsciiExt}; fn main() { let s = String::from("foobar"); let mut result = s.into_bytes(); (0..result.len()).for_each(|i| if i % 2 == 0 { result[i] = result[i].to_ascii_lowercase(); } else { result[i] = result[i].to_asc...
true
2eac05d04db9c8d9b7dfc93c89459946c508370b
Rust
boxdot/advent-of-code-2019
/christian/11/src/main.rs
UTF-8
1,710
2.953125
3
[]
no_license
use core::cell::RefCell; use itertools::*; use std::collections::HashMap; use std::io::{self, prelude::*}; use vm::Vm; fn parse(input: &Vec<String>) -> Vec<i64> { let ints = input.iter().map(|x| x.split(',')).flatten(); ints.filter_map(|x| x.parse().ok()).collect() } fn solve(mem: &Vec<i64>, start: i64) -> (u...
true
6577908f1b7ef11b4b480c475800f3b452859cd9
Rust
whitebatman2/rusty_chess
/src/main.rs
UTF-8
39,821
2.59375
3
[ "CC-BY-4.0", "MIT", "CC0-1.0", "CC-BY-3.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use bevy::prelude::*; use std::f32::consts::{PI, FRAC_PI_2}; use bevy_mod_picking::*; use rand::random; use crate::GameState::{WaitingForSelect, PawnPromoting}; use bevy::input::gamepad::GamepadButtonType::Select; use bevy::window::WindowId; use std::cmp; use crate::PieceType::Knight; use bevy::input::mouse::{MouseMoti...
true
6589b7633835b2983f0283349d188138701055fd
Rust
mrDIMAS/rg3d-physics
/src/gjk_epa.rs
UTF-8
19,086
2.640625
3
[ "MIT" ]
permissive
/// Gilbert-Johnson-Keerthi (GJK) intersection test + Expanding Polytope /// Algorithm (EPA) implementations. /// /// "Implementing GJK", Casey Muratori: /// https://www.youtube.com/watch?v=Qupqu1xe7Io /// /// "GJK + Expanding Polytope Algorithm - Implementation and Visualization" /// https://www.youtube.com/watch?v=6...
true
27a83dbbe6244ae9a6b73c2c53e74ace6dda17f1
Rust
intendednull/yew
/packages/yew-router/src/router.rs
UTF-8
3,183
3.53125
4
[ "Apache-2.0", "MIT" ]
permissive
//! Router Component. use crate::Routable; use gloo::events::EventListener; use std::rc::Rc; use yew::prelude::*; /// Wraps `Rc` around `Fn` so it can be passed as a prop. pub struct RenderFn<R>(Rc<dyn Fn(&R) -> Html>); impl<R> RenderFn<R> { /// Creates a new [`RenderFn`] /// /// It is recommended that y...
true
d8c922082ec26022b793843986d33cd5ad9836d3
Rust
MierBen/http_broker
/src/handlers/queue_get.rs
UTF-8
1,607
2.921875
3
[]
no_license
use actix_web::{get, rt::time::interval, web, HttpResponse}; use async_std::sync::Mutex; use std::time::Duration; use crate::models::{GetQueue, Queue}; /// Getting value from queue with timeout /// /// # Arguments /// /// * `data` - A queue shared object /// * `name` - Name of queue /// * `time` - Timeout /// async ...
true
3e98366de4169cd4403d5f8ea7a1f549986adb06
Rust
marco-c/gecko-dev-wordified
/third_party/rust/range-alloc/src/lib.rs
UTF-8
11,442
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use std : : { fmt : : Debug iter : : Sum ops : : { Add AddAssign Range Sub } } ; # [ derive ( Debug ) ] pub struct RangeAllocator < T > { / / / The range this allocator covers . initial_range : Range < T > / / / A Vec of ranges in this heap which are unused . / / / Must be ordered with ascending range start to permit s...
true
f0ce635a5f9027872a2445ad842aad1d8d623382
Rust
zhiburt/tabled
/json_to_table/src/table/mod.rs
UTF-8
23,272
3.375
3
[ "MIT" ]
permissive
use core::fmt::{self, Display}; use std::borrow::Borrow; use serde_json::Value; use tabled::{ builder::Builder, grid::{ config::{AlignmentHorizontal, ColoredConfig, Entity, Indent, Sides, SpannedConfig}, dimension::CompleteDimension, records::EmptyRecords, }, settings::{style::S...
true
958689b090691de894704e17a2c8d6855f256988
Rust
marco-c/gecko-dev-wordified-and-comments-removed
/third_party/rust/tokio/src/time/driver/wheel/stack.rs
UTF-8
2,081
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super : : { Item OwnedItem } ; use crate : : time : : driver : : Entry ; use std : : ptr ; # [ derive ( Debug ) ] pub ( crate ) struct Stack { head : Option < OwnedItem > } impl Default for Stack { fn default ( ) - > Stack { Stack { head : None } } } impl Stack { pub ( crate ) fn is_empty ( & self ) - > bool { self...
true
f77dfb7bdf8f3d83a064648a0476ea249f3c4566
Rust
hwchen/news
/src/main.rs
UTF-8
1,381
2.515625
3
[]
no_license
mod hn; mod reddit; use colored::*; use crate::hn::{ fetch_hn_top, fetch_hn_item, HN_DISCUSSION, }; use crate::reddit::fetch_reddit_new; type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; fn main() -> Result<()> { // set up logging env_logger::init(); // red...
true
3487ac1c0a6c0595b3f55ac29c14a08742000322
Rust
jjmark15/rocket-server
/service/src/web/routes/hello.rs
UTF-8
170
2.84375
3
[ "MIT" ]
permissive
#[get("/")] pub fn hello_world() -> &'static str { "Hello, world!" } #[get("/<name>")] pub fn hello_name(name: String) -> String { format!("Hello, {}!", name) }
true
6458b7e815888cc9b194a8adaf284cbd0ffd5be2
Rust
udoprog/genco
/src/tokens/static_literal.rs
UTF-8
980
3.84375
4
[ "MIT", "Apache-2.0" ]
permissive
use crate::lang::Lang; use crate::tokens::{FormatInto, Item, ItemStr}; /// A formatter from a static literal. /// /// Created from the [static_literal()] function. #[derive(Debug, Clone, Copy)] pub struct StaticLiteral { literal: &'static str, } impl<L> FormatInto<L> for StaticLiteral where L: Lang, { fn ...
true
5184ddad522d665e33aab886e009f90cb6523141
Rust
tg-rs/tgbot
/src/types/document.rs
UTF-8
2,626
3.234375
3
[ "MIT" ]
permissive
use crate::types::{photo_size::PhotoSize, primitive::Integer}; use serde::Deserialize; /// General file (as opposed to photos, voice messages and audio files) #[derive(Clone, Debug, Deserialize)] pub struct Document { /// Identifier for this file, which can be used to download or reuse the file pub file_id: St...
true
a888b60a44be7336894447be0566b3774ee1a4b4
Rust
fredrikaverpil/rust-syntax
/src/mod20_strings.rs
UTF-8
1,263
3.640625
4
[]
no_license
#![allow(unused_variables)] fn strings() { // there are two string types; // 1. &str = string slice // 2. String = heap allocated string // statically allocated, included in our compiled program, not created during runtime // cannot be re-assigned, cannot be manipulated let s: &'static str = "...
true
2715bac7af46e977e0ddbe3ac9437f59bfd10e24
Rust
lcdr/raknet_shim
/src/bridge.rs
UTF-8
5,717
3.09375
3
[]
no_license
//! Contains the link between RakNet and TcpUdp, as well as abstract packet definitions. use std::collections::HashMap; use std::io::Result as Res; use std::net::{SocketAddr, ToSocketAddrs}; use endio::LERead; use endio::LEWrite; use crate::raknet::Connection as RakConn; use crate::tcpudp::Connection as TcpUdpConn; u...
true
03ca963f036db4854e9786f2b6477149ccff6187
Rust
Raz-Hemo/advent2020
/src/stages/stage9.rs
UTF-8
1,630
3.21875
3
[]
no_license
use std::io::prelude::*; use anyhow::Context; fn get_numbers() -> anyhow::Result<Vec<usize>> { let mut f = std::fs::File::open("stage9.txt").unwrap(); let mut numbers = String::new(); f.read_to_string(&mut numbers).unwrap(); Ok( numbers.split("\n") .filter(|n| *n != "") .map(|n...
true
bb42449443188815193c0fcbc7749251656bcb4d
Rust
gvissers/babs
/src/ubig/support.rs
UTF-8
1,894
3.0625
3
[ "Apache-2.0" ]
permissive
// Copyright, 2021, Gé Vissers // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
163db3fe2061f8871908a15f4173f01e68b35fd9
Rust
jaywalia/rust_by_example
/src/rbe_9_lets.rs
UTF-8
1,236
3.625
4
[]
no_license
// if lets pub fn _test_if_let(){ _awkward_match(); _better_if_let(); _awkward_loop_match(); _awesome_while_let(); } fn _awkward_match() { let opt = Some(42); match opt { Some(i) => println!("Eternal answer {}", i), _ => println!("Don't worry, be happy"), } } fn _better_i...
true
c9074e8add94bf99dd7dee2c04b34bf129a92031
Rust
valarauca/trollrun
/src/exec/config.rs
UTF-8
4,114
2.921875
3
[]
no_license
use std::collections::BTreeMap; use std::process::{Command, Stdio}; use super::super::serde::Deserialize; use super::runs::TrollRun; /// RunKind states what file we will execute #[derive(Clone, Deserialize, Debug, PartialEq, Eq, Hash)] #[serde(untagged)] pub enum RunKind { Trivial(String), ComplexRun(Complex...
true
33be739a6beaacbb7b2fa4dfce9757a6d4566bf7
Rust
paulkirkwood/rs.parcoursdb
/src/mountains/massif_central/mod.rs
UTF-8
367
2.640625
3
[]
no_license
use crate::location::Location; use crate::mountains::util::french_col; pub fn la_bourboule() -> Location { french_col("La Bourboule", 1180) } pub fn le_lioran() -> Location { french_col("Le Lioran", 1326) } pub fn puy_de_dome() -> Location { french_col("Puy de Dôme", 1415) } pub fn super_besse() -> Loca...
true
90367b2b677ec0a9f338768a78b8cb2e016237c1
Rust
PiDelport/twilio-oai-rust
/twilio-oai-serverless-v1/src/models/serverless_v1_service_asset_asset_version.rs
UTF-8
2,510
2.5625
3
[]
no_license
/* * Twilio - Serverless * * This is the public Twilio REST API. * * The version of the OpenAPI document: 1.20.3 * Contact: support@twilio.com * Generated by: https://openapi-generator.tech */ #[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] pub struct ServerlessV1ServiceAssetAssetVersion { ...
true
f00c9a009bcada4d68ffdc4f8e5bb9d3797b3a77
Rust
Samulus/rust-pong
/src/paddle.rs
UTF-8
946
2.6875
3
[]
no_license
/* * paddle.rs * Author: Samuel Vargas * Date: 03/27/2017 */ extern crate sdl2; extern crate rand; use sdl2::rect::Rect; use sdl2::pixels::*; use world::*; pub struct Paddle { pub dimen: Rect, pub speed: u32, } impl Paddle { pub fn new(x: i32, y: i32, w: i32, h: i32, speed: u32) -> Paddle { ...
true
3285687785ba70cd0aa3ee05a8ad81f0201904b0
Rust
rfdonnelly/svfmt
/svfmt/tests/assignment.rs
UTF-8
558
2.671875
3
[]
no_license
#[macro_use] mod common; mod assignment { use crate::common::*; use indoc::indoc; #[test] fn operator_assignment() { init(); let input = indoc!( " function int f(a); a *= 2 ; a <<= 3; endfunction " ...
true
f014077b89d5cd59c9a8005c170066db7d8d5c9b
Rust
ziita1111/uefi-app
/src/console.rs
UTF-8
2,077
2.59375
3
[]
no_license
use crate::prelude::*; use core::fmt; pub struct Console; impl Console { pub fn new() -> Console { Console{} } pub extern "C" fn efi_print(&self, s: &str) -> EFI_STATUS{ let stdout: &mut EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL = unsafe { &mut *((*SYSTEM_TABLE).ConOut) }; let string = s.as...
true
00b9867f99777acab7a4bc6b7d6133d6d710ff54
Rust
vamshi-krishna-prime/algorithm-playground
/simple-exercises/rust-exercises/sample-code-2/code003.rs
UTF-8
2,243
3.640625
4
[ "MIT" ]
permissive
// A very convoluted way to convert a hex string to sa vector of bytes and back use std::collections::HashMap; fn build_hexmap() -> (HashMap<u8, String>, HashMap<String, u8>) { let mut i2c = HashMap::new(); let mut c2i = HashMap::new(); let chars = ["a", "b", "c", "d", "e", "f"]; for i in 0..=10 { ...
true
a98cc8f7d5ddc8cd9fda450d88fa77ebde1ebe30
Rust
alcroito/advent_of_code_2020
/src/helpers/mod.rs
UTF-8
992
2.890625
3
[ "MIT" ]
permissive
pub mod grid; pub mod nom; use std::fs; pub fn get_data_from_file(name: &str) -> Option<String> { let path = format!("data/{}.txt", name); match fs::read_to_string(path) { Ok(s) => Some(s), Err(e) => { println!("Error reading data: {}", e); None } } } pub f...
true
54b3873fc12ea97078588cdfd674cb86cfed69c5
Rust
devil-k/gluesql
/src/data/value/json.rs
UTF-8
1,771
3.15625
3
[ "Apache-2.0" ]
permissive
use { super::{Value, ValueError}, crate::result::Result, serde_json::Value as JsonValue, std::collections::HashMap, }; impl Value { pub fn parse_json_map(value: &str) -> Result<Value> { let value = serde_json::from_str(value).map_err(|_| ValueError::InvalidJsonString)?; if !matches...
true
7ef3483b78adc42df2c5c3bb76eb97b7fd94be12
Rust
justinas/mylang
/src/parser/test.rs
UTF-8
16,219
3.078125
3
[ "MIT" ]
permissive
use super::*; use super::expr::{parse_atom, parse_comparison, parse_logexpr, parse_product, parse_sum}; #[cfg(test)] fn str_to_tokens(s: &str) -> Vec<Token> { let lexer = super::super::lexer::Lexer::new(s.as_bytes()).unwrap(); let tokens_at = lexer.lex().unwrap(); tokens_at.into_iter().map(|t| t.0).collect...
true
dcf33b3bc5601b96e012cbd99e3e7281da326e29
Rust
ttlajus/lava_torrent
/tests/write_bencode_elem.rs
UTF-8
2,252
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
extern crate lava_torrent; extern crate rand; use lava_torrent::bencode::BencodeElem; use rand::Rng; use std::collections::HashMap; use std::iter::FromIterator; const OUTPUT_ROOT: &str = "tests/tmp/"; fn rand_file_name() -> String { OUTPUT_ROOT.to_owned() + &rand::thread_rng().gen::<u16>().to_string() } #[test]...
true
21d80dc7fdd04847121fda1efab8967d3b0d1d46
Rust
jdmejiav/Rust
/fibonacci/src/main.rs
UTF-8
423
3.65625
4
[]
no_license
use std::io; fn main () { let mut fib :String = String::new(); println!("Ingrese un de fibonacci a calcular: "); io::stdin().read_line(&mut fib).unwrap(); let _fib: u64 = fib.trim().parse().ok().expect("Hubo un error"); let calc = fibonacci(_fib); println!("El fibonacci de {}, es : {}",_fib,calc); } fn fi...
true
7b66a4c074379f017c9331049b7a7b32262d8571
Rust
chris-laplante/muncher
/src/muncher.rs
UTF-8
22,991
3.65625
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cell::Cell; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum StackResult { NonBrace, Okay, BraceUnmatched, } impl StackResult { pub fn is_ok(self) -> bool { self == StackResult::Okay } } #[derive(Debug, Clone)] pub struct Stack<'a> { input: &'a str, stack: Vec<char>, pos: (u...
true
5f819adb4a67656b6b8ef7dd776fe92c2a564cd2
Rust
marcocastignoli/redpill-server
/src/reaction/mod.rs
UTF-8
2,757
2.6875
3
[]
no_license
pub mod model; pub mod schema; use rocket::request::{Form, FromForm, FormItems, FromParam}; use rocket::{self, http::Status}; use rocket_contrib::json::{Json, JsonValue}; use rocket::response::Response; use self::model::Reaction; use user::auth::ApiKey; use db; #[options( "/")] fn options_handler<'a>() ...
true
9cf7347f804e7afbeace82c499cea7093ac3b29e
Rust
dguenther/rustchip
/src/cpu.rs
UTF-8
21,494
2.8125
3
[ "MIT" ]
permissive
extern crate rand; extern crate sfml; use sfml::graphics::{Color, Image, RenderWindow, RenderTarget, Sprite, Texture}; use sfml::window::keyboard; use std::fs::File; use std::io::Read; use std::path::Path; pub struct Cpu { // These fields are public so they can be set directly in tests, not sure // if there's a b...
true
87a2154ab64bbf0b31c68babc5486826b21a9331
Rust
g-bartoszek/snake
/snake-core/src/tests/test_utils.rs
UTF-8
3,434
3.25
3
[ "MIT" ]
permissive
use crate::*; use std::fmt::Write; pub struct HardcodedNumbersGenerator { numbers: [u32; 6], current: usize, } impl RandomNumberGenerator for HardcodedNumbersGenerator { fn next(&mut self) -> u32 { let result = self.numbers[self.current]; self.current = (self.current + 1) % self.numbers.le...
true
32919543760a94074788ae2e5a61218ff52c1e3e
Rust
gurkodil/aoc-2019
/day9/src/lib.rs
UTF-8
8,957
3.359375
3
[]
no_license
// Link to puzzle: https://adventofcode.com/2019/day/5 // // Summary: // // OPCODES: // 1: Add instruction, followed by two parameters and lastly the address to // where the results should be stored. // 2: Multiply instruction, followed by two parameters and lastly the // address where the results should ...
true
0c705e59e0c80865f6fb1a2bd40ff01063ed1298
Rust
Kixiron/RSLint
/crates/rslint_lsp/src/core/session.rs
UTF-8
1,998
2.78125
3
[ "MIT" ]
permissive
//! Core definitions related to the LSP server session. use crate::core::{document::Document, error::Error}; use dashmap::{ mapref::one::{Ref, RefMut}, DashMap, }; use rslint_core::CstRuleStore; use tower_lsp::{lsp_types::*, Client}; /// Represents the current state of the LSP session. pub struct Session { ...
true
4b7ae33240f88d712c3359023a5506b0c08f21a0
Rust
selaux/qrende
/src/math.rs
UTF-8
809
3.25
3
[]
no_license
pub fn vec_length(vec: (f64, f64)) -> f64 { f64::sqrt(f64::powi(vec.0, 2) + f64::powi(vec.1, 2)) } pub fn vec_between_points(first: (f64, f64), second: (f64, f64)) -> (f64, f64) { (second.0 - first.0, second.1 - first.1) } pub fn vec_norm(vec: (f64, f64)) -> (f64, f64) { let length = vec_length(vec); (vec.0 /...
true
3789ac808432b02a8e1d84ba87031d4f5a2bb3d0
Rust
lochbrunner/flow-inspector
/server/src/main.rs
UTF-8
3,069
3
3
[]
no_license
extern crate ws; use std::collections::HashMap; use std::fs::{read_to_string, File}; use std::io::Read; use std::sync::mpsc; use std::sync::mpsc::Receiver; use std::sync::Arc; use std::sync::Mutex; use std::thread; use ws::{listen, Handler, Message, Request, Response, Result, Sender}; extern crate libc; use std::ffi::...
true