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
d545cb848a6b78a3ded37a323d261caa2100f86c
Rust
tuzz/game-engine
/src/systems/model_loader.rs
UTF-8
6,885
2.578125
3
[]
no_license
use specs::prelude::*; use tobj::{load_obj_buf, load_mtl_buf}; use std::collections::HashMap; use std::io::BufReader; use crate::resources::*; use crate::components::*; pub struct ModelLoader; #[derive(SystemData)] pub struct SysData<'a> { entities: Entities<'a>, model_groups: Write<'a, ModelGroups>, mod...
true
b39f21f5525ae32dbc32d1fcce20daeced9dffc2
Rust
froyoframework/rust-intro
/basic-rust-sample/src/main.rs
UTF-8
2,177
3.546875
4
[ "MIT" ]
permissive
#[derive(Debug)] struct Pemain { nama: String, umur: i32, gol: i32, } impl Pemain { fn new(nama: &str) -> Pemain { Pemain { nama: nama.to_string(), umur: 27, gol: 100 } } fn get_gol(&self) -> i32 { self.gol } } fn main() { //...
true
5fa21c955021f62daeb826640b6400d6c2500574
Rust
sampersand/qutie
/src/obj/objects/null.rs
UTF-8
1,564
2.828125
3
[]
no_license
use obj::objects::object::{Object, ObjType}; use obj::objects::boolean::{Boolean, FALSE}; pub struct Null {} pub const NULL: Null = Null{}; impl Null { #[inline] pub fn get() -> Null { NULL } pub fn to_string(&self) -> String { "null".to_string() } } use std; impl_defaults!(Debug; Null, "...
true
75ef22efe4aa71bf152891bad8c4955aeff07d69
Rust
Orangenosecom/philipshue
/examples/recall_scene.rs
UTF-8
915
2.5625
3
[ "MIT" ]
permissive
extern crate philipshue; use std::env; use std::num::ParseIntError; use philipshue::bridge::Bridge; mod discover; use discover::discover; fn main() { match run() { Ok(()) => (), Err(_) => println!("Invalid number!"), } } fn run() -> Result<(), ParseIntError> { let args: Vec<String> = en...
true
e05b8cd653648f4baac3718857ac2359b32ea131
Rust
akiles/embassy
/embassy-usb/src/descriptor_reader.rs
UTF-8
3,112
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::descriptor::descriptor_type; use crate::driver::EndpointAddress; use crate::types::InterfaceNumber; #[derive(Copy, Clone, PartialEq, Eq, Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub struct ReadError; pub struct Reader<'a> { data: &'a [u8], } impl<'a> Reader<'a> { pub fn new(da...
true
2f08df3bbb4a0bbd605d1fd3850003ae87e4a723
Rust
drupalio/comprakt
/compiler-lib/src/firm_context.rs
UTF-8
7,205
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{ firm::{ runtime::{self, Runtime}, FirmProgram, Options, ProgramGenerator, }, strtab::StringTable, type_checking::{type_analysis::TypeAnalysis, type_system::TypeSystem}, }; use lazy_static::lazy_static; use libfirm_rs::{bindings, types::TyTrait}; use optimization; use std::{...
true
cc0dc8d0859474bb5b14b062fc8837e151a927ec
Rust
dpc/rust-extfsm
/src/lib.rs
UTF-8
35,883
3.125
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
//! Implementation of a generic final state machine with //! extended state. Features worth mentioning: //! //! * optional exit/enter transitions on states //! * each event instance can provide boxed arguments to transiton closure //! * each transition closure can return with vector of arguments that //! are queued a...
true
94b246a882da9e3cddd1661079d8becd5ae5d3c6
Rust
houlei/QuantMath
/src/instruments/assets.rs
UTF-8
12,382
3.15625
3
[ "MIT" ]
permissive
use std::rc::Rc; use std::fmt::Display; use std::fmt; use std::cmp::Ordering; use std::hash::Hash; use std::hash::Hasher; use instruments::Instrument; use instruments::Priceable; use instruments::PricingContext; use instruments::DependencyContext; use instruments::SpotRequirement; use dates::rules::DateRule; use dates:...
true
dafd31f7983e92f20ac95701dbcded2f7b3ed534
Rust
LycrusHamster/muta
/binding-macro/src/lib.rs
UTF-8
8,641
2.859375
3
[ "MIT" ]
permissive
extern crate proc_macro; mod common; mod cycles; mod hooks; mod read_write; mod service; use proc_macro::TokenStream; use crate::cycles::gen_cycles_code; use crate::hooks::verify_hook; use crate::read_write::verify_read_or_write; use crate::service::gen_service_code; #[rustfmt::skip] /// `#[genesis]` marks a servic...
true
2ee5649a692960758e26f1dea74f5e37c2c65653
Rust
semargal/num-to-words
/src/utils.rs
UTF-8
218
3.140625
3
[ "Apache-2.0" ]
permissive
use crate::types::*; pub fn int_to_triplets(mut number: Int) -> Vec<Int> { let mut triplets = Vec::new(); while number > 0 { triplets.push(number % 1000); number /= 1000; } triplets }
true
7cace3920061be374e669ae33027e29958876737
Rust
feldim2425/AdventOfCode19
/day_09/main.rs
UTF-8
527
2.578125
3
[]
no_license
#[path = "../common/title.rs"] mod title; mod intcomputer; use std::fs; use intcomputer::*; fn solve_puzzle(mem: &Vec<i64>) { let result = run_program(mem, &vec![1]); println!("1.) {}", result.get_result().unwrap().outputs[0]); let result_2 = run_program(mem, &vec![2]); println!("2.) {}", result_2.ge...
true
a9fa4e18755fb07cc3617570576d21091e79e7f0
Rust
automerge/automerge
/rust/automerge/benches/map.rs
UTF-8
8,485
2.5625
3
[ "MIT" ]
permissive
use automerge::{transaction::Transactable, Automerge, ScalarValue, ROOT}; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; fn repeated_increment(n: u64) -> Automerge { let mut doc = Automerge::new(); let mut tx = doc.transaction(); tx.put(ROOT, "counter", ScalarValue::counter(0)).u...
true
47a6454a7c768353f8f37e6e6a021f2291efe339
Rust
luryus/cursive
/cursive-core/src/views/focus_tracker.rs
UTF-8
1,718
3.140625
3
[ "MIT" ]
permissive
use crate::{ direction::Direction, event::{Event, EventResult}, view::{CannotFocus, View, ViewWrapper}, With, }; /// Detects focus events for a view. pub struct FocusTracker<T> { view: T, on_focus_lost: Box<dyn FnMut(&mut T) -> EventResult>, on_focus: Box<dyn FnMut(&mut T) -> EventResult>, ...
true
1e5fbe71ecf187abca4242e223dce834cf43858b
Rust
kevincox/rustymedia
/src/cache.rs
UTF-8
1,597
2.703125
3
[ "Apache-2.0" ]
permissive
use lru_cache; use smallvec; use std; #[derive(Debug)] struct Entry { format: crate::ffmpeg::Format, media: std::sync::Arc<dyn crate::Media>, } #[derive(Debug)] pub struct TranscodeCache { values: lru_cache::LruCache< String, smallvec::SmallVec<[Entry; 1]>>, } impl TranscodeCache { pub fn new() -> Self { T...
true
a22de3592e800f0286278dc50facbf5b8f21a6d9
Rust
AIRTucha/TinyRenderer.rs
/src/engine.rs
UTF-8
2,982
2.890625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::common::Vec3; use crate::matrix::Matrix4x4; use std::f64; use std::vec; use std::vec::Vec; use wasm_bindgen::Clamped; use wasm_bindgen::JsCast; use web_sys::ImageData; pub struct Engine { width: u32, height: u32, context: web_sys::CanvasRenderingContext2d, } impl Engine { pub fn render(&sel...
true
8a50277e12d27526220acabc8342583825a22eee
Rust
bwindsor22/thistle
/src/database/cosine_db.rs
UTF-8
1,487
3.265625
3
[]
no_license
use crate::database::embedding::get_embedding; use crate::database::db::{Operations, Doc}; pub struct CosineDB { pub docs: Vec<Doc>, } impl Operations for CosineDB { fn load(&mut self, texts: Vec<String>) { for text in texts { let vect = get_embedding(&text); self.docs.push(Doc...
true
b82e84d842b6da507b489b5429124d4fdf57ec46
Rust
mbStavola/Voltaire
/src/action/scan.rs
UTF-8
3,280
2.796875
3
[]
no_license
use std::fs; use std::path::{Path, PathBuf}; pub fn execute(volatility_path: PathBuf, args: &super::ArgMatches) { let source = Path::new(args.value_of("source").unwrap()); let destination = Path::new(args.value_of("destination").unwrap()); let es = args.value_of("es").unwrap(); let profile = args.value...
true
e0690cadd7085c2832072b868681f0ff6753b509
Rust
micahhausler/jwtdecode-rust
/src/jwt.rs
UTF-8
1,725
3.484375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use base64::decode; use serde::{Deserialize, Serialize}; use serde_json; use std::collections::HashMap; /// JWT represents a JSON web token #[derive(Serialize, Deserialize, Debug)] pub struct JWT { pub header: HashMap<String, String>, pub body: HashMap<String, serde_json::Value>, pub signature: String, ...
true
0513a07d8ac8c393daee13fe358145d87cfd09fc
Rust
Pagliacii/sicp-reg-machine
/examples/ec_evaluator/supports/primitive.rs
UTF-8
3,625
3.046875
3
[ "MIT" ]
permissive
use reg_machine::{ machine::{ procedure::Procedure, value::{ToValue, Value}, }, make_proc, math, }; use super::{ io::display, list::{is_null_pair, list_ref, list_rest}, }; pub fn apply_primitive_procedure(proc: Vec<Value>, args: Vec<Value>) -> Value { let pair = &proc; if p...
true
89c8a426522045e23bdad0878d5c09b425882af0
Rust
grumpyjames/aoc-2018
/src/nine.rs
UTF-8
2,311
3.15625
3
[]
no_license
extern crate regex; #[derive(Debug)] struct Player { score: usize } struct Entry { value: usize, prev: usize, next: usize, } fn main() { let player_count = 448; let marble_count= 7162800; let mut players = Vec::new(); for _i in 0..player_count { players.push(Player {score: 0}...
true
16113fe8bfb7ddcab277e35006f128ff41ff871a
Rust
gnzlbg/is_sorted
/src/unsigned.rs
UTF-8
11,189
2.921875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Algorithms for unsigned integers #![allow(unused_attributes)] /// 128-bit-wide algorithm for slices of unsigned integers /// /// Note: /// * `_mm_load_si128` requires `SSE2` /// * `_mm_alignr_epi8` requires `SSSE3` /// * `_mm_and_si128` requires `SSE2` /// * `_mm_test_all_ones` requires `SSE4.1` macro_rules! unsig...
true
400056a434a3db49674dfb21adf12c9615bed5a5
Rust
taxmeifyoucan/cadr-guide
/src/build_system/dotnet.rs
UTF-8
4,916
2.625
3
[]
no_license
use std::io; use std::path::Path; use super::ExecutableSuggestion; fn deserialize_ignore_any<'de, D: serde::Deserializer<'de>>(deserializer: D) -> Result<(), D::Error> { use serde::Deserialize; serde::de::IgnoredAny::deserialize(deserializer)?; Ok(()) } pub fn suggest_executables(source_dir: &Path) -> Ve...
true
ad38a7606f982282e7ff576ce0b7936b470b0810
Rust
HectorIGH/Competitive-Programming
/Leetcode Challenge/07_July_2020/Rust/Week 3/3_Top K Frequent Elements.rs
UTF-8
1,191
3.328125
3
[]
no_license
//Given a non-empty array of integers, return the k most frequent elements. // //Example 1: // //Input: nums = [1,1,1,2,2,3], k = 2 //Output: [1,2] //Example 2: // //Input: nums = [1], k = 1 //Output: [1] //Note: // //You may assume k is always valid, 1 ≤ k ≤ number of unique elements. //Your algorithm's time complexit...
true
05bbdb4d96a553c485716978b22e3ca5c85593cb
Rust
ffahri/rust-server-finder
/src/main.rs
UTF-8
479
2.546875
3
[]
no_license
use reqwest::Error; #[tokio::main] async fn main() -> Result<(), Error> { println!("Hello, world!"); let client = reqwest::Client::new(); let resp = client.get("https://api.battlemetrics.com/servers") .query(&[ ("filter[game]", "rust"), ("filter[status]", "online"), ...
true
98bc2f413b64a934c5f686e7a168d8ec8f5204b4
Rust
wayslog/veda
/src/hmac/murmur3.rs
UTF-8
1,807
3.03125
3
[ "MIT" ]
permissive
const C1: u32 = 0x85eb_ca6b; const C2: u32 = 0xc2b2_ae35; const R1: u32 = 16; const R2: u32 = 13; const M: u32 = 5; const N: u32 = 0xe654_6b64; pub fn murmur3_32(source: &[u8], seed: u32) -> u32 { let buf = source.as_ref(); let mut processed = 0; let mut state = seed; let mut iter = buf.array_chunks:...
true
d194d5959a6e18b6af4ae3578ae8fe3a1cb87eef
Rust
SINHASantos/grpc-rust
/grpc/src/bytesx/iter_buf.rs
UTF-8
1,616
3.078125
3
[ "MIT" ]
permissive
use bytes::Buf; use std::cmp; pub(crate) struct IterBuf<B: Buf, I: Iterator<Item = B>> { iter: I, next: Option<B>, rem: usize, } impl<B: Buf, I: Iterator<Item = B>> IterBuf<B, I> { pub fn new(iter: I, rem: usize) -> IterBuf<B, I> { let mut b = IterBuf { next: None, iter...
true
ccda2f0ea75886f16927526527d5bb5067500d9d
Rust
pcein/trust-rust
/code/interesting-crates/maplit-demo/src/main.rs
UTF-8
212
3.0625
3
[]
no_license
#[macro_use] extern crate maplit; fn main() { let fruits = hashmap! { "apple" => 100, "orange" => 120, "mango" => 130, }; println!("{:?}", fruits); }
true
a91db9607f04b0db156aa9874cf37dd1effdbf45
Rust
jtescher/aoc-2020
/src/day_14.rs
UTF-8
4,310
3.5
4
[]
no_license
use std::collections::HashMap; pub fn part_one(input: &str) -> anyhow::Result<usize> { let mut addresses = HashMap::new(); let mut mask = ""; for line in input.lines() { if line.starts_with("mask") { mask = line .splitn(2, " = ") .last() ...
true
253dc74faef6c537d2ab04c8140b725e65f9fb30
Rust
Larusso/unity-version-manager
/uvm_core/src/unity/hub/mod.rs
UTF-8
1,601
2.84375
3
[ "Apache-2.0" ]
permissive
pub mod editors; pub mod paths; use std::io; use crate::unity; use thiserror::Error; // #[derive(Error, Debug)] pub enum UvmHubError { #[error("unity hub config: '{0}' is missing")] ConfigNotFound(String), #[error("Unity Hub config directory missing")] ConfigDirectoryNotFound, #[error("failed...
true
ac14af1cef4716e639f93625345bf3967ffb28bf
Rust
rust-rosetta/rust-rosetta
/tasks/count-in-octal/src/main.rs
UTF-8
135
3.171875
3
[ "Unlicense" ]
permissive
use std::u8; fn main() { // We count from 0 to 255 (377 in octal) for i in 0..=u8::MAX { println!("{:o}", i); } }
true
86b3a27f4e34ea2e06bd62d6f4cd8116b59fcfe6
Rust
gleam-lang/gleam
/compiler-cli/src/export.rs
UTF-8
2,976
2.59375
3
[ "Apache-2.0" ]
permissive
use gleam_core::{ build::{Codegen, Mode, Options, Target}, Result, }; // TODO: start in embedded mode // TODO: test /// Generate a directory of precompiled Erlang along with a start script. /// Suitable for deployment to a server. /// /// For each Erlang application (aka package) directory these directories a...
true
5f97a2439ceec0ae964b9752bde5a60bf59395ab
Rust
richiprieto/Rust_examples
/Cap5/tuple_structs/src/main.rs
UTF-8
464
3.609375
4
[]
no_license
fn main() { //las estructuras tupla no tienen nombres //asociados a colos campos, solo tienen tipos //son utiles cuando se necesita dar un nombre //a la tupla y que sea diferente a otras especificas struct Color(i32, i32, i32); struct Point(i32, i32, i32); let black = Color(1, 0, 0); le...
true
bd89b53829df1913aa0ccd0a211337db8c3d1230
Rust
COLDTURNIP/raphanus_leetcode
/rust/src/p950.rs
UTF-8
2,614
3.859375
4
[]
no_license
/* Problem 950. Reveal Cards In Increasing Order ============================================= https://leetcode.com/problems/reveal-cards-in-increasing-order/ In a deck of cards, every card has a unique integer. You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in o...
true
dc0486acba9b7c319f58f22057b6e725a37f075b
Rust
jonlamb-gh/openscad-models-rust
/wood-projects/couch/src/board.rs
UTF-8
1,919
2.96875
3
[ "MIT" ]
permissive
use dimdraw::{ObjectAssembler, ObjectDescriptor}; use scad::*; use board_dimensions::BoardDimensions; pub struct Board { dimensions: BoardDimensions, color: Option<String>, } impl Board { pub fn new(length: f32, width: f32, thickness: f32, color: Option<&'static str>) -> Self { let mc = if let So...
true
23ab0a371542550d5f758d2951f88a517e8c2480
Rust
purplg/orrient
/src/api/endpoints.rs
UTF-8
1,589
2.6875
3
[ "MIT" ]
permissive
use super::{AccountAchievement, Achievement, AllAccountAchievements, AllAchievementIDs, Dailies}; /// Represents how and where to access the requested data pub trait Endpoint<P> { /// Whether the endpoint requires an API key from the user const AUTHENTICATED: bool; /// Build a url path to the endpoint fro...
true
fab951f36b616653c0c97c83f3dd3abbb4ceef07
Rust
hubert-levangong/Rust
/CC/Challenge5-bis/src/main.rs
UTF-8
2,514
3.03125
3
[]
no_license
use std::fs; use std::io::{Read, Write}; use std::error::Error; use base64::{decode, decode_config}; // // Additional testing to confirm // the complete chain from loading a Base64'ed binary file // all the way to decoding it using a multiple bytes key // fn main() { let filename = String::from("/Users/hubert/Doc...
true
37726f1fbdd9dbc387e849405bc3a5e7c7b58fdc
Rust
arun11299/Rust-Practice
/concurrency4.rs
UTF-8
858
3.015625
3
[]
no_license
use std::thread; use std::sync::{Mutex, Arc}; fn main() { let m = Arc::new(Mutex::new(0)); let m1 = Arc::clone(&m); let m2 = Arc::clone(&m1); let handle1 = thread::spawn(move || { loop { let mut num = m1.lock().unwrap(); *num = *num + 1; println!("Thread-1 v...
true
f3f22c5a946ac7dde7ee73a28463ab6325bd1255
Rust
myarchsource/rust
/vendor/cookie_store/src/cookie_expiration.rs
UTF-8
7,367
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
use std; use std::ops::Deref; use serde::{Deserialize, Serialize}; use time::{self, Tm}; #[derive(PartialEq, Eq, Clone, Debug, Hash, PartialOrd, Ord)] pub struct SerializableTm(Tm); impl Deref for SerializableTm { type Target = time::Tm; fn deref(&self) -> &Self::Target { &self.0 } } impl From<T...
true
3977eb1e4154c9ce33d2e561940e7fb68eb7fac7
Rust
lukaspustina/ifconfig-rs
/src/fairings.rs
UTF-8
1,100
2.671875
3
[ "MIT" ]
permissive
use rocket::{Data, Request, Response}; use rocket::fairing::{Fairing, Info, Kind}; use std::str::FromStr; use std::net::IpAddr; use std::net::SocketAddr; #[derive(Default)] pub struct HerokuForwardedFor; impl Fairing for HerokuForwardedFor { fn info(&self) -> Info { Info { name: "Set the reque...
true
166ebc25dfc1a8f0daa70ea6c3cdd8e1ad0d35cb
Rust
prataprc/gist
/rs/partial_ord.rs
UTF-8
208
3.21875
3
[ "MIT" ]
permissive
#[derive(PartialEq,PartialOrd,Default,Debug)] struct X { a: u32, b: u32, } fn main() { let x = X{a: 10, b: 20}; let y = X{a: 10, b: 20}; println!("{:?}", x); println!("{}", x < y); }
true
cac472a5c0abfc476bc427a8438d487c51550fda
Rust
sanderhahn/adventofcode2020-rs
/examples/day05b.rs
UTF-8
1,021
3.296875
3
[]
no_license
use std::{fs::File, io::BufRead, io::BufReader, io::Error}; fn parse_num(str: &str) -> u32 { let mut num = 0; for c in str.chars() { num <<= 1; num |= match c { 'F' => 0, 'B' => 1, 'R' => 1, 'L' => 0, c => panic!("invalid input {}", c)...
true
dc4a2407696acaee71594c6f3d87e87773b15650
Rust
newpavlov/rustrush-crypto-workshop
/pwhash/src/main.rs
UTF-8
1,002
2.9375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! #Examples //! ```sh //! rustrush-pwhash pbkdf2 my_salt my_password //! ceQDgNQEkik+bmUXyPZUsuvP0xTJaAcWSJvRR4Ryb2I= //! ``` //! //! ```sh //! rustrush-pwhash argon2 my_salt my_password //! 0ebFEUWTY+Y+FaTeA/jbIP4Ofc83lnlk76Bol+CkPk8= //! ``` use structopt::StructOpt; use hmac::Hmac; use sha2::Sha256; mod cli; use ...
true
c983cb5f59c361d7b7513f4936491b42e6ff9634
Rust
Symforian/University
/Rust/List_1/T4/square_area_to_circle.rs
UTF-8
712
3.546875
4
[]
no_license
fn square_area_to_circle(size:f64) -> f64 { let r = size.sqrt()/2f64; std::f64::consts::PI*r*r } fn main() { square_area_to_circle(5.0); } #[cfg(test)] mod tests { use super::square_area_to_circle; #[test] fn test1() { assert_eq!(square_area_to_circle(0.0), 0.0); } #[test] ...
true
fc9dfed70f648924de06af58fac58c74c4f2b8e1
Rust
getsentry/symbolic
/symbolic-debuginfo/src/base.rs
UTF-8
30,288
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::borrow::Cow; use std::fmt; use std::iter::FromIterator; use std::ops::{Bound, Deref, RangeBounds}; use std::str::FromStr; use symbolic_common::{clean_path, join_path, Arch, CodeId, DebugId, Name}; use crate::sourcebundle::SourceFileDescriptor; pub(crate) trait Parse<'data>: Sized { type Error; fn p...
true
921b7fc5d351977c5fd95c73e72e1b44056dab48
Rust
vain0x/procon
/rust/src/procon/graph/strong_component_decomposition.rs
UTF-8
2,459
2.984375
3
[ "CC0-1.0" ]
permissive
// Verified: http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=3429517#1 use std; pub struct StrongComponentDecomposition<'a> { /// Number of vertices. n: usize, /// The graph. g: &'a [Vec<usize>], /// Dual of the graph. h: Vec<Vec<usize>>, /// gray[u] = true if the vertex u is visited....
true
16df30d81180ed9b83f35dd8c80cec60ff5485e1
Rust
virtualgraham/wasm-graph-app
/tests/graph/iterator/recursive_test.rs
UTF-8
4,282
2.59375
3
[]
no_license
use gizmo_graph_db::graph::iterator::fixed::{Fixed}; use gizmo_graph_db::graph::iterator::and::{And}; use gizmo_graph_db::graph::iterator::save::{tag}; use gizmo_graph_db::graph::iterator::recursive::{Recursive}; use gizmo_graph_db::graph::iterator::{Shape, Morphism}; use gizmo_graph_db::graph::refs::{pre_fetched, Name...
true
6cfd429d2d521de43364ede911e5eb6f4730fd96
Rust
doubleduck98/uni
/rust/lista1/zad4/src/main.rs
UTF-8
1,230
3.53125
4
[]
no_license
fn main() { println!("{}", square_area_to_circle(14.0)); } fn square_area_to_circle(size: f64) -> f64 { size / 4.0 * std::f64::consts::PI } fn assert_close(a: f64, b: f64, epsilon: f64) { assert!( (a - b).abs() < epsilon, format!("Expected: {}, got: {}", b, a) ); } #[test] fn test0() ...
true
2b6bdf8c7b798180744c0aebc4013c7c0390a532
Rust
IThawk/rust-project
/rust-data-struct/src/Algorithms/dynamic_programming/edit_distance.rs
UTF-8
4,874
3.6875
4
[ "Apache-2.0" ]
permissive
//! Compute the edit distance between two strings use std::cmp::min; /// edit_distance(str_a, str_b) returns the edit distance between the two /// strings This edit distance is defined as being 1 point per insertion, /// substitution, or deletion which must be made to make the strings equal. /// /// This function ite...
true
d5f608ff9a28f1debc0404e5034c869eef71e850
Rust
necauqua/quantum-loops
/src/states/main_menu.rs
UTF-8
2,993
2.53125
3
[ "MIT" ]
permissive
use noise::{NoiseFn, Perlin}; use crate::{ engine::{self, event::Event, ui::Button, *}, states::{ level_select::LevelMenuState, main_game::draw_background, options::OptionsState, scores::ScoresState, tutorial::TutorialState, }, QuantumLoops, }; use nalgebra::Vector2; #[derive(Debug)] p...
true
d0da11ea7004503c67e34af9ab891eeb19ccd539
Rust
typed-io/cryptoxide
/src/sha1.rs
UTF-8
1,679
3.21875
3
[ "Apache-2.0", "MIT" ]
permissive
//! An implementation of the SHA-1 cryptographic hash algorithm. //! //! it is however discouraged to use this algorithm in any application as is, as this is //! not considered secured anymore. the algorithm is deprecated since 2011, and chosen prefix //! attack are practical. //! //! However the hash function is still...
true
0bb75eb0a955ef4f8c166399ede42b7d07890a6c
Rust
iobtl/raytrace-rs
/src/instances.rs
UTF-8
5,907
3.078125
3
[]
no_license
use crate::{ aabb::AABB, hittable::{HitModel, HitRecord, Hittable}, ray::Ray, utility::{degrees_to_radians, INFINITY}, vec3::Vec3, }; #[derive(Clone)] pub struct Translate<'a> { hit_model: Box<HitModel<'a>>, offset: Vec3, } impl<'a> Translate<'a> { pub fn new(hit_model: HitModel<'a>, o...
true
fea71dbce837fb397dfa84a4602e1003934c75d4
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc136/src/bin/e.rs
UTF-8
818
2.953125
3
[]
no_license
use proconio::input; fn divisors(n: usize) -> Vec<usize> { let mut d = vec![]; for i in 1.. { if i * i > n { break; } if n % i == 0 { d.push(i); if i != n / i { d.push(n / i); } } } d.sort(); d } fn mai...
true
952c546042da4cd9d7d9ae94929bfe539430c90c
Rust
ccdle12/kvs-db
/course-examples/project-3/src/client.rs
UTF-8
2,241
3.1875
3
[]
no_license
use crate::common::{GetResponse, RemoveResponse, Request, SetResponse}; use crate::{KvStoreError, Result}; use serde::Deserialize; use serde_json::de::{Deserializer, IoRead}; use std::io::{BufReader, BufWriter, Write}; use std::net::{TcpStream, ToSocketAddrs}; /// Key Value store client that reads and writes to a Key ...
true
9d9cbeb604893f124eefb47d3ea05b3f1016908f
Rust
bastiion/json-typedef-infer
/src/hints.rs
UTF-8
6,203
3.40625
3
[ "MIT" ]
permissive
use crate::inferred_number::NumType; /// Hints for [`Inferrer`][`crate::Inferrer`]. /// /// By default, [`Inferrer`][`crate::Inferrer`] will never produce enum, values, /// or discriminator forms. Hints tell [`Inferrer`][`crate::Inferrer`] to use /// these forms. See [`HintSet`] for details on how you can specify the ...
true
8e4f51d65a17a8ba031877c9206d029b92fe3163
Rust
bba7474/advent-2020
/day_09/src/main.rs
UTF-8
2,113
3.171875
3
[]
no_license
use std::fs; use std::io::{BufWriter, stdout}; use ferris_says::say; use itertools::iproduct; fn main() { let input = read_input(); let invalid_number = find_number_not_matching_rule(input.clone()); announce_answer(format!("{} is the first number that is not a sum of two of the previous 25 numbers", inval...
true
33fc6f32efb0ada14bcfb036415789d6fa3d8531
Rust
zachwood0s/lambda
/src/main.rs
UTF-8
1,074
2.890625
3
[]
no_license
#[macro_use] extern crate clap; extern crate colored; extern crate dialoguer; use clap::{Arg, App}; pub mod lexer; pub mod parser; pub mod repl; pub mod errors; arg_enum!{ enum Mode{ Repl, Make } } fn main(){ //Convert mode options to lowercase let values = Mode::variants().iter()....
true
71dbbbce344a170be76e2afae321dcb7c61a52bb
Rust
JohnDoneth/coffee
/examples/image.rs
UTF-8
1,806
2.90625
3
[ "MIT" ]
permissive
use coffee::graphics::{ self, Color, Frame, HorizontalAlignment, VerticalAlignment, Window, WindowSettings, }; use coffee::load::Task; use coffee::ui::{ Align, Column, Element, Image, Justify, Renderer, Text, UserInterface, }; use coffee::{Game, Result, Timer}; pub fn main() -> Result<()> { <ImageScree...
true
f29f3630b6aaf9ce039a7385e68fa31892a907d5
Rust
stormtracks/rust-examples
/nom/examples/t01.rs
UTF-8
426
3.328125
3
[ "MIT" ]
permissive
//https://iximiuz.com/en/posts/rust-writing-parsers-with-nom/ use nom::{bytes::complete::tag, IResult}; fn foo(s: &str) -> IResult<&str, &str> { tag("foo")(s) } fn main() { // this returns an error // let result = foo("rick foo bar"); let result = foo("foo bar"); println!("{:?}", result); } /* fn...
true
4b9e0e881fb46efce477055995b4a238b41fc218
Rust
senrust/algorithm
/chapter_10/priority_queue/src/main.rs
UTF-8
1,423
3.625
4
[]
no_license
fn maxheapfy(index: usize, heap: &mut Vec<i32>){ let mut largest_index = index; if index*2 <= heap.len() -1{ if heap[index] < heap[index*2] { largest_index = index*2; } } if index*2+1 <= heap.len() -1{ if heap[largest_index] < heap[index*2+1] { largest_...
true
686c5c62ad3aa73116e21b6edc16632e5e1ce25d
Rust
aeolus3000/rust_stack
/src/utils/stack.rs
UTF-8
3,887
3.890625
4
[]
no_license
use crate::utils::pushpop::PushPop; const SIZE: usize = 4; pub struct Stack { buffer: Vec<i32>, pointer: usize } impl Stack { pub fn new() -> Stack { let buffer: Vec<i32> = Vec::new(); let pointer: usize = 0; let stack = Stack { buffer, pointer, };...
true
62a6546d75af965ec9d83d80ebf62c4a5f1bdad3
Rust
LukasKalbertodt/libtest-mimic
/src/lib.rs
UTF-8
17,264
3.421875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Write your own tests and benchmarks that look and behave like built-in tests! //! //! This is a simple and small test harness that mimics the original `libtest` //! (used by `cargo test`/`rustc --test`). That means: all output looks pretty //! much like `cargo test` and most CLI arguments are understood and used. W...
true
e537653923751535087321a3cdf536c8b7a265cc
Rust
doytsujin/winrt-rs
/crates/tests/metadata/tests/writer.rs
UTF-8
2,630
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
#[test] fn writer() { let temp_file = std::env::temp_dir().join("test_metadata.winmd"); { use metadata::writer::*; let mut tables = Tables::new("test.winmd"); let mut def = TypeDef::new(TypeName::new("TestWindows.Foundation", "IStringable")); def.flags.set_public(); def...
true
6f66aca6ccd6e007e925ff506f4a1930a7f1b294
Rust
luben/repro-hyper
/src/bin/broker.rs
UTF-8
5,391
2.796875
3
[]
no_license
use broker::inspect_drop; use futures::{future, sync::oneshot, Future}; use std::{ cell::RefCell, collections::hash_map::HashMap, collections::VecDeque, error::Error, rc::Rc, time::Duration, }; // the HTTP 1/2 stack use hyper::{ header::HeaderValue, service::service_fn, Body, Method, Request, Response, Serv...
true
57b961a803e4aba5cd9b49302feb85977d4b41df
Rust
iphipps/rust-and-embedded-study-notes
/embedded_programming/rust_embedded/09_chapter/src/main.rs
UTF-8
1,287
2.6875
3
[ "Apache-2.0" ]
permissive
#![no_main] #![no_std] use aux9::{entry, tim6}; #[inline(never)] fn delay(tim6: &tim6::RegisterBlock, ms: u16) { // Set the timer to go off in `ms` ticks // 1 tick = 1 ms tim6.arr.write(|w| w.arr().bits(ms)); // CEN: Enable the counter tim6.cr1.modify(|_, w| w.cen().set_bit()); // Wait until...
true
3ee8f5b9caa7a7e624d4c705a9227a7eae8b1baf
Rust
PaddlePaddle/VisualDL
/frontend/packages/wasm/src/high_dimensional.rs
UTF-8
2,430
2.671875
3
[ "Apache-2.0" ]
permissive
use rulinalg::matrix::{BaseMatrix, Matrix}; const THRESHOLD_DIM_NORMALIZE: usize = 50; #[derive(Serialize, Deserialize)] pub struct PCAResult { pub vectors: Vec<Vec<f64>>, pub variance: Vec<f64>, } impl PCAResult { pub fn new(vectors: Vec<Vec<f64>>, variance: Vec<f64>) -> Self { PCAResult { ...
true
8441dc782ba11bb873d6ab5ff6a41539d1f4546e
Rust
ejmahler/strength_reduce
/tests/test_reduced_unsigned.rs
UTF-8
4,562
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
#[macro_use] extern crate proptest; extern crate strength_reduce; use proptest::test_runner::Config; use strength_reduce::{StrengthReducedU8, StrengthReducedU16, StrengthReducedU32, StrengthReducedU64, StrengthReducedUsize, StrengthReducedU128}; macro_rules! reduction_proptest { ($test_name:ident, $struct_name:i...
true
f2a558dcbfc3bd4410055dfb6a7cfa997a203cd1
Rust
visd0m/yaged
/src/types/mod.rs
UTF-8
5,799
2.84375
3
[ "MIT" ]
permissive
use std::collections::HashMap; pub type ColorMap = HashMap<usize, Rgb>; #[derive(Debug)] pub struct Gif { signature: String, screen_descriptor: ScreenDescriptor, global_color_map: Option<ColorMap>, frames: Vec<Frame>, } impl Gif { pub fn signature(&self) -> &str { &self.signature } ...
true
64e852030b379aa26837db023876ef0ad80b1ffc
Rust
jaffa4/siko-1
/crates/siko_ir/src/types.rs
UTF-8
16,955
2.765625
3
[ "MIT" ]
permissive
use crate::class::ClassId; use crate::data::TypeDefId; use crate::program::Program; use crate::type_var_generator::TypeVarGenerator; use crate::unifier::Unifier; use siko_util::format_list; use siko_util::Collector; use siko_util::Counter; use std::collections::BTreeMap; use std::fmt; pub struct ResolverContext { ...
true
bdb2192cf0cd690dd4f19483faa6df6e29926dd3
Rust
calum/rust-unic
/gen/src/generate/ucd/age.rs
UTF-8
3,085
2.703125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::char; use std::collections::BTreeMap; use std::fmt::Display; use std::fs::File; use std::io::{self, Read, Write}; use std::path::Path; use std::str::FromStr; use super::{UnicodeData, UnicodeVersion}; use generate::PREAMBLE; use generate::char_property::ToRangeBSearchMap; use regex::Regex; #[derive(Clone, D...
true
b94d83fda07a8042671bd9f5ffa18859128a33e8
Rust
vvvm23/sss
/src/md.rs
UTF-8
14,463
3.609375
4
[]
no_license
use std::fs::File; use std::io::prelude::*; /// This file handles the conversion from md to a vector of enums that describes /// the various components of a markdown file. This will not be a comprehensive /// representation of a markdown file, but will be sufficient for my use case. /// /// In particular, I will begin ...
true
5ec38d4aebececc0dd6a035924bb2accf7194663
Rust
colelawrence/cargo-watt
/macro-test/src/lib.rs
UTF-8
745
2.59375
3
[ "MIT" ]
permissive
use proc_macro::TokenStream; extern crate proc_macro; #[proc_macro] pub fn my_macro(_input: TokenStream) -> proc_macro::TokenStream { let stream = quote::quote! { println!("{}", 42); }; stream.into() } #[proc_macro] pub fn my_macro1(_input: TokenStream) -> proc_macro::TokenStream { let strea...
true
ab5f9283ceacb81a511bdcb38c5e531aab206182
Rust
rome/tools
/crates/rome_js_analyze/src/analyzers/suspicious/no_sparse_array.rs
UTF-8
3,560
2.515625
3
[ "MIT" ]
permissive
use rome_analyze::{context::RuleContext, declare_rule, ActionCategory, Ast, Rule, RuleDiagnostic}; use rome_console::markup; use rome_diagnostics::Applicability; use rome_js_factory::make; use rome_js_syntax::{AnyJsArrayElement, AnyJsExpression, JsArrayExpression, TriviaPieceKind}; use rome_rowan::{AstNode, AstNodeExt,...
true
02d0c4bcc7d98b0af190fc39909f24ea0842f724
Rust
tomhoule/prisma-engine
/libs/datamodel/core/src/common/functions/traits.rs
UTF-8
945
3
3
[ "Apache-2.0" ]
permissive
use crate::ast; use crate::common::value::{MaybeExpression, ValueValidator}; use crate::error::DatamodelError; /// Trait for functions which can be accessed from the datamodel. pub trait Functional { /// Gets the name of the function. fn name(&self) -> &str; /// Applies the function to the given arguments...
true
013c31a5286bce22329164ff926df17300a0013f
Rust
cnruby/learn-rust-by-crates
/hello-borrowing/bin-hello/examples/expand/move_vec.rs
UTF-8
1,082
3.390625
3
[]
no_license
#![allow(unused_variables)] #[cfg(feature = "ok")] fn main() { let v: Vec<u8> = vec![1, 2, 3]; println!("v is {:p}", &v); // clone // *cloned* the variable v, rendering v usable. let z = v.clone(); println!("z is {:p}", &z); println!("v is {:p}", &v); // move / copy // *moved* the...
true
3bd56dafc9be0df39907bc3103619a9bf02669c0
Rust
ErikssonM/weekend-tracer
/src/color.rs
UTF-8
1,413
3.09375
3
[]
no_license
use std::iter::Sum; use std::ops::{Add, Mul}; use rand::random; use crate::geometry::{rand_in, v3, V3}; #[derive(Clone, Copy, Debug)] pub struct Color(pub V3); impl Color { pub fn black() -> Self { Color(v3(0.0, 0.0, 0.0)) } pub fn ppm(&self) -> String { // sqrt for gamma correction ...
true
1a1aad8236a6511ae9a4aa0ad3d8154226152faa
Rust
sam-wright/Advent-of-Code
/2018/day1/src/main.rs
UTF-8
1,441
3.3125
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{self, Read}; fn main() -> io::Result<()> { let mut file = File::open("input.txt")?; //let mut file = File::open("test_input.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; contents = contents.replace("+"...
true
c4d06054b20b6fe48e66ff087ce701f78c3a8421
Rust
wadackel/rs-td4
/td4/src/opcode.rs
UTF-8
499
3.265625
3
[ "MIT" ]
permissive
use num_derive::FromPrimitive; // Operation Code #[derive(Debug, Copy, Clone, FromPrimitive, ToPrimitive)] pub enum Opcode { AddA = 0b0000, // ADD A, Im AddB = 0b0101, // ADD B, Im MovA = 0b0011, // MOV A, Im MovB = 0b0111, // MOV B, Im MovAB = 0b0001, // MOV A, B MovBA = 0b0100, // MOV B, ...
true
0b00ae044d41fc52a922217e153c7865bd7282dd
Rust
yamash723/nes-hello-world-rust
/src/nes/cassette/header.rs
UTF-8
2,073
3.40625
3
[]
no_license
use super::CassetteInitializeError; #[derive(Debug, PartialEq)] pub struct INesHeader { /// ASCII letters 'NES' followed by 0x1A(EOF) pub magic_numbers: [u8; 4], /// Number of pages for The program rom pub prg_size: u8, /// Number of pages for The character rom pub chr_size: u8, } impl INesHea...
true
44bf53f13e2a7bfaac5108e5a4e05de11cdec05f
Rust
accierro/leetcode-solutions
/easy/matrix/toeplitz_matrix/src/main.rs
UTF-8
1,995
3.921875
4
[]
no_license
// A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. // Now given an M x N matrix, return True if and only if the matrix is Toeplitz. // Example 1: // Input: // matrix = [ // [1,2,3,4], // [5,1,2,3], // [9,5,1,2] // ] // Output: True // Explanation: // In the above grid...
true
441c35256e92801dcde4365c66ff1f4750a9d7eb
Rust
AlisCode/bevy
/crates/bevy_core/src/time/time.rs
UTF-8
1,295
3
3
[ "MIT" ]
permissive
use bevy_ecs::ResMut; use bevy_utils::{Duration, Instant}; /// Tracks elapsed time since the last update and since the App has started #[derive(Debug)] pub struct Time { pub delta: Duration, pub instant: Option<Instant>, pub delta_seconds_f64: f64, pub delta_seconds: f32, pub seconds_since_startup:...
true
d3db477882b00d08e38c76c90726cccca2840610
Rust
wgledbetter/learn-rust
/src/vars.rs
UTF-8
291
3.171875
3
[]
no_license
pub fn run() { // Default let v1 = "Fake"; println!("v1 = {}", v1); // Mutable let mut v2 = 0; v2 = 5; println!("v2 = {}", v2); // Const const V3: i128 = 345; println!("V3 = {}", V3); // Multiple Variables let (t1, t2) = ("First", 45.6); }
true
18acc426faa2cd1188119b2e8aa779f870fad676
Rust
Daniel-B-Smith/NPR-Weekend-Puzzle
/oct_21_2018_pat_rondon/src/main.rs
UTF-8
2,440
2.96875
3
[ "MIT" ]
permissive
/* This code finds a solution to the NPR puzzle presented on Oct 21, 2018. A (paraphrased) statement of the problem: Given the letters in the word 'beermouth', contruct a three by three matrix of words where all the verticals, horizontals, and diagonals form three letter words. This solution is a (nearl...
true
398ebfb14fd273c1744ef9f3ce8997a21858258b
Rust
Ryman/advent-of-code
/2017/src/bin/two.rs
UTF-8
3,571
4.09375
4
[]
no_license
/* --- Day 2: Corruption Checksum --- As you walk through the door, a glowing humanoid shape yells in your direction. "You there! Your state appears to be idle. Come help us repair the corruption in this spreadsheet - if we take another millisecond, we'll have to display an hourglass cursor!" The spreadsheet consists...
true
fcf624a825eb4c3c1dd18f0f9cdbba1210db71dd
Rust
MissionKontrol/css_walker
/src/main.rs
UTF-8
1,797
3.046875
3
[]
no_license
use std::fs; use scraper::{Html, Selector}; use selectors::attr::CaseSensitivity; use clap::{App, Arg}; #[derive(Default)] struct RollResult { player_name: String, date: String, // die: String, // result: u8, } fn main() { // ARGs let matches = App::new("rust_test") .version("0...
true
c27d0fdc60a98234aa6808f4f268c052880de89e
Rust
drichardson/examples
/rust/rustbook/ch8/vectors/src/main.rs
UTF-8
1,185
4.21875
4
[ "Unlicense" ]
permissive
fn main() { let v: Vec<i32> = Vec::new(); println!("v={:?}", v); // using the vec! macro. Type inferred. let v = vec![1, 2, 3]; println!("v={:?}", v); let mut v = Vec::new(); v.push(5); v.push(6); v.push(7); v.push(8); println!("v={:?}", v); // Dropping a vector drops ...
true
0d32435ddde3a0155929486607f1d4122c7cd502
Rust
MarkZuber/rpiled
/rledsvr/src/tasks/displaytext.rs
UTF-8
1,133
2.734375
3
[ "MIT" ]
permissive
use crate::taskmgr::TaskError; use core::jobs::{Cancellable, LoopState}; use core::TextBlock; use rpiledbind::MatrixFont; use rpiledbind::MatrixHolder; pub struct DisplayTextTask { matrix: MatrixHolder, text_blocks: Vec<TextBlock>, } impl DisplayTextTask { pub fn new(matrix: &MatrixHolder, text_blocks: Ve...
true
2fafba7fcfebc214bc03bf97a52909a0dc6dd3cc
Rust
196Ikuchil/nes_emulator
/src/nes/rom/mod.rs
UTF-8
302
2.921875
3
[ "MIT" ]
permissive
use super::types::{Data, Addr}; #[derive(Debug)] pub struct Rom { vec: Vec<Data>, } impl Rom { pub fn new(buf: Vec<Data>) -> Rom { Rom { vec: buf.clone() } } pub fn read(&self, addr: u32) -> Data { self.vec[addr as usize] } pub fn size(&self) -> usize { self.vec.len() } }
true
d7b18859a2a4a42804e8002b025a83f980672e71
Rust
sd-EvandroLippert/data_types_01
/src/main.rs
UTF-8
2,900
3.71875
4
[]
no_license
#[allow(dead_code)] #[allow(unused_variables)] mod stack_and_heap; use std::mem; fn main() { fundamental_data_types(); operators(); scope_and_shadowing(); stack_and_heap::stack_and_heap(); } fn fundamental_data_types(){ // Data types // Integers // u = unsigned só maiores ou igua...
true
2d9753626014630851f8ba324fa4b92cf6df0869
Rust
oabrivard/efp
/rust/retirement_calc/src/main.rs
UTF-8
978
3.59375
4
[]
no_license
use std::io::stdin; use chrono::{Utc, Datelike}; fn read_positive_int() -> i32 { loop { let mut buffer = String::new(); stdin().read_line(&mut buffer).expect("error reading data"); if let Ok(result) = buffer.trim().parse::<i32>() { if result >= 0 {return result;} } ...
true
b724c00f2ddb2ced77cd6d140b35db59dc98a789
Rust
douban/redarrow-rs
/src/webclient.rs
UTF-8
4,140
2.765625
3
[ "BSD-3-Clause" ]
permissive
use std::sync::mpsc; use std::time::Duration; use anyhow::Result; use crate::{CommandParams, CommandResult}; const VERSION: &'static str = env!("CARGO_PKG_VERSION"); #[derive(Debug)] pub struct Client { host: String, port: u32, command: String, arguments: Vec<String>, user_agent: String, con...
true
83501348a209c4a0bc4d870b114e65d2e82d81ab
Rust
anderssonjohn/AdventOfCode
/rust_2015/src/day03.rs
UTF-8
2,190
3.515625
4
[]
no_license
use crate::utils::read_file; use std::collections::HashMap; enum Direction { North, West, South, East } #[derive(Clone, Copy, Eq, Hash, PartialEq)] struct Position {x: i32, y: i32} impl Position { pub fn new() -> Position { Position {x: 0, y: 0} } } pub fn main () { println!("Day...
true
bfba7514f941a612103217010dc86012cbefc0b2
Rust
pipi32167/LeetCode
/rust/src/problem_0640.rs
UTF-8
2,589
3.46875
3
[]
no_license
use std::i32; use std::iter::FromIterator; #[derive(Debug)] struct Solution {} impl Solution { pub fn solve_equation(equation: String) -> String { let parse = || -> Vec<String> { let mut ret = vec![]; let mut chars = vec![]; let mut is_met_eq = false; for c in equation.chars() { ...
true
75799503cfc6024ffdd69ddcd51d7478ea814c5c
Rust
nushell/nushell
/crates/nu-cmd-lang/src/core_commands/while_.rs
UTF-8
3,758
2.859375
3
[ "MIT" ]
permissive
use nu_engine::{eval_block, eval_expression, CallExt}; use nu_protocol::ast::Call; use nu_protocol::engine::{Block, Command, EngineState, Stack}; use nu_protocol::{ Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Type, Value, }; #[derive(Clone)] pub struct While; impl Command for While { ...
true
614e52d3603f47d6a5e1a2e2dc12e098aeb59326
Rust
rowhit/scirust
/sralgebra/src/commutative_ring.rs
UTF-8
3,934
3.421875
3
[ "Apache-2.0" ]
permissive
#![doc="Defines the commutative ring algebraic structure. A commutative ring is a ring where the multiplication operation is commutative. A commutative ring is a set R equipped with binary operations + and * satisfying the following nine axioms: R is an abelian group under addition, meaning: * (a + b) + c = a + (b...
true
dfc0d32a3adaf825eac3524c6919e2bd17d84fc8
Rust
Niedzwiedzw/rust-drivers-playground
/src/main.rs
UTF-8
2,353
2.8125
3
[]
no_license
mod command_ids; use rppal::{ gpio::{ Gpio, OutputPin, }, spi::{ Bus, SlaveSelect, Spi, Mode, }, }; use std::thread; use std::time::Duration; struct Ssd1306Display { spi_channel: Spi, dc_pin: OutputPin, } impl Ssd1306Display { pub fn new() -...
true
52810575372941afa08e01a18777ebf370ce3a77
Rust
maxim-komar/learning-rust
/rust-by-example/trait/dyn/dyn.rs
UTF-8
1,589
4.09375
4
[]
no_license
// The Rust compiler needs to know how much space every function's return // type requires. This means all your functions have to return a concrete // type. Unlike other languages, if you have a trait like `Animal`, you // can't write a function that returns `Animal`, because its different // implementations will need ...
true
f5970deb28f2d86ca9e595d2a08069b244cecf8b
Rust
FarhanAliRaza/Learning-Rust
/src/print.rs
UTF-8
619
3.640625
4
[]
no_license
pub fn run(){ println!("Hello "); //can not print number directly println!("{}", 1); //basic frmating println!("My name is {} and i am from {}", "farhan", "Pakistan"); //positional argument println!("My name is {0} and {0} is from {1}", "faryhan", "Pakistan"); //named arguments prin...
true
153571032b909ece8d83ffb2977dacbf1ef7549f
Rust
CosmWasm/terra-contracts
/contracts/maker/tests/integration.rs
UTF-8
3,859
2.78125
3
[ "Apache-2.0" ]
permissive
//! This integration test tries to run and call the generated wasm. //! It depends on a Wasm build being available, which you can create with `cargo wasm`. //! Then running `cargo integration-test` will validate we can properly call into that generated Wasm. //! //! You can easily convert unit tests to integration test...
true
47a3f9ef3a7942477ac3a31a21a2215c1d8ec721
Rust
jihoonson/iron-arrow
/src/common/mod.rs
UTF-8
14,757
2.703125
3
[ "Apache-2.0" ]
permissive
pub mod status; pub mod ty; pub mod bit_util; pub mod field; use std::collections::HashMap; #[derive(Debug, Eq, PartialEq)] pub struct KeyValueMetadata { keys: Vec<String>, values: Vec<String> } impl KeyValueMetadata { pub fn new() -> KeyValueMetadata { KeyValueMetadata { keys: Vec::new(), valu...
true
d5ebb981b687fc35173552e9dec279f257fa6e55
Rust
tillrohrmann/rust-challenges
/aoc_2020_5/src/lib.rs
UTF-8
1,397
3.703125
4
[ "Apache-2.0" ]
permissive
use std::str::FromStr; #[derive(Eq, PartialEq, Debug)] pub struct BoardingPass { row: usize, column: usize, } impl BoardingPass { pub fn new(row: usize, column: usize) -> BoardingPass { BoardingPass { row, column, } } fn parse_number(input: &str) -> usize {...
true