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
9992d261b59660d65defe86d46630b02ee43b98b
Rust
yaanhyy/hyper_demo
/src/async_tcp.rs
UTF-8
1,955
3.15625
3
[]
no_license
use async_std::net::TcpListener; use std::time::Duration; use futures::stream::StreamExt; use futures_util::io::AsyncReadExt; use futures::{future, select}; fn tcp_server() { let server = { async move { let addr = "127.0.0.1:6142"; let listener = TcpListener::bind(addr).await.unw...
true
be1b46c372e28194330b1757a8b06359a1ed2b7c
Rust
slowtec/msr
/crates/msr-legacy/src/pid.rs
UTF-8
10,904
3.421875
3
[ "MIT", "Apache-2.0" ]
permissive
//! # Example //! //! ```rust,no_run //! use std::{thread, time::Duration}; //! use msr_legacy::{TimeStepController, pid::*}; //! //! // 1. Create the PID configuration //! let cfg = PidConfig { //! k_p: 2.5, // define the proportional coefficient //! k_i: 0.7, // define the integral coefficient //! k_d: 5....
true
60de80fbb569032f98745fdb0d7e174fdb5de361
Rust
rust-may/hyper
/src/lib.rs
UTF-8
7,276
3.125
3
[ "MIT" ]
permissive
#![doc(html_root_url = "https://docs.rs/hyper/v0.10.13")] #![cfg_attr(test, deny(missing_docs))] #![cfg_attr(test, deny(warnings))] #![cfg_attr(all(test, feature = "nightly"), feature(test))] //! # Hyper //! //! Hyper is a fast, modern HTTP implementation written in and for Rust. It //! is a low-level typesafe abstrac...
true
dfcbf1cca87b8a6c7292e9ecf2a25954c31461b1
Rust
zmilan/catapulte
/src/controller/template_send_json.rs
UTF-8
4,146
2.59375
3
[]
no_license
use crate::error::ServerError; use crate::service::smtp::SmtpPool; use crate::service::template::provider::TemplateProvider; use crate::service::template::template::TemplateOptions; use actix_http::RequestHead; use actix_web::{web, HttpResponse}; use lettre::Transport; pub fn filter(req: &RequestHead) -> bool { re...
true
70a052357cda4f82df8c2bbdf19d39fdc07e111e
Rust
beachcitiessoftware/rtcp
/src/util/util_test.rs
UTF-8
1,818
3.0625
3
[ "MIT" ]
permissive
#[cfg(test)] mod test { use crate::errors::Error; use crate::util::{get_padding, set_nbits_of_uint16}; #[test] fn test_get_padding() -> Result<(), Error> { let tests = vec![(0, 0), (1, 3), (2, 2), (3, 1), (4, 0), (100, 0), (500, 0)]; for (n, p) in tests { assert_eq!( ...
true
2a39721eb4bf03696cc80970e1249c78aa8ee597
Rust
iCodeIN/rusty-chip-8-emu
/src/main.rs
UTF-8
3,743
2.609375
3
[ "MIT" ]
permissive
#![feature(const_int_pow)] #![cfg_attr(test, feature(proc_macro_hygiene))] mod errors; mod emulator; mod runner; mod vm; use flexi_logger::{LogSpecBuilder, Logger}; use log::{error, info, LevelFilter}; use ggez::{ conf::{WindowMode, WindowSetup}, event::{self, EventHandler}, graphics::{self, Text, Align}...
true
40df896769c8f83db8e8ceb989a7a0194908e991
Rust
9elements/enter32
/src/led_matrix_frontend.rs
UTF-8
2,209
2.5625
3
[]
no_license
use controller_state::ControllerState; use def::DIMENSION; use gilrs::Gilrs; use rpi_led_matrix::{LedColor, LedMatrix, LedMatrixOptions}; use std::sync::mpsc::{Receiver, Sender, TryRecvError}; pub fn start( input_sender: Sender<ControllerState>, frame_reveicer: Receiver<Vec<u8>>, color_map: &Vec<(u8, u8, u...
true
ced1d102c05aed2f12c717641990094e3ae6070f
Rust
thisismypotpie/maze-runner
/src/menu.rs
UTF-8
7,091
3.265625
3
[ "MIT" ]
permissive
extern crate termion; use crate::running_alg::begin_game; use crate::running_alg::generate_maze; use crate::running_alg::load_maze; use std::io::{stdin, stdout, Read, Write}; use std::process::exit; use termion::clear; use termion::color; /* PURPOSE: The function retrieves the player intput of the length, width, and n...
true
c583a65815220e0ea49e13a5b04c08bf6bfb59d1
Rust
dgollub/rust-sorting-algos
/src/quick.rs
UTF-8
1,968
3.53125
4
[ "MIT" ]
permissive
#[allow(dead_code)] pub fn quick_sort<T>(list: &mut [T]) where T: PartialOrd, { if list.len() < 2 { return; } quicksort(list, 0, list.len() as i32 - 1) } fn quicksort<T>(list: &mut [T], start: i32, end: i32) where T: PartialOrd, { match list.len() { 1 => return, 2 => { ...
true
d152cfec51b5ecfd6e02c337c41e96f1bc6883fe
Rust
rome/tools
/crates/rome_js_analyze/src/semantic_analyzers/suspicious/no_class_assign.rs
UTF-8
2,697
2.984375
3
[ "MIT" ]
permissive
use rome_analyze::context::RuleContext; use rome_analyze::{declare_rule, Rule, RuleDiagnostic}; use rome_console::markup; use rome_js_semantic::{Reference, ReferencesExtensions}; use rome_js_syntax::AnyJsClass; use crate::semantic_services::Semantic; declare_rule! { /// Disallow reassigning class members. ///...
true
fee8f8e22054765df39e955b473a2e81140089de
Rust
danslocombe/todo
/src/main.rs
UTF-8
10,427
3.09375
3
[]
no_license
extern crate argparse; extern crate chrono; extern crate colored; extern crate rand; extern crate serde; extern crate serde_json; extern crate time; #[macro_use] extern crate serde_derive; use argparse::{ArgumentParser, Store, StoreOption}; use rand::Rng; use std::fs::File; use std::fs::OpenOptions; use std::io::BufR...
true
bdf5b4ae64ea57705b6a42f23f0fd9a94ce6f84f
Rust
casey/practicum
/command/src/main.rs
UTF-8
722
2.921875
3
[]
no_license
extern crate glob as glob_lib; macro_rules! die { ($fmt:expr) => {print!(concat!($fmt, "\n")); std::process::exit(1)}; ($fmt:expr, $($arg:tt)*) => {print!(concat!($fmt, "\n"), $($arg)*); std::process::exit(1)}; } fn glob(pattern: &str) -> Vec<String> { match glob_lib::glob(pattern) { Ok(globs) => globs.filt...
true
3305e0d7936540c3c489d8b485a00b628a7abffe
Rust
rydz/rocket_seek_stream
/src/lib.rs
UTF-8
590
2.515625
3
[ "MIT" ]
permissive
//! This crate provides a seekable stream responder for rocket that will satisfy range requests. //! //! # Examples //! see the examples directory for more. //! //! ```no_run //! use rocket::{get, launch, routes}; //! use rocket_seek_stream::SeekStream; //! //! #[get("/")] //! fn home<'a>() -> std::io::Result<SeekStrea...
true
1979c377dd00fbefc86850b8d6c03b4fab3f8c8f
Rust
sunmeng90/rust-lang
/examples/list13-13/src/main.rs
UTF-8
3,594
4.1875
4
[ "MIT", "Apache-2.0" ]
permissive
#![allow(dead_code)] #![allow(unused_variables)] fn main() { create_an_iterator(); using_an_iterator_in_for_loop(); iterator_demonstration(); method_that_cosumes_iterators(); method_that_produces_iterator(); } // create but not consume it fn create_an_iterator() { let v1 = vec![1, 2, 3]; le...
true
4c416a71dc4ecb50632510cd5cdde72eeb2ea5a1
Rust
Vlad-Shcherbina/codejam
/2021/qual/moons_and_umbrellas.rs
UTF-8
989
3.203125
3
[]
no_license
use std::io::BufRead; fn main() { let stdin = std::io::stdin(); let mut it = stdin.lock().lines(); let mut read_line = move || it.next().unwrap().unwrap(); let n: i32 = read_line().parse().unwrap(); for case_no in 0..n { let line = read_line(); let mut it = line.split_whitespace();...
true
9725ac8202377f15de36b043f00f709e4b555bdf
Rust
mandeep2206/wasmtime-java
/tests/slices/src/lib.rs
UTF-8
2,574
2.859375
3
[ "Apache-2.0" ]
permissive
use wasmtime_jni_exports::{Borrowed, Owned, WasmAllocated, WasmSlice}; // needed for exports to wasmtime-jni pub use wasmtime_jni_exports; // These functions are declared in Java and use the Linker to associate them to the Module Instance. #[link(wasm_import_module = "test")] extern "C" { fn hello_to_java(data_pt...
true
10ace4764326733ec8ed2a1798ffcdbc259e1b9e
Rust
geo-engine/geoengine
/datatypes/src/dataset.rs
UTF-8
18,195
3.359375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::identifier; use serde::{de::Visitor, Deserialize, Serialize}; identifier!(DataProviderId); // Identifier for datasets managed by Geo Engine identifier!(DatasetId); #[derive(Debug, Clone, Hash, Eq, PartialEq, Deserialize, Serialize)] #[serde(rename_all = "camelCase", tag = "type")] /// The identifier for l...
true
bf2db65434f85098a66eeb29bff0fb12967d3d44
Rust
Gogomoe/LeetCodeSolutions
/src/0073.rs
UTF-8
1,126
3.34375
3
[]
no_license
use std::iter; impl Solution { pub fn set_zeroes(matrix: &mut Vec<Vec<i32>>) { let m = matrix.len(); let n = matrix[0].len(); let mut cols: Vec<bool> = iter::repeat(false).take(n).collect(); for i in 0..m { let mut row = false; for j in 0..n { ...
true
cb92abbb1970aaece677670fad042d8e057f6d8b
Rust
dimforge/ncollide
/src/query/visitors/composite_point_containment_test.rs
UTF-8
1,492
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::bounding_volume::BoundingVolume; use crate::math::{Isometry, Point}; use crate::partitioning::{VisitStatus, Visitor}; use crate::query::PointQuery; use crate::shape::CompositeShape; use na::RealField; /// Visitor for checking if a composite shape contains a specific point. pub struct CompositePointContainme...
true
d9da7c3a32c0423243d3ad7840eb11a27622dced
Rust
gwadej/quikdecision_rust
/src/error.rs
UTF-8
1,002
3.046875
3
[ "MIT" ]
permissive
use thiserror::Error; #[derive(Error, Debug, PartialEq, Clone)] pub enum QuikError { #[error("Unrecognized deck type {0}")] UnrecognizedDeck(String), #[error("Non-number somehow passed parsing {0}")] NotANumber(String), #[error("Missing dice expression")] DiceMissingExpr, #[error("Failed pa...
true
ef81a6133c6317c0b5b44fb0a76235738648f1e6
Rust
ejmahler/RustFFT
/src/fft_cache.rs
UTF-8
1,301
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{collections::HashMap, sync::Arc}; use crate::{Fft, FftDirection}; pub(crate) struct FftCache<T> { forward_cache: HashMap<usize, Arc<dyn Fft<T>>>, inverse_cache: HashMap<usize, Arc<dyn Fft<T>>>, } impl<T> FftCache<T> { pub fn new() -> Self { Self { forward_cache: HashMap::new(...
true
92a2f0e2c0a839d412b98c9994e61ffea2eb1dfd
Rust
tobixdev/AdventOfCode
/2020/src/problems/day13/stage_1.rs
UTF-8
690
2.703125
3
[ "Unlicense" ]
permissive
use crate::util::read_lines; pub fn run() { let min_time: u32 = read_lines("./src/problems/day13/input.txt").unwrap().nth(0).unwrap().unwrap().parse().unwrap(); let busses: Vec<u32> = read_lines("./src/problems/day13/input.txt").unwrap().nth(1).unwrap().unwrap() .split(",") .filter(|bus| *bus !...
true
1a6f9e8018b89ac0aed503b1ff20f874a01e4806
Rust
iyzana/advent-of-code-2019
/src/day2.rs
UTF-8
1,644
3.375
3
[]
no_license
#[aoc_generator(day2)] fn parse(input: &str) -> Vec<usize> { input.split(',').map(|v| v.parse().unwrap()).collect() } #[aoc(day2, part1)] fn part1(program: &[usize]) -> usize { run(program, 12, 2) } #[aoc(day2, part2)] fn part2(program: &[usize]) -> usize { for noun in 0..=99 { for verb in 0..=99 ...
true
8f8657219e9091464fbbefa182611808b588eb24
Rust
kenkoooo/super-duper-dragon
/src/usi.rs
UTF-8
588
2.609375
3
[]
no_license
use anyhow::Result; use shogiutil::{SfenBoard, SfenMove, UsiRequest, UsiResponse}; use std::io::{stdin, Read}; pub trait UsiPlayer { fn play(&mut self, request: UsiRequest) -> Vec<UsiResponse>; fn usi_play(&mut self) -> Result<()> { loop { let mut input = String::new(); stdin()....
true
ff19e92e10d94c668c178241064e640e6f1d2580
Rust
enierga/rustegrep
/src/main.rs
UTF-8
3,655
2.875
3
[]
no_license
#![allow(unused)] /** * thegrep - Tar Heel egrep * * Author(s): Vincent Enierga * ONYEN(s): venierga * * UNC Honor Pledge: I pledge I have received no unauthorized aid * on this assignment. I further pledge not to distribute my solution * to this code to anyone other than the course staff and partner. */ exter...
true
2ce593f2213593bbb6f35353e113231c76106d84
Rust
sensudata/flux-lsp
/src/protocol/requests.rs
UTF-8
4,530
2.53125
3
[ "MIT" ]
permissive
use serde::de::DeserializeOwned; use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use crate::protocol::properties::{ ContentChange, Position, TextDocument, TextDocumentIdentifier, VersionedTextDocumentIdentifier, }; fn default_id() -> u32 { 0 } #[derive(Serialize, ...
true
0361e02fd99205ea354a5340375eb96a5f8a0a52
Rust
icew4ll/rsub
/src/line.rs
UTF-8
2,196
2.765625
3
[]
no_license
extern crate colored; extern crate csv; extern crate regex; extern crate ssh2; use regex::Regex; use std::fs::File; use std::process; use std::net::TcpStream; use ssh2::Session; use std::io::Read; use std::error::Error; use colored::*; type Record = (String, String, String); fn csvread(conn: &mut Vec<Record>) -> Res...
true
5a464a3f6994125ba8b039a5ffd6c568bac2d90f
Rust
robertohuertasm/toy_json_parser
/src/models.rs
UTF-8
616
2.765625
3
[]
no_license
use serde::Deserialize; use std::{borrow::Cow, collections::HashMap}; pub type TypeLineResults<'a> = HashMap<Cow<'a, str>, TypeLineCounter>; #[derive(Deserialize, Debug)] pub struct TypeLine { #[serde(rename(deserialize = "type"))] pub linetype: String, } #[derive(Debug, Default)] pub struct TypeLineCounter ...
true
9e89dba908e889112bfc9f922fb4ca27f573d90a
Rust
lizelive/dataclasses
/dataclasses_lib/src/example.rs
UTF-8
766
2.65625
3
[]
no_license
#[derive(Dataclass)] #[dataclass(frozen = true, post_init = "post_init")] struct InventoryItem { #[field(default = "helloworld")] name: String, #[field(default_factory = "killme")] adress: String, #[field(init = false)] generated: String, } /// https://docs.python.org/3/library/datacla...
true
ed44ed5f3f6eb393c788dceac449f5a176f9a396
Rust
heyLu/confidence
/.bin/up.rs
UTF-8
814
3
3
[]
no_license
#![feature(rust_2018_preview)] use std::env; use std::path::PathBuf; use std::process; // Checks if it can find a directory (or file) up the directory tree. // // Can be used to check if you're in a vcs-versioned directory, like git, mercurial or svn. // // usage: up .git // up .git <path-to-directory> fn main...
true
8315b42fc17536db07409f91a91d804311ceba27
Rust
rodolfoghi/urionlinejudge
/rust/uri1010/src/main.rs
UTF-8
623
3.421875
3
[]
no_license
use std::io; fn ler() -> (f32, f32) { let mut input = String::new(); io::stdin() .read_line(&mut input) .expect("Failed to read line"); let mut iter = input.trim().split_whitespace(); let _ = iter.next(); let numero_pecas: f32 = iter.next().unwrap().parse().unwrap(); let valo...
true
511487fcf3022f2f6d9f22104829af63fb036b85
Rust
Conzel/chessy
/src/attacks.rs
UTF-8
30,061
2.6875
3
[ "MIT" ]
permissive
use crate::boards::*; use crate::game::*; use crate::magic_number_tables::{MAGIC_NUMBERS_BISHOP, MAGIC_NUMBERS_ROOK}; use crate::make_usize_wrapper; use crate::pieces::*; use crate::positions::*; use array_const_fn_init::array_const_fn_init; use array_init::array_init; use lazy_static::lazy_static; use rand::rngs::Smal...
true
334c13bf82af2986d083dc94d60c69d47e558a6c
Rust
fisherdarling/luther
/src/scanner.rs
UTF-8
8,009
2.953125
3
[]
no_license
use crate::alphabet_translator::alphabet_translator; use crate::dfa::*; use std::collections::BTreeMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::Path; // example scan.u file // x0ax20x5C x6fpqrx73 // wiki/noto.tt pqrs // wiki/nots.tt opqr // wiki/endsq.tt endsq /...
true
183f737241cd9c444d3c42987389172e46e4bdae
Rust
bokuweb/naglfar
/src/window.rs
UTF-8
3,741
2.65625
3
[ "MIT" ]
permissive
extern crate cairo; extern crate gtk; use gtk::traits::*; use gtk::Inhibit; // use gtk::{ContainerExt, WidgetExt, Window}; use cairo::{Context, FontSlant}; use painter::{DisplayCommand, DisplayList}; use layout::Dimensions; struct RenderingWindow { window: gtk::Window, drawing_area: gtk::DrawingArea, } impl...
true
1227c6d382612ab2ec76b66832b9fd368c6cac86
Rust
jarri2di/crate_downloader
/src/lib.rs
UTF-8
6,549
2.78125
3
[ "BSD-3-Clause" ]
permissive
#![deny(warnings)] #[macro_use] extern crate log; #[macro_use] extern crate failure; use failure::Error; use futures_util::StreamExt; use serde::Deserialize; use std::{ fs::File, io::{prelude::*, BufReader}, path::{Path, PathBuf}, }; use structopt::StructOpt; use walkdir::{DirEntry, WalkDir}; #[derive(D...
true
20ba6fcdc09248e2da70097b347a66555f3c3b90
Rust
EFanZh/LeetCode
/src/problem_1288_remove_covered_intervals/mod.rs
UTF-8
611
2.90625
3
[]
no_license
pub mod greedy; pub mod greedy_2; pub trait Solution { fn remove_covered_intervals(intervals: Vec<Vec<i32>>) -> i32; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ (&[[1, 4], [3, 6], [2, 8]] as &[_], 2), (&[[1, 4], [2, 3]], 1...
true
7403f56f56d1fa51877f9a6299b2d2e0a09c7c8c
Rust
Dentosal/vpass
/src/sync/error.rs
UTF-8
1,222
2.609375
3
[ "MIT" ]
permissive
use chrono::prelude::*; use serde_json::Value; #[derive(Debug)] pub enum Error { /// API rate limit reached, try again at ApiRateLimit(DateTime<Utc>), /// Requested key doesn't exist NoSuchKey(String), /// HTTP connection error Http(reqwest::Error), /// HTTP status code implies error. ...
true
7826810cecee0ecedd0e0787dc4c9c0388658715
Rust
fussybeaver/rust_kafka
/src/segment.rs
UTF-8
14,541
3.15625
3
[]
no_license
use std::fs::File; use std::mem; use std::path::PathBuf; use std::path::Path; use std::io::prelude::*; use std::io::SeekFrom; use crc::{crc32, Hasher32}; pub struct Segment { path: PathBuf, pub offset: usize, buffer_size: usize, file: Option<File>, write_buffer: Option<Vec<u8>>, buffer_offset: ...
true
d7f48f5b39c9fd48b79bd9a49e9021db83077e40
Rust
opcode0x90/adventofcode
/2019-04/opcode0x90/src/lib.rs
UTF-8
2,850
3.546875
4
[ "BSD-3-Clause" ]
permissive
use std::{ collections::HashMap, error::Error, io::{BufRead, BufReader, Read}, }; type Range = (usize, usize); fn valid(password: usize) -> bool { // convert number as string, it's easier to process this way let digits = password.to_string(); // two adjacent digits are the same let rule1 ...
true
4cc179c919363ba0bcf645df804a4a3d43eb773b
Rust
QUANTAXIS/rxRust
/src/subject/mut_ref_subject.rs
UTF-8
5,239
2.6875
3
[ "MIT" ]
permissive
use crate::prelude::*; use observer::{complete_proxy_impl, error_proxy_impl, next_proxy_impl}; pub struct MutRefValue<T>(pub *mut T); impl<T> Clone for MutRefValue<T> { #[inline] fn clone(&self) -> Self { MutRefValue(self.0) } } impl<T> Copy for MutRefValue<T> {} #[derive(Clone)] pub struct MutRefSubject<'a, It...
true
1c1f1ab2448a4766927ae83398b5fca643df2b49
Rust
JoNil/rlisp
/rlisp/tests/rlisp_test.rs
UTF-8
5,753
3.109375
3
[ "MIT" ]
permissive
extern crate rlisp; use self::rlisp::Rlisp; #[test] fn test_rlisp() { let mut rlisp = Rlisp::new(); assert_eq!(rlisp.execute("(def {a} 12)"), "()"); assert_eq!(rlisp.execute("(+ a a)"), "24"); assert_eq!(rlisp.execute("(- a 4)"), "8"); assert_eq!(rlisp.execute("(eval (head {(+ 1 2) (+ 10 20)})...
true
d48adb5c6f8da6918188a61814c4fda83c70a487
Rust
mosmeh/tamago
/src/utils.rs
UTF-8
599
3.203125
3
[]
no_license
use bstr::ByteSlice; pub fn extract_name_bytes<'a>(id: &'a str, sep: &Option<String>) -> &'a [u8] { let id = id.as_bytes(); if let Some(sep) = sep { if let Some(pos) = id.find(sep) { return &id[..pos]; } } id } #[cfg(test)] mod tests { use super::*; #[test] fn ...
true
acb9f4dd3eb4a2e16ad2da71c2ba307d79b5f088
Rust
mewbak/Lancelot
/core/src/arch.rs
UTF-8
7,002
3.25
3
[ "Apache-2.0" ]
permissive
use std::{fmt, hash}; use num::FromPrimitive; /// please don't access VA.0 directly. /// its provided so you can construct VA like: /// ``` /// use lancelot::arch::VA; /// let _ = VA(0x0); /// ``` #[derive(Copy, Clone)] pub struct VA(pub u64); impl VA { /// Compute the VA given a delta RVA, like `self:va + other...
true
337c232d78811b4abd3882de3ccd81753f996753
Rust
Vicfred/codeforces-rust
/amusing_joke_141A.rs
UTF-8
1,061
3.25
3
[ "BSD-3-Clause" ]
permissive
// https://codeforces.com/problemset/problem/141/A use std::io; use std::collections::HashMap; fn main() { let mut guest = String::new(); let mut host = String::new(); let mut letters = String::new(); io::stdin() .read_line(&mut guest) .unwrap(); let guest = guest.trim().to_string...
true
12d51efbaf6d8a87aed6ef13f0c80ef6ae0affab
Rust
eira-fransham/wasm-reader
/src/ints.rs
UTF-8
8,794
2.75
3
[]
no_license
use crate::{Error, ParseResult, Parser, ParserError}; use byteorder::ByteOrder; use std::{io::Read, marker::PhantomData}; use wasm_reader_traits::MaybePosition; #[derive(Debug)] pub struct FixedReader<T> { _marker: PhantomData<T>, } impl<T> Clone for FixedReader<T> { fn clone(&self) -> Self { Self::ne...
true
22950b26385d022620d0da41695eab05ee4043f0
Rust
layeddie/instacam
/src/app/settings.rs
UTF-8
1,975
3.203125
3
[]
no_license
use serde::{Deserialize, Serialize}; use serde_json::Result; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Settings { pub input: String, pub output: String, pub width: i32, pub height: i32, pub fps: i64, pub pipeline: Option<Vec<Proc>>, } #[derive(Serialize, Deserialize, Clone, De...
true
8f199d73bf0b53ccc316c658775a93ba1a5b49b9
Rust
fralken/adventofcode2019
/src/days/day07.rs
UTF-8
6,500
2.875
3
[]
no_license
use std::fs; use permutohedron::Heap; #[derive(Default)] struct Ampli { inputs: Vec<i32>, outputs: Vec<i32>, codes: Vec<i32>, pos: usize } impl Ampli { fn new(codes: Vec<i32>, inputs: Vec<i32>) -> Self { Ampli { inputs, codes, ..Default::default() } } fn get_param_value(&self, mod...
true
fdfb5274c3f34ea60e74e1499a6ffa06889bba42
Rust
ives9638/dingir-exchange
/src/message/mod.rs
UTF-8
5,701
2.6875
3
[]
no_license
use crate::market::Order; use crate::types::OrderEventType; use anyhow::Result; use serde::{Deserialize, Serialize}; pub mod consumer; pub mod persist; pub mod producer; pub use producer::{BALANCES_TOPIC, ORDERS_TOPIC, TRADES_TOPIC, UNIFY_TOPIC}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct BalanceMess...
true
759de7dcfc52189653de8a572f088dc932daf2f0
Rust
dai-dao/rust-algorithms
/src/rs/add_two_number_linked_list.rs
UTF-8
3,882
3.59375
4
[]
no_license
use std::fmt; #[derive(Debug, Clone)] struct Node { val : i8, next : Option<Box<Node>> } impl Node { fn new(val : i8) -> Node { return Node { val : val, next : None } } } impl fmt::Display for Node { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Write strictly the fir...
true
1ff9293da4b8f20cabe810b5c1f7c7c2c548e8c0
Rust
babariviere/ats
/native/ats/src/lib.rs
UTF-8
3,443
2.796875
3
[]
no_license
use geo::algorithm::contains::Contains; use rustler::types::ListIterator; use rustler::{Encoder, Env, Error, NifResult, ResourceArc, Term}; mod atoms { rustler::rustler_atoms! { atom ok; //atom error; atom __true__ = "true"; atom __false__ = "false"; } } rustler::rustler_export...
true
cdcb85ec117cd88545f636451424fd0f82fc0ffa
Rust
aloucks/raw-window-handle
/src/appkit.rs
UTF-8
694
2.6875
3
[ "Zlib", "Apache-2.0", "MIT" ]
permissive
use core::ffi::c_void; use core::ptr; /// Raw window handle for AppKit. /// /// ## Construction /// ``` /// # use raw_window_handle::AppKitHandle; /// let mut handle = AppKitHandle::empty(); /// /* set fields */ /// ``` #[non_exhaustive] #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct AppKitHandle { ...
true
1f8ae0420905e1ddcf8465987cc51df453059f3d
Rust
madmax28/aoc2019
/src/day23/mod.rs
UTF-8
3,122
3.125
3
[]
no_license
use crate::day09::{Iss, Value}; use std::convert::TryFrom; #[derive(Debug)] enum Error { UnexpectedIssResult, InvalidAddress, } #[derive(Debug)] struct Packet { address: Value, x: Value, y: Value, } fn run(iss: &mut Iss) -> crate::Result<Option<Packet>> { use crate::day09::StopReason::*; ...
true
743c90fceb31491ee11d12dea3aeb2e822e4b970
Rust
maciejhirsz/logos
/tests/benches/bench.rs
UTF-8
6,304
2.859375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use criterion::{black_box, criterion_group, criterion_main, Criterion, Throughput}; use logos_derive::Logos; #[derive(Debug, Clone, Copy, PartialEq, Logos)] pub enum Token { #[regex(r"[ \n\t\f]", logos::skip)] InvalidToken, #[regex("[a-zA-Z_$][a-zA-Z0-9_$]*")] Identifier, #[regex(r#""([^"\\]|\\t|...
true
11a6e8ef55679e6ede80eed7f8091518d8eac49d
Rust
dejimenez/user-management-rust
/src/jwt.rs
UTF-8
1,672
2.828125
3
[]
no_license
use crate::errors::ServiceError; use serde::{Deserialize, Serialize}; use std::env; use std::time::{SystemTime, UNIX_EPOCH}; use jsonwebtoken::{decode, encode, Algorithm, DecodingKey, EncodingKey, Header, Validation}; use chrono::NaiveDate; use super::models::User; #[derive(Debug, Serialize, Deserialize)] struct Cla...
true
179d990880ac3a7c1e90063ad7ae6ae516e12aea
Rust
chc4/tulpa
/src/parsing.rs
UTF-8
3,371
3.375
3
[]
no_license
use luther; use luther_derive; #[derive(Lexer, Debug)] pub enum Token { #[luther(regex = "function")] Function, #[luther(regex = "if")] If, #[luther(regex = "let")] Let, #[luther(regex = "do")] Do, #[luther(regex = "in")] In, #[luther(regex = "=")] Tis, #[luther(rege...
true
83bbb5378934e1ec5fef9625caee80ae18cf2598
Rust
Shirataki2/competitive_submissions
/abc190/src/bin/f.rs
UTF-8
7,805
3.234375
3
[]
no_license
#![allow(unused_imports)] use proconio::{input, fastout}; use std::cmp::*; use fenwick_tree::*; #[fastout] fn main() { input!(n: usize, mut a: [i64; n]); let mut b = FenwickTree::new(2 * n, |&x, &y| x + y); let mut t: i64 = 0; for i in (0..n).rev() { t += b.sum(a[i] as usize); b.add(a[...
true
c99c2ccddcddd94f41dcc028de636f9647c89474
Rust
cgrage/rustris
/rustris-cmdl/src/curses_ui.rs
UTF-8
14,410
2.859375
3
[ "MIT" ]
permissive
use rustris_core::game::Game; use rustris_core::model::Tetromino; use rustris_core::model::{Board, CellVal, Stats, UserInput}; use std::time::{Duration, Instant}; const ONE_SECOND: Duration = Duration::from_secs(1); #[derive(Debug)] pub struct UI { screen: pancurses::Window, app_win: pancurses::Window, pa...
true
6a72e0275f382683322b14a47ef43a688717819f
Rust
lindseypoche/Brogrammers_Rust_Lang_Study
/projects/TStructsAndTraits/main.rs
UTF-8
2,267
4.1875
4
[]
no_license
//Structs with annotated lifetimes. struct Rectangle<'a> { pub color: &'a String, pub height: u32, pub width: u32, } struct PrivateRectangle<'a> { color: &'a String, height: u32, width: u32, } //Method declaratiions for structs. impl<'a> Rectangle<'a>{ } impl<'a> PrivateRectangle<'a>{ //W...
true
b658c577831166b3834a5a2f20d59550e7b7e62e
Rust
lollek/AoC2018
/5/5.rs
UTF-8
1,770
3.21875
3
[]
no_license
use std::fs::File; use std::io::Read; use std::str; use std::usize; fn main() { let data = setup(); println!("Size (a): {}", q1(data.to_owned())); let smallest = (('a' as u8)..('z' as u8 + 1)) .fold(usize::MAX, |smallest, letter| { let upper_letter = (letter as u8) | 0x20; ...
true
1555e9ab8032509930f433de1851d9b6a288da58
Rust
FauxFaux/catfight
/src/main.rs
UTF-8
8,749
2.703125
3
[ "MIT" ]
permissive
extern crate byteorder; extern crate getopts; extern crate libc; extern crate rand; mod copy; // normal, sane imports: use std::env; use std::io; use std::io::prelude::*; use std::fs; use std::fs::File; // from crates: use getopts::Options; // magic method-adding imports: use std::os::unix::io::AsRawFd; use byteord...
true
7e592909888e4b2a2fcaf5dbbe6b571c2282c365
Rust
keyko-io/xain-fl
/rust/src/common/client.rs
UTF-8
1,346
2.796875
3
[ "Apache-2.0" ]
permissive
use derive_more::{Display, From}; use std::str::FromStr; use uuid::{self, Uuid}; #[derive( Eq, PartialEq, Hash, Debug, Copy, Clone, Display, Serialize, Deserialize, Default, From, )] /// A unique random client identifier pub struct ClientId(Uuid); impl ClientId { /// Return a new random client identifier ...
true
5420ce9d6246d16f4f595a02b3a84e6eeeb6c592
Rust
wonderful-panda/inazuma
/src-tauri/app/src/git/lstree.rs
UTF-8
2,244
2.9375
3
[ "MIT" ]
permissive
use super::{exec, GitError}; use regex::Regex; use std::{collections::HashMap, path::Path}; use types::*; enum EntryBase<'a> { Blob(&'a str), Tree(&'a str), } fn to_entry(base: &EntryBase, entries: &HashMap<&str, Vec<EntryBase>>) -> LstreeEntry { match base { EntryBase::Blob(path) => LstreeEntry {...
true
eb1fb14dcd07a1820c4ebb9af749db4f5d465cf0
Rust
Malique-Auguste/Nariva
/compiler/src/parser/statement.rs
UTF-8
215
2.65625
3
[]
no_license
use crate::parser::expression::Expression; #[derive(Debug, PartialEq)] pub enum Statement { ValueInitialization{symbol: String, value: Expression}, ValueAssignment{symbol: String, value: Expression} }
true
ceaf13a0d0380df4402146f9bc2cd52091ae5842
Rust
EFanZh/Introduction-to-Algorithms
/src/chapter_16_greedy_algorithms/problems/problem_16_2_scheduling_to_minimize_average_completion_time/question_a.rs
UTF-8
624
3
3
[]
no_license
#[must_use] pub fn schedule_tasks(tasks: &[u64]) -> Box<[usize]> { let mut result = tasks.iter().copied().enumerate().collect::<Vec<_>>(); result.sort_by_key(|(_, key)| *key); result.into_iter().map(|(i, _)| i).collect() } #[cfg(test)] mod tests { #[test] fn test_schedule_tasks() { assert...
true
4a2e5215bc93d83696274611c9f0d8a681d17bcc
Rust
vallentin/detect-lang
/src/lib.rs
UTF-8
9,862
3.53125
4
[ "MIT" ]
permissive
//! Utility for identifying names of programming languages (and related files) from paths and file extensions. //! //! # Paths and Extensions //! //! Languages can be identified from paths using [`from_path`] //! or directly from extensions using [`from_extension`]. //! //! [`from_path`]: fn.from_path.html //! [`from_e...
true
28ee22fd81d520481ea49f9fd7efec3160618a4a
Rust
prisma/prisma-engines
/psl/psl/tests/base/basic.rs
UTF-8
6,164
2.9375
3
[ "Apache-2.0" ]
permissive
use crate::common::*; use psl::parser_database::ScalarType; #[test] fn parse_basic_model() { let dml = indoc! {r#" model User { id Int @id firstName String lastName String } "#}; let schema = psl::parse_schema(dml).unwrap(); let user_model = schema.assert_...
true
3fca403745c14ec8182af39b5000fa40ccb3ea34
Rust
jgarte/monty
/montyc/src/context/mod.rs
UTF-8
1,279
2.59375
3
[]
no_license
use std::{ collections::hash_map::DefaultHasher, hash::{Hash, Hasher}, path::PathBuf, }; pub(crate) mod global; pub(crate) mod local; pub(crate) mod module; pub(crate) mod resolver; pub use self::{global::GlobalContext, local::LocalContext, module::ModuleContext}; #[derive(Debug, Clone, Hash, PartialEq, ...
true
b651ba6dfb09a2e7665905eae2a9ac4c0525c6ec
Rust
Noah2610/LD45-WorkingTitle
/src/systems/death_floor.rs
UTF-8
1,148
2.640625
3
[ "MIT" ]
permissive
use super::system_prelude::*; const DEATH_FLOOR: f32 = -50.0; #[derive(Default)] pub struct DeathFloorSystem; impl<'a> System<'a> for DeathFloorSystem { type SystemData = ( Entities<'a>, Write<'a, ResetLevel>, Write<'a, PlayerDeaths>, ReadStorage<'a, Transform>, ReadStorag...
true
9bd0ebbf30e1cca3bacf78a3ab136aa2a9eabed4
Rust
jstarry/solana
/metrics/src/datapoint.rs
UTF-8
5,768
2.9375
3
[ "Apache-2.0" ]
permissive
use std::{fmt, time::SystemTime}; #[derive(Clone, Debug)] pub struct DataPoint { pub name: &'static str, pub timestamp: SystemTime, pub fields: Vec<(&'static str, String)>, } impl DataPoint { pub fn new(name: &'static str) -> Self { DataPoint { name, timestamp: SystemTi...
true
6462a71c6a2e37606c6e7148d4bf5a32c802c507
Rust
rust-rosetta/rust-rosetta
/tasks/catamorphism/src/main.rs
UTF-8
551
3.734375
4
[ "Unlicense" ]
permissive
#![allow(clippy::unnecessary_fold)] fn main() { let numbers = [1, 2, 3, 4, 5]; let sum = numbers.iter().fold(0, |a, n| a + n); println!("{}", sum); let product = numbers.iter().fold(1, |a, n| a * n); println!("{}", product); } #[cfg(test)] mod tests { #[test] fn test_sum() { let su...
true
d820aa398d6325791a81fd282ee571f4bf1515fe
Rust
gtsiam/miniserve
/src/file_upload.rs
UTF-8
9,326
2.515625
3
[ "MIT" ]
permissive
use actix_web::{ http::{header, StatusCode}, HttpRequest, HttpResponse, }; use futures::{future, Future, FutureExt, Stream, TryStreamExt}; use std::{ io::Write, path::{Component, PathBuf}, pin::Pin, }; use crate::errors::{self, ContextualError}; use crate::listing::{self, SortingMethod, SortingOrde...
true
6ec5e30303572ee1fa501609212db14eb8f2e6dd
Rust
zargony/advent-of-code-2017
/src/day21.rs
UTF-8
8,539
3.484375
3
[]
no_license
#[macro_use] extern crate nom; use std::fmt; use std::str::FromStr; #[derive(PartialEq, Clone)] struct Grid { pixels: Vec<Vec<bool>>, } impl fmt::Debug for Grid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { try!(writeln!(f, "Grid:")); for row in &self.pixels { for &pix...
true
db471f98709cd7d7b98e8d43d11777392e2e4a59
Rust
carolhmj/exercism
/rust/acronym/src/lib.rs
UTF-8
1,060
3.6875
4
[]
no_license
pub fn abbreviate(phrase: &str) -> String { //Remove special characters from phrase let phrase = phrase.chars() .map(|c| if !c.is_ascii_punctuation() { c.to_string() } else {" ".to_string()}) .collect::<String>(); println!("{:?}", phrase); //Check if any word is an all-caps or all-lowercase. If there i...
true
facb2f47eeb88267baf9d6f6b4243b1f5f1c68c2
Rust
konkers/nesutil
/tests/pattern_table_test.rs
UTF-8
611
2.5625
3
[ "BSD-2-Clause" ]
permissive
extern crate nesutil; extern crate raster; use std::fs::File; use std::io::prelude::*; #[test] fn load_from_image_test() { let image = raster::open("tests/data/tiles.png").unwrap(); let pt = nesutil::PatternTable::load_from_image(&image).unwrap(); let mut golden_output = [0; 4096]; let mut file = Fi...
true
ef101169eb58b43154415787b53db97349d29b22
Rust
Yuhyeingjoo/Rust-example-of-the-rust-programming-language-
/ch11/src/lib.rs
UTF-8
1,264
3.078125
3
[]
no_license
/***** CH11_1 Problem 1. Complete panic_when_num_is_bigger in a form that the test can be perfomed. 2. Make the panic_case to pass the test ( add "should_panic expect ) *****/ pub fn panic_when_num_is_bigger() { if num >num2{ panic!("{} is bigger than {}", num, num2); ...
true
c14b34d08b224e142445a4464123042b56357a07
Rust
chengluyu/codewars
/rust/1kyu/simple-interactive-interpreter/src/main.rs
UTF-8
2,011
3.65625
4
[ "MIT" ]
permissive
use std::collections::HashMap; enum Token { Whitespace, Punctuator(char), Identifier(String), Number(f32), } struct Lexer { } enum BinaryOp { Add, Sub, Mul, Div, } enum Expr { Reference(String), Number(f32), Binary(BinaryOp, Box<Expr>, Box<Expr>), Assign(String, Box<...
true
eede986792bcc9976646f80c56aafcb14dfbf660
Rust
Wanger-SJTU/leetcode-solutions
/rust/7.整数反转.rs
UTF-8
343
2.5625
3
[ "MIT" ]
permissive
/* * @lc app=leetcode.cn id=7 lang=rust * * [7] 整数反转 */ #include "leetcode.h" // @lc code=start impl Solution { pub fn reverse(x: i32) -> i32 { return x.abs() .to_string() .chars().rev() .collect::<String>() .parse::<i32>() .unwrap_or(0) * x.signum(); } } //...
true
ff9a78b4e6ec7a0776a36ae841660b51aabcb94f
Rust
nicolasvienot/n-puzzle
/src/algo/heuristics.rs
UTF-8
5,039
3.015625
3
[ "MIT" ]
permissive
use std::fmt; use rulinalg::matrix::{Matrix, BaseMatrixMut, BaseMatrix, MatrixSlice}; #[derive(Debug, Clone, PartialEq)] pub enum Heuristic { Manhattan, Euclidian, Hamming, LinearConflict } impl fmt::Display for Heuristic { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}...
true
b47ab5c4c49583f399f61760a8f0fc9b16841f02
Rust
mofanv/veracruz
/veracruz-utils/src/policy/expiry.rs
UTF-8
3,641
3.609375
4
[ "MIT", "CC-BY-SA-2.0" ]
permissive
//! Expiry timepoints //! //! ## Authors //! //! The Veracruz Development Team. //! //! ## Licensing and copyright notice //! //! See the `LICENSE_MIT.markdown` file in the Veracruz root directory for //! information on licensing and copyright. use super::error::PolicyError; use serde::{Deserialize, Serialize}; /////...
true
7b5b7f923c3d71bdcd4239bf8e2b9b5d6f53f728
Rust
sigmaSd/IRust
/script_examples/ipython/src/main.rs
UTF-8
5,543
2.734375
3
[ "MIT" ]
permissive
use std::{ io::{Read, Write}, process::{ChildStdin, Command, Stdio}, sync::mpsc, }; use irust_api::color; use rscript::{scripting::Scripter, Hook, ScriptType, VersionReq}; #[derive(Default)] struct IPython { stdin: Option<ChildStdin>, stdout: Option<mpsc::Receiver<String>>, } impl Scripter for IP...
true
115c0e8b64dea445ce75eeaa58b3a82e53f35239
Rust
xemwebe/finql
/src/datatypes/object_handler.rs
UTF-8
818
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
use async_trait::async_trait; use serde::{de::DeserializeOwned, Serialize}; use super::DataError; /// Handler general, serializable objects /// This is ideal for storing objects for a relational data model is not the best fit /// or objects used very rarely, i.e. descriptions of complex assets. /// The ID is a string...
true
f2d81f50d66bc07c7c1589bc5c62888ec15095a8
Rust
wsttxni/udemy_rust_tutorial
/src/main1.rs
UTF-8
2,811
3.046875
3
[]
no_license
#![allow(unused_variables)] #![allow(dead_code)] mod sh; mod if_exp; mod while_loops; mod for_loops; mod matches; mod structures; use std::mem; const MEANING_OF_LIFE:i8 = 42; // no fixed address static mut Z_TWO:i32 = 132; fn fundamental_data_types() { // i8 u8 i16 u16 i32 u32 let a:u8 = 123; // 8bits 0...
true
459b3088b798d7cbefc8bb35dda5de94a4593698
Rust
sshashank124/graphite
/src/core/ops.rs
UTF-8
3,187
2.609375
3
[]
no_license
#[macro_export] macro_rules! op { ($trait:ident::$op:ident, *$type:ident) => { impl $trait for $type { type Output = $type; #[inline(always)] fn $op(self) -> $type { $type($trait::$op(self.0)) } } }; ($trait:ident::$op:ident, *$lhs:ident -> *$rhs:ident -> $out:ident) ...
true
9f4f0667febf193db67d96e2af3877b0f2047992
Rust
munckymagik/redis-clone
/byte_string/src/lib.rs
UTF-8
3,913
3.0625
3
[]
no_license
#![forbid(unsafe_code)] use std::borrow::Cow; mod from_bytes; use from_bytes::from_bytes; pub use from_bytes::{Number, ParseIntError}; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ByteStr<'inner> { bytes: &'inner [u8], } impl<'outer> ByteStr<'outer> { pub fn new<T>(other: &'outer T) -> Self w...
true
c5b6bd17cf20a64ef06c87c02bc17742104dd078
Rust
Nereuxofficial/rust_move_gen
/src/castling_rights.rs
UTF-8
5,880
3.328125
3
[ "MIT" ]
permissive
use castle::*; use side::Side; use std::fmt; type Internal = u8; /// Represents the right to castle in a particular director for a particular side #[derive(PartialEq, Copy, Clone)] pub struct CastlingRights(pub Internal); pub const WHITE_QS: CastlingRights = CastlingRights(1); pub const BLACK_QS: CastlingRights = Ca...
true
9e6b4bc6c7bc4c3eb340c76f1d7ab0d6095e2a25
Rust
retupmoca/bots
/src/ffi_interface.rs
UTF-8
2,739
2.546875
3
[]
no_license
/** * NOTE: Everything in this file should be considered unsafe! * * Due to limitations of wasm_bindgen, the functions themselves can't be marked * unsafe, but if you treat these like safe functions, you get to keep both * pieces. */ #[cfg(feature = "c_ffi")] use std::os::raw::c_char; #[cfg(feature = "c_ffi")] u...
true
ad445cce344d563af2957643552722e1b1b4ecfd
Rust
lazystitan/rust-learning-and-practice
/algorithms/src/sort/insert_sort.rs
UTF-8
793
3.53125
4
[]
no_license
use super::sort_trait::SortTrait; use std::fmt::Display; pub struct InsertSort; impl<T> SortTrait<T> for InsertSort where T: PartialEq + PartialOrd, { fn sort(vector: &mut Vec<T>) { let n = vector.len(); for i in 1..n { for j in (1..(i + 1)).rev() { if Self::less(&(...
true
669add95b25efc8711e1c2b785fde47b8893c5a5
Rust
zmwangx/rust-ffmpeg
/src/codec/picture.rs
UTF-8
5,173
2.578125
3
[ "WTFPL" ]
permissive
use std::marker::PhantomData; use std::mem; use std::slice; use ffi::*; use format; use libc::{c_int, size_t}; use Error; pub struct Picture<'a> { ptr: *mut AVPicture, format: format::Pixel, width: u32, height: u32, _own: bool, _marker: PhantomData<&'a ()>, } impl<'a> Picture<'a> { pub ...
true
9bd774cc6a0857373f4f347d8deeb0c4ccd3b771
Rust
TheNeikos/shoppe
/src/error.rs
UTF-8
2,996
2.53125
3
[]
no_license
#![allow(dead_code)] use iron::prelude::*; use iron::status; use diesel; use std::error::Error; use std::fmt::{self, Debug}; #[derive(Debug)] pub struct NotImplemented { route: String, } impl NotImplemented { pub fn new(req: &Request) -> NotImplemented { NotImplemented { route: req.url.c...
true
79e7d48d1b7f6140314a4820c8b5c05c0202d7aa
Rust
asmexcaliburwoods/mm0
/mm0-rs/components/mmcc/src/arch/x86/proof.rs
UTF-8
10,445
2.84375
3
[ "CC0-1.0" ]
permissive
//! X86-specific types used in the proof API. use crate::proof::Inst; use super::CC; impl<'a> Inst<'a> { /// The REX byte and the opcode portion of the instruction. pub fn layout(&self) -> InstLayout { self.layout.parse(&mut self.content()) } } fn parse_arr<const N: usize>(p: &mut &[u8]) -> [u8; N] { le...
true
0d13c5a0a90f41d0d826934f1633ac13c65e96f2
Rust
david-sk/projecteuler
/src/problems/0050_consecutive_prime_sum/prime.rs
UTF-8
283
3.3125
3
[]
no_license
// // Prime numbers logic // pub fn is_prime(n: u64) -> bool { if n < 3 || n % 2 == 0 { return n == 2; } let end = (n as f64).sqrt() as u64; for i in (3..=end).step_by(2) { if n % i == 0 { return false; } } return true; }
true
5503d29ac2205dd49ef9fd37810378e64469a175
Rust
evgenykuzyakov/near-cli
/src/commands/view_command/view_transaction_status/operation_mode/online_mode/mod.rs
UTF-8
923
2.6875
3
[]
no_license
pub mod select_server; /// аргументы, необходимые для создания транзакции в online mode #[derive(Debug, Default, clap::Clap)] pub struct CliNetworkArgs { #[clap(subcommand)] selected_server: Option<self::select_server::CliSelectServer>, } #[derive(Debug)] pub struct NetworkArgs { selected_server: self::se...
true
c1524048afef2ab6c09f810e734e2b2ac3e5e63c
Rust
lauraleegunn/matasano
/set1/repeating_key_xor/src/hamming.rs
UTF-8
1,740
4.15625
4
[]
no_license
//! # Hamming Distance //! //! The hamming distance is the amount of bits that need //! to be changed to go from one value to another. //! This is some code to calculate (normalized) //! hamming distances of bytes and strings of bytes. /// # Hamming Distance between two bytes /// /// Computes the hamming distance bet...
true
f4db854dc98cab2a007d881e6701f032cb852ab4
Rust
DaseinPhaos/arendur
/src/shape/sphere.rs
UTF-8
12,111
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2017 Dasein Phaos aka. Luxko // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except a...
true
5bb19292ea6bf8cfc97a03f505d24fcf919340ef
Rust
Akagi201/learning-rust
/misc/crate/lang/project-director/english/greetings.rs
UTF-8
118
2.859375
3
[ "MIT" ]
permissive
// english/greetings.rs pub fn hello() { println!("Hello!"); } pub fn hey_guies() { println!("Hey, guies!") }
true
94156ab4146f731734244aa92f832811242f9750
Rust
age-rs/old-gods
/old_gods/src/components/path.rs
UTF-8
3,403
3.359375
3
[]
no_license
#[derive(Debug, Clone)] pub enum PathComponent { /// The entity has a Name HasName(String), /// The entity is an Effect IsEffect } #[derive(Debug, Clone)] pub enum PathSpace { /// The entity lives within an inventory. Get the inventory by its Name. Inventory(String, Vec<PathComponent>), } /// An EntityP...
true
396eb1a84e8fb97abfeb617599713a078900873c
Rust
tandrysyawaludin/trashbuddy-api
/src/partner_review_module/mod.rs
UTF-8
2,196
2.71875
3
[]
no_license
use database; use rocket_contrib::{Json, Value}; mod partner_review; use self::partner_review::{AlreadyPartnerReview, NewPartnerReview, PartnerReview}; #[post("/", data = "<partner_reviews>", format = "application/json")] fn create_partner_review( partner_reviews: Json<NewPartnerReview>, connection: database::...
true
ca2f230a778953d8fe39e8b6783f4b7edc8f8afd
Rust
redox-os/drivers
/nvmed/src/scheme.rs
UTF-8
18,543
2.640625
3
[ "MIT", "BSD-3-Clause" ]
permissive
use std::collections::BTreeMap; use std::convert::{TryFrom, TryInto}; use std::fmt::Write; use std::io; use std::io::prelude::*; use std::sync::Arc; use std::{cmp, str}; use syscall::{ Error, Io, Result, SchemeBlockMut, Stat, EACCES, EBADF, EINVAL, EISDIR, ENOENT, ENOLCK, EOVERFLOW, MODE_DIR, MODE_FILE, O_DIRE...
true
bf0f298277a68a0518f122eef982f37f342cb64d
Rust
chinagxwei/learn-rust-by-leetcode
/src/problems_1_to_10/problems_6_zigzag_conversion.rs
UTF-8
1,770
3.796875
4
[]
no_license
/// 6. /// /// 将一个给定字符串根据给定的行数,以从上往下、从左到右进行 Z 字形排列。 /// /// 比如输入字符串为 "LEETCODEISHIRING" 行数为 3 时,排列如下: /// /// L C I R /// E T O E S I I G /// E D H N /// 之后,你的输出需要从左往右逐行读取,产生出一个新的字符串,比如:"LCIRETOESIIGEDHN"。 /// /// 请你实现这个将字符串进行指定行数变换的函数: /// /// string convert(string s, int numRows); /// 示例 1: /// /// 输入: s ...
true
42ef5df0c1878fbc199120c04426663d611d7be3
Rust
obeah/sheeit
/sheeit_storage/src/location/iterator.rs
UTF-8
7,401
2.875
3
[ "MIT" ]
permissive
use super::{CellRange, SheetCoordinate, SheetRange}; use crate::size_check::NonNegativeIsize; use crate::{Cell, Sheet}; use im::vector::Focus; use im::Vector; use std::cmp; use std::isize; /// A trait that allows you to create an IntoIterator-like with the context of T pub trait IntoIteratorWith<'a, T> { type Item...
true