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
62ffaf58b9517b7900feaafd5217b7845007803f
Rust
KatsuyaKikuchi/programming_contest_rust
/src/AizuOnlineJudge/ITP1/4_C.rs
UTF-8
425
3.125
3
[]
no_license
use proconio::input; fn main() { loop { input! { a:i32, op:char, b:i32 } let ans = match op { '+' => Some(a + b), '-' => Some(a - b), '/' => Some(a / b), '*' => Some(a * b), _ => None }; if...
true
a6c72b7ce4f0430540f26250ba2ae4a7635ccbf4
Rust
pjfordham/atoms_rust
/src/atoms.rs
UTF-8
10,114
3.09375
3
[]
no_license
use std::cmp; pub struct PseudoRandom { x: u64, w: u64, s: u64, } impl PseudoRandom { pub fn new() -> PseudoRandom { PseudoRandom{ x : 0, w : 0, s : 0xb5ad4eceda1ce2a9 } } fn msws(&mut self) -> u32 { self.x = self.x.wrapping_mul(self.x); self.w = self.w.wrapping_add(se...
true
23291842d7dddccef0fa5421a9783ed1eed6b343
Rust
endeav0r/bad64
/src/shift.rs
UTF-8
3,657
3.015625
3
[ "Apache-2.0" ]
permissive
use core::convert::TryFrom; use core::fmt; use bad64_sys::*; /// A shift applied to a register or immediate #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)] #[allow(non_camel_case_types)] pub enum Shift { LSL(u32), LSR(u32), ASR(u32), ROR(u32), UXTW(u32), SXTW(u32), SXTX(u32), UXTX(u...
true
ddb0d4f6fecce674bfca65bbb69476d90fd7fbf8
Rust
cmyr/rust-buffer-bench
/benches/buffer.rs
UTF-8
3,117
2.75
3
[]
no_license
#[macro_use] extern crate criterion; extern crate buffer_bench; extern crate xi_rope; extern crate xi_rope_master; extern crate xi_rope_rc; extern crate ropey; use std::iter; use criterion::{Criterion, Fun}; use xi_rope::rope::Rope as Ropev2; use xi_rope_master::Rope as Ropev3; use xi_rope_rc::Rope as RopeRc; use ...
true
cf70961257a2fd6cfea8551781283a8e5a72e00b
Rust
avcdsld/substrate-node-nft
/pallets/attendance/src/lib.rs
UTF-8
2,308
2.78125
3
[ "Unlicense" ]
permissive
#![cfg_attr(not(feature = "std"), no_std)] /// Edit this file to define custom logic or remove it if it is not needed. /// Learn more about FRAME and the core library of Substrate FRAME pallets: /// https://substrate.dev/docs/en/knowledgebase/runtime/frame use frame_support::{decl_module, decl_storage, decl_event, de...
true
e3bb4b6dbfe0eaf511ca5cbe62c743259f3f6572
Rust
bcmyers/aoc2019
/src/day08.rs
UTF-8
1,690
3
3
[ "MIT", "Apache-2.0" ]
permissive
use std::io; use crate::error::Error; const ROWS: usize = 6; const COLS: usize = 25; pub fn run<R>(mut reader: R) -> Result<(String, String), Error> where R: io::BufRead, { // Parse input let mut buf = Vec::new(); reader.read_to_end(&mut buf)?; buf.pop(); buf.iter_mut().for_each(|b| *b -= 48)...
true
80602b2846b31df8514b54b5c9b7fbeb794b3a99
Rust
bs-community/blessing-skin-shell
/src/programs/export.rs
UTF-8
4,264
3.3125
3
[ "MIT" ]
permissive
use crate::shell::{executable::Builtin, Argument, Arguments, Executables, Vars}; use crate::terminal::Terminal; use ansi_term::Color; pub struct Export; impl Export { fn print_warning(&self, terminal: &Terminal, message: String) { terminal.write(&format!("{}\r\n", Color::Yellow.paint(message))); } } ...
true
2422802e4bedcdfc13089a70d2a9963bc3c7b08e
Rust
sulabhkothari/SkRustNetworking
/src/async_await_basics.rs
UTF-8
12,036
3.453125
3
[]
no_license
use futures::executor::block_on; use std::thread::Thread; use std::sync::mpsc; use futures::join; use { std::{ pin::Pin, task::Waker, thread, }, }; use { futures::{ future::{FutureExt, BoxFuture}, task::{ArcWake, waker_ref}, }, std::{ future::Future, ...
true
af9a8ab99895f8c08bc98f50129cddaa0e8facea
Rust
AndrewScull/rust
/src/test/run-pass/issue-22536-copy-mustnt-zero.rs
UTF-8
970
2.8125
3
[ "MIT", "Apache-2.0", "Unlicense", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "bzip2-1.0.6", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
true
dad378954bbba780267ff73fba02e2a07c9c92cc
Rust
tarikeshaq/exercism-rust
/atbash-cipher/src/lib.rs
UTF-8
1,149
3.4375
3
[]
no_license
fn cipher_encode(c: char) -> char { let pos = c as u8 - b'a'; let res_pos = 25 - pos; (b'a' + res_pos) as char } /// "Encipher" with the Atbash cipher. pub fn encode(plain: &str) -> String { plain .chars() .filter(|c| c.is_alphabetic() || c.is_numeric()) .map(|c| { i...
true
0cbe6634f6faf2e72d1f87b68b77293fdfdd2526
Rust
jujinesy/KiwiTalk_kiwitalk-tauri
/src-tauri/src/config.rs
UTF-8
722
2.609375
3
[]
no_license
use serde::Deserialize; #[derive(Deserialize)] #[serde(default)] pub struct Config { pub agent: String, pub version: String, pub os_version: String, pub language: String, pub xvc_seeds: [String; 2], } impl Default for Config { fn default() -> Self { Self { agent: "win32".into(), version: "...
true
711b7250ba9e7b4c55849edae744f3f839eaddd2
Rust
adamnemecek/Peroxide
/src/operation/extra_ops.rs
UTF-8
419
3.234375
3
[]
no_license
pub trait PowOps { type Output; fn pow(&self, n: usize) -> Self::Output; fn powf(&self, f: f64) -> Self::Output; fn sqrt(&self) -> Self::Output; } pub trait TrigOps { type Output; fn sin(&self) -> Self::Output; fn cos(&self) -> Self::Output; fn tan(&self) -> Self::Output; } pub trait E...
true
1972859c2531eef7fe7e4345694cad81bf456026
Rust
while1malloc0/advent-of-code
/2021/rust/src/bin/day5.rs
UTF-8
7,100
3.421875
3
[]
no_license
use std::collections::HashMap; fn main() { let p1_in: Lines = include_str!("../../inputs/5.txt").into(); let p1_answer = p1(p1_in); println!("Part 1: {}", p1_answer); let p2_in: Lines = include_str!("../../inputs/5.txt").into(); let p2_answer = p2(p2_in); println!("Part 2: {}", p2_answer); } ...
true
d96b293d9ad05e18c511a25d09a22f81a7600bba
Rust
Erikovsky/curve-tracer
/src/dut/aoi.rs
UTF-8
1,195
3.296875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[derive(Copy, Clone, Debug)] pub struct AreaOfInterest { pub min_v: f64, pub max_v: f64, pub min_i: f64, pub max_i: f64, } impl AreaOfInterest { pub fn new_pos_i_pos_v(i: f64, v: f64) -> Self { Self { min_v: 0.0, max_v: v, min_i: 0.0, max_i: ...
true
6da985d4eb279fd9aa4cf9690da58303f1aaa391
Rust
DutchGhost/Advent-Of-Code-2018
/day13/src/turnstate.rs
UTF-8
553
3.671875
4
[]
no_license
use std::mem; /// Represents the state of what direction should be moved in upon an intersection point. #[derive(Debug)] pub enum TurnState { Left, Straight, Right, } impl TurnState { pub fn new() -> Self { TurnState::Left } pub fn switch(&mut self) { mem::replace( ...
true
a8c44e038e1f5bf5e9836f94bf841b78d03636f5
Rust
modyharshit23/hhvm
/hphp/hack/src/ocamlrep/impls.rs
UTF-8
18,524
2.609375
3
[ "MIT", "Zend-2.0", "PHP-3.01" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // This source code is licensed under the MIT license found in the // LICENSE file in the "hack" directory of this source tree. use std::collections::{btree_map, btree_set, BTreeMap, BTreeSet}; use std::convert::TryInto; use std::path::PathBuf; use std::rc::Rc; u...
true
600e4f8ff35305eceddc0b8090bf167568ce5189
Rust
oSoc17/lopeningent_backend
/server/lib/graph/src/graph/heapdata.rs
UTF-8
2,045
3.96875
4
[ "MIT" ]
permissive
//! Structure used for putting data on a heap, for Dijkstra purposes. //! It also inverts the comparison operator, which is useful since the //! Binary Heap data structure in Rust yields all data in high-to-low order. use std::ops::Add; use std::cmp::Ordering; /// HeapData struct /// /// # Examples /// ``` /// use gr...
true
2e100d41caa00354b19e331c229dda7341f23e87
Rust
felixge/advent-2020
/day10-1/src/main.rs
UTF-8
916
3.640625
4
[]
no_license
use anyhow::Result; use std::fs; fn main() { let input = fs::read_to_string("./input.txt").unwrap(); println!("{}", answer(&input).unwrap()); } fn answer(input: &str) -> Result<i64> { let mut nums = to_numbers(input)?; nums.sort(); let mut d1 = 0; let mut d3 = 1; let mut prev = 0; for...
true
28076728299a48f0ad9f2082320b7e9f5dda31be
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/base16ct-0.1.1/src/display.rs
UTF-8
866
3.15625
3
[ "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
use core::fmt; /// `core::fmt` presenter for binary data encoded as hexadecimal (Base16). #[derive(Copy, Clone, Debug, Eq, PartialEq)] pub struct HexDisplay<'a>(pub &'a [u8]); impl fmt::Display for HexDisplay<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:X}", self) } } ...
true
cf6a20188ffb9910c0877bcc0cb68aa3ecbdc575
Rust
exercism/rust
/exercises/practice/luhn-trait/.meta/example.rs
UTF-8
1,182
3.515625
4
[ "MIT" ]
permissive
pub trait Luhn { fn valid_luhn(&self) -> bool; } impl Luhn for String { fn valid_luhn(&self) -> bool { if self.chars().any(|c| c.is_alphabetic()) || self.chars().count() == 1 { return false; } self.chars() .filter_map(|c| c.to_digit(10)) .rev() ...
true
48f1faf579eb71709d839f5faf68d8ecae2575b9
Rust
kecors/aoc20
/day-13/src/main.rs
UTF-8
1,427
2.953125
3
[ "MIT" ]
permissive
use std::io::{stdin, Read}; fn main() { let mut input = String::new(); stdin().read_to_string(&mut input).unwrap(); let lines: Vec<&str> = input.lines().collect(); let depart_time = lines[0].parse::<u64>().unwrap(); // Part 1 let bus_ids: Vec<u64> = lines[1] .split(',') .filt...
true
af614f8aef4ef939b112cb66e36b12f40f6264a3
Rust
will-zegers/rust-raytracer
/src/geometry/ray.rs
UTF-8
3,765
3.171875
3
[]
no_license
use super::{Point3, Vec3}; use crate::color::Color; use crate::hittable::Hittable; #[derive(Debug, PartialEq)] pub struct Ray { pub origin: Point3, pub direction: Vec3, } impl Ray { pub fn new(origin: Point3, direction: Vec3) -> Self { Self { origin, direction } } pub fn at(&self, t: f64...
true
00d195522ddcb99b25c3525fc2c54b0799ef7150
Rust
willem66745/zoneinfo-rust
/examples/zdump.rs
UTF-8
1,580
2.625
3
[ "MIT" ]
permissive
// This example tries to emulate zdump(8) verbose output extern crate zoneinfo; extern crate time; use zoneinfo::ZoneInfo; use time::{at_utc, Timespec}; use std::env::args; fn main() { let info = match args().nth(1) { Some(region) => ZoneInfo::by_tz(&region).unwrap(), None => ZoneInfo::get_local_...
true
99f084ec4a5ca8e2ae006396baa088fa05b31cea
Rust
OneSignal/rust-service
/src/logging.rs
UTF-8
4,416
2.75
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 OneSignal, Inc. // // 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
b9873820c63e770601650eecef92799d4c506d31
Rust
AlexanderCurtin/terrible_rust_shell
/src/main.rs
UTF-8
7,419
3.078125
3
[]
no_license
use std::env::var; use std::fs::File; use std::io; use std::io::prelude::*; use std::process::*; extern crate regex; #[macro_use] extern crate pest_derive; extern crate pest; use pest::iterators::Pair; use pest::Parser; #[derive(Parser)] #[grammar = "grammar.pest"] struct ShellParser; pub enum ShellCommand { I...
true
5db7cbc2bad68d544ffb4effacedef46aed1ab37
Rust
meyerphi/advent-of-code
/2018/src/day5.rs
UTF-8
1,386
3.359375
3
[]
no_license
mod common; fn react(polymer: &str) -> String { let mut s = String::from(polymer); loop { // add end of polymer character let mut t = String::new(); let mut skip = false; for (c, d) in s .chars() .zip(s.chars().skip(1).chain(vec!['#'].into_iter())) ...
true
f36acb0dd526c92429df2518c8ead81b768e6864
Rust
ShantanuVichare/battlesnake_rust
/src/lib.rs
UTF-8
1,836
3.046875
3
[]
no_license
mod gamedata; use gamedata::*; use serde::{Serialize, Deserialize}; use std::sync::Mutex; #[derive(Debug, Serialize)] pub struct RootResponse { apiversion: String, author: String, color: String, head: String, tail: String, } impl RootResponse { pub fn new<'a>(apiversion: &'a str, author: &'a s...
true
e69db19003ad31d76ecfc3e78fd28a65b13b07e7
Rust
xzfc/cached-nix-shell
/build.rs
UTF-8
2,351
2.515625
3
[ "MIT", "Unlicense" ]
permissive
use std::env::{var, var_os}; use std::path::Path; use std::process::Command; fn main() { if var_os("CNS_IN_NIX_SHELL").is_none() { // Release build triggered by nix-build. Use paths relative to $out. let out = var("out").unwrap(); println!("cargo:rustc-env=CNS_TRACE_NIX_SO={out}/lib/trace-n...
true
d4a7c6abd690c9f9ee7ba223a8c6ffe3f1e8e850
Rust
acidburn0zzz/ruffle
/core/src/avm1/object.rs
UTF-8
18,289
2.734375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Object trait to expose objects to AVM use crate::avm1::error::Error; use crate::avm1::function::{Executable, FunctionObject}; use crate::avm1::object::shared_object::SharedObject; use crate::avm1::object::super_object::SuperObject; use crate::avm1::object::value_object::ValueObject; use crate::avm1::property::Attr...
true
3f25ecfa642a74fa6debfcc957932b89573b07fc
Rust
tkaden4/crossterm
/src/shared/functions.rs
UTF-8
1,302
2.734375
3
[ "MIT" ]
permissive
//! Some actions need to preformed platform independently since they can not be solved `ANSI escape codes`. use Context; #[cfg(unix)] use kernel::unix_kernel::terminal::terminal_size; #[cfg(windows)] use kernel::windows_kernel::terminal::terminal_size; #[cfg(unix)] use kernel::unix_kernel::terminal::pos; #[cfg(windo...
true
4226a7d0f9e7424f5eb5878dc933f05026fd641c
Rust
sioncheng/programming-rust
/ownership/src/main.rs
UTF-8
1,003
3.96875
4
[]
no_license
fn main() { let a = 1; { let s = "2"; println!("s = {}", s); } //s is not in the scope println!("{} {}", a , s); println!("a = {}", a); let mut s = String::from("hello"); s.push_str(", world!"); println!("s = {}", s); let s1 = String::from("rust"); println!("s1...
true
640c7c4c21478c16ec347263022eeb31c74dfb6a
Rust
mozilla/gecko-dev
/third_party/rust/zerovec/benches/zerovec.rs
UTF-8
5,372
2.53125
3
[ "LicenseRef-scancode-unicode", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). use criterion::{black_box, criterion_group, criterion_main, Criterion}; use rand::SeedableRng; use rand_distr::{Distr...
true
7f0496c01ebf40a6dfedf6c742be65d72b49e4ea
Rust
drupalio/inkdrop
/lib/src/lib.rs
UTF-8
3,157
2.78125
3
[ "MIT" ]
permissive
pub mod color; pub mod point; pub mod tsp; pub mod voronoi; use anyhow::Result; use image::GenericImageView; use rand::Rng; use std::path; use svg::node::element::path::Data; use svg::node::element::Circle; use svg::node::element::Path; use svg::Document; const COLORS: [&str; 4] = ["cyan", "magenta", "yellow", "black...
true
89234c8807f76ed13da61922c924bd9b07595294
Rust
fedyarov/CompilerRUST
/Tests/Cycle_test/Cycle.rs
UTF-8
189
2.953125
3
[]
no_license
fn main() { let mut var1=2; let mut i=0; let mut j=0; for i in 1 .. 5{ var1 = var1 * 2; println!("{}", var1); for j in 0 .. 2{ var1 = var1+1; println!("{}",var1); } } }
true
7f4a0a373dbbea5fbf0a2c2b54293ba2bf8c3d6f
Rust
49nord/utimeseries-rs
/src/err.rs
UTF-8
1,161
2.671875
3
[ "MIT" ]
permissive
use std::io; quick_error! { #[derive(Debug)] pub enum Error { Io(err: io::Error) { from() description("io error") display("I/O error: {}", err) cause(err) } IntervalOutOfRange { description("interval out of range") ...
true
df33d2f4ad410ffb2686f1a9627183ef57347a74
Rust
mic-/snes
/vgm2spc/rust/src/codec/psgcodec.rs
UTF-8
6,872
2.9375
3
[]
no_license
/// /// A VGM compressor focusing mainly on PSG commands (0x50 0xnn). /// Each group of 8 commands is prepended with a flag byte, where each bit specifies /// if the corresponding command is a PSG command or not. The command byte (0x50) is stripped /// and only the argument byte is written to the output. /// /// The co...
true
5961829f6783f5094f975585504b6e71985889a2
Rust
barzamin/plotterart
/src/bin/03-sierpinski-arrowhead.rs
UTF-8
3,896
2.515625
3
[]
no_license
#![allow(unused_imports)] use gnuplot::{Figure, PlotOption}; use hpgl::hp7470a::{DeviceControlInstruction, HandshakeConfig, HandshakeMode}; use hpgl::{Coordinate, HpglCommand, HpglProgram, PlotterWriteable}; use serialport::{self, DataBits, FlowControl, Parity, SerialPortSettings, StopBits}; use std::time::Duration; us...
true
7fa480824b619c05733ad9d72274b3a84a4c360e
Rust
OkaeriPoland/okaeri-sdk-rust
/src/noproxy.rs
UTF-8
2,145
2.59375
3
[ "MIT" ]
permissive
use crate::client::OkaeriClient; use crate::OkaeriSdkError; use serde::Deserialize; use serde_json::json; use std::collections::HashMap; use std::env; use std::time::Duration; use url::Url; type Result<T> = std::result::Result<T, OkaeriSdkError>; #[allow(dead_code)] #[derive(Deserialize)] pub struct NoProxyAddressInf...
true
28aee93dfd2c8e93086f454b239fa89f74a608f5
Rust
robbym/hexdiff
/src/ihex16.rs
UTF-8
1,505
2.984375
3
[]
no_license
use std::io::Read; use ihex::{Reader, Record}; #[derive(Debug, Copy, Clone)] pub struct IHex16Word { pub address: u32, pub value: u32, } pub struct IHex16File(pub Vec<IHex16Word>); impl IHex16File { pub fn from_reader<R: Read>(read: &mut R) -> IHex16File { let mut hex_data = String::new(); ...
true
bee16b254565abf9d5610891cd2bc1a76dc56e0b
Rust
miller-time/wasm-chess
/src/board.rs
UTF-8
769
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::file::BoardFile; use crate::square::{default_squares, Square}; use wasm_bindgen::prelude::*; #[wasm_bindgen] #[derive(Debug)] pub struct Board { squares: Vec<Square>, } #[allow(clippy::new_without_default)] #[wasm_bindgen] impl Board { pub fn new() -> Board { let squares = default_squares()...
true
3b7c5e5f12ceea637041f22fa708b3a5bd6144c6
Rust
denoland/deno_lint
/src/rules/no_throw_literal.rs
UTF-8
2,269
2.703125
3
[ "MIT" ]
permissive
// Copyright 2020-2021 the Deno authors. All rights reserved. MIT license. use super::{Context, LintRule}; use crate::handler::{Handler, Traverse}; use crate::Program; use deno_ast::view::{Expr, ThrowStmt}; use deno_ast::SourceRanged; use derive_more::Display; #[derive(Debug)] pub struct NoThrowLiteral; const CODE: &...
true
a825d35b178587a77731c832303ce3d1a106d761
Rust
jaisanas/techiedelight
/rust/longest_path.rs
UTF-8
1,695
2.75
3
[]
no_license
const N: i32 = 10; const ROW: [i32; 4] = [-1, 0, 1, 0]; const COL: [i32; 4] = [0, 1, 0, -1]; fn main() { let mut mat = vec![ vec![1, 0, 1, 1, 1, 1, 0, 1, 1, 1], vec![1, 0, 1, 0, 1, 1, 1, 0, 1, 1], vec![1, 1, 1, 0, 1, 1, 0, 1, 0, 1], vec![0, 0, 0, 0, 1, 0, 0, 1, 0, 0], vec![1,...
true
86b342bce6f8d3a344b055d520e3bc3e4be991f3
Rust
avr-rust/rust-legacy-fork
/src/librustc_data_structures/sip128.rs
UTF-8
19,263
3.109375
3
[ "LicenseRef-scancode-other-permissive", "MIT", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
//! This is a copy of `core::hash::sip` adapted to providing 128 bit hashes. use std::cmp; use std::hash::Hasher; use std::slice; use std::ptr; use std::mem; #[derive(Debug, Clone)] pub struct SipHasher128 { k0: u64, k1: u64, length: usize, // how many bytes we've processed state: State, // hash State...
true
84945bde150665cb3a551bc9b28f35bbf13a4b3b
Rust
admay/aoc-2019
/src/day1.rs
UTF-8
1,363
3.390625
3
[]
no_license
#[aoc(day1, part1)] pub fn solve_p1(input: &str) -> f64 { input .lines() .map(|x| x.parse::<f64>().unwrap()) .map(|x| (x / 3.0).trunc() - 2.0) .sum() } pub fn calc_fuel(f: f64) -> f64 { let mut total_fuel = 0.0; let mut cur_fuel = f; let mut done = false; while !done...
true
ca2b394ef9d28e89dc154bc473af4265868e45ee
Rust
charliejeynes/arc
/src/ord/set/react_set.rs
UTF-8
685
2.765625
3
[]
no_license
//! Reaction set. use crate::{ chem::Reaction, ord::{ReactKey, Set, SpecKey}, }; /// Alias for the reaction set. pub type ReactSet = Set<ReactKey, Reaction>; impl ReactSet { /// Get a list of all species keys used by the reaction set. #[inline] #[must_use] pub fn spec_keys(&self) -> Vec<SpecK...
true
46a40423b302de6f6eb68f1cc6cf9e4f1df50cd8
Rust
vopi181/MCLexer
/src/defines.rs
UTF-8
218
2.59375
3
[]
no_license
mod defines { #[derive(Debug)] pub enum cells_defines { variable, function, } #[derive(Debug)] pub struct cells_struct { cell_type: cells_defines, data: string } }
true
8a899802c1ef48c25b5e0666d4cd114ac56ac87d
Rust
stickeritis/sticker-encoders
/src/layer/mod.rs
UTF-8
7,659
3.234375
3
[ "BlueOak-1.0.0" ]
permissive
//! CoNLL-X layer encoder. use std::convert::{Infallible, TryFrom}; use conllu::graph::{Node, Sentence}; use conllu::token::{Features, Token}; use serde_derive::{Deserialize, Serialize}; use super::{EncodingProb, SentenceDecoder, SentenceEncoder}; mod error; use self::error::*; /// Tagging layer. #[serde(rename_al...
true
e9113d0585a3d2812f904d5290e4f1254d8572d0
Rust
isgasho/highnoon
/src/ws.rs
UTF-8
3,627
2.5625
3
[ "MIT" ]
permissive
use crate::endpoint::Endpoint; use crate::state::State; use crate::{Request, Response, Result}; use async_trait::async_trait; use futures_util::{SinkExt, TryStreamExt}; use hyper::upgrade::Upgraded; use hyper::StatusCode; use std::future::Future; use std::marker::PhantomData; use std::sync::Arc; use tokio_tungstenite::...
true
c359666a1d9848824dc93f8b6b75d2a7fc51b8e1
Rust
jz4o/codingames
/rust/practice/classic_puzzle/easy/ghost-legs.rs
UTF-8
1,890
3.125
3
[]
no_license
use std::io; macro_rules! parse_input { ($x:expr, $t:ident) => ($x.trim().parse::<$t>().unwrap()) } /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ fn main() { let mut input_line = String::new(); io::stdin().read_line(&mut input_lin...
true
0442217ffc3fcd6ab52023034a2d0e51ea797494
Rust
zeta1999/rustvis
/src/bin/bin.rs
UTF-8
1,308
2.765625
3
[ "Apache-2.0" ]
permissive
extern crate rustvis; extern crate time; use rustvis::{Rgb, barchart, new_with_background}; use rustvis::linechart::*; use time::PreciseTime; use rustvis::barchart::*; fn main() { let start = PreciseTime::now(); let white = Rgb { r: 255, g: 255, b: 255}; let _black = Rgb { r: 0, g: 0, b: 0}; let slate...
true
978c1980dcb2125cabfb929cc7539c949cdcb0c5
Rust
coolreader18/gcmodule
/src/cc.rs
UTF-8
22,374
2.84375
3
[ "MIT" ]
permissive
use crate::collect; use crate::collect::AbstractObjectSpace; use crate::collect::ObjectSpace; use crate::debug; use crate::ref_count::RefCount; use crate::trace::Trace; use crate::trace::Tracer; use std::cell::UnsafeCell; use std::mem; use std::mem::ManuallyDrop; use std::ops::Deref; use std::ops::DerefMut; use std::pa...
true
f950cc6f125e9a3584fae2ff0b4661cbc07dd69e
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0458.poor-pigs/poor-pigs_test.go
UTF-8
714
2.546875
3
[ "MIT" ]
permissive
package problem0458 import ( "fmt" "testing" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { buckets int minutesToDie int minutesToTest int ans int }{ { 1, 1, 1, 0, }, { 1000, 12, 60, 4, }, { 1000, 15, 60, 5, }, // 可以有多个 ...
true
0af82f2d00068bc5e332a4c8fc7e1a8f85585e51
Rust
MichaelRawson/discrimination-tree
/src/lib.rs
UTF-8
6,943
2.96875
3
[]
no_license
#[cfg(test)] mod tests; mod util; use crate::util::SortedMap; fn report_bad_state() -> ! { panic!( "\ bad state detected - this could mean: 1. inserted keys are not proper traversals of well-formed terms, or 2. identical symbols have been used with different arities" ); } pub trait Symbol: Or...
true
c10ae4b8a2fec4224532d8721521b920a15453b0
Rust
reiya-hanai/aoj-book-in-rust
/cgl3_c_polygon_point_containment/src/main.rs
UTF-8
5,952
3.09375
3
[]
no_license
#![allow(unused_macros)] #![allow(dead_code)] use std::cmp::Ordering; use std::ops::{Add, Mul, Sub}; // ---------------------------------------------------------------------------------------------------- // input macro by @tanakh https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 // ---------------------------------...
true
f70b3fca4554199d6ebf0c0f6e3ec6be74e75893
Rust
JonathanLorimer/tendermint-rs
/tendermint/src/error.rs
UTF-8
5,391
2.796875
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
//! Error types use anomaly::{BoxError, Context}; use thiserror::Error; use crate::account; use crate::vote; /// Error type pub type Error = BoxError; /// Kinds of errors #[derive(Clone, Eq, PartialEq, Debug, Error)] pub enum Kind { /// Cryptographic operation failed #[error("cryptographic error")] Cryp...
true
b0b9fbdff91cda9d948c3a3e6cb8d4449370d597
Rust
marco-c/gecko-dev-wordified
/third_party/rust/rust_decimal/src/rand.rs
UTF-8
5,380
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate : : Decimal ; use rand : : { distributions : : { uniform : : { SampleBorrow SampleUniform UniformInt UniformSampler } Distribution Standard } Rng } ; impl Distribution < Decimal > for Standard { fn sample < R > ( & self rng : & mut R ) - > Decimal where R : Rng + ? Sized { Decimal : : from_parts ( rng . next_...
true
f892ae219bcde9668d6b4916e8a85a87f48b31cb
Rust
saschagrunert/craft
/src/resolver/encode.rs
UTF-8
12,286
2.53125
3
[ "MIT" ]
permissive
use std::collections::{HashMap, HashSet, BTreeMap}; use std::fmt; use std::str::FromStr; use regex::Regex; use rustc_serialize::{Encodable, Encoder, Decodable, Decoder}; use package::Package; use package_id::PackageId; use source::SourceId; use util::{CraftResult, Graph, Config, internal, ChainError, CraftError}; use...
true
c48bdfea73c3cc9136f4f4a61a815c6f5e9055ba
Rust
TheHellBox/Sorption-Space-Sim
/src/gui/mod.rs
UTF-8
1,814
2.515625
3
[ "MIT" ]
permissive
pub mod widgets; use glium::index::PrimitiveType::TriangleStrip; use glium::{DrawParameters, VertexBuffer, IndexBuffer, Surface, Frame}; use universe::game::Game; use render::Window; use render::Vertex; pub struct Gui{ pub buttons: Vec<widgets::Button> } impl Gui{ pub fn draw_gui(&self, target: &mut Frame, ...
true
7f7d416c24d381938123941a879d9f9e06b4357a
Rust
coord-e/r53ddns
/src/domain/change_status.rs
UTF-8
444
2.78125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::str::FromStr; use crate::base::{Error, Result}; #[derive(PartialEq, Eq)] pub enum ChangeStatus { Pending, InSync, } impl FromStr for ChangeStatus { type Err = Error; fn from_str(s: &str) -> Result<ChangeStatus> { match s { "PENDING" => Ok(ChangeStatus::Pending), ...
true
dbfd989d2773bf10bb6cc114378298589b7838b0
Rust
scifi6546/n-tree
/src/lib.rs
UTF-8
8,082
3.671875
4
[ "MIT" ]
permissive
pub fn new_tree<Data>() -> L0Node<Data> { L0Node { data: None } } pub struct L0Node<Data> { data: Option<(Data, usize)>, } impl<Data: Clone> L0Node<Data> { pub fn empty() -> Self { Self { data: None } } /// Sets self data pub fn set(&mut self, data: Data, index: usize) { self.dat...
true
25ae46b0795563790dd00002fe6b04eac75e3d8c
Rust
NaokiM03/quick-magic
/src/main.rs
UTF-8
439
2.71875
3
[ "MIT" ]
permissive
use clipboard_win::{set_clipboard_string}; use rust_embed::RustEmbed; #[derive(RustEmbed)] #[folder = "snippet/"] struct Asset; fn main() { let louise = Asset::get("character/Louise.txt").unwrap(); let text = std::str::from_utf8(louise.as_ref()).unwrap(); set_clipboard_string(text.trim_end()).expect("Succ...
true
fa1681910127fa6463926da5d9d105b4fc179ae8
Rust
iredelmeier/resufancy
/src/resume.rs
UTF-8
695
3.125
3
[ "MIT" ]
permissive
#[derive(Debug, Clone)] pub struct Resume { html: String, stylesheet: String, } impl Resume { pub fn new(html: String, stylesheet: String) -> Self { Self { html, stylesheet } } pub fn html(&self) -> &str { &self.html } pub fn stylesheet(&self) -> &str { &self.style...
true
94a0aea37ee60744cfd448e067175a0f55a75822
Rust
U007D/ecpp17cc
/src/error.rs
UTF-8
1,207
3.078125
3
[]
no_license
use std::fmt; use std::ffi::OsString; use std::io::Error as IoError; use std::option::NoneError; #[allow(unused_imports)] use super::*; #[derive(Fail, Debug)] //Papercut: PartialEq is not object safe and cannot be used with io::Error :( pub enum Error { //#[fail(display = "{}", MSG_ERROR)] ArgInvalidUtf8(OsSt...
true
6694df63df5d1a3b7dd15a47bee115ac4f885b7d
Rust
oxidecomputer/cio
/partial-struct/tests/create_new.rs
UTF-8
1,163
3.140625
3
[ "Apache-2.0" ]
permissive
use partial_struct::partial; use serde::{Deserialize, Serialize}; #[test] fn test_create_new() { fn default_to_true() -> bool { true } #[partial(NewStruct1, with(Default), without(Eq))] #[partial(NewStruct2)] #[derive(Debug, PartialEq, Eq, Deserialize, Serialize)] pub(crate) struct Old...
true
5b7edfa9769906b1dc1b0175d67f6a56255bf870
Rust
zyansheep/Grasslandia
/src/main_menu.rs
UTF-8
3,846
2.515625
3
[]
no_license
use bevy::prelude::*; use crate::GameState; pub struct ButtonMaterials { normal: Handle<ColorMaterial>, hovered: Handle<ColorMaterial>, pressed: Handle<ColorMaterial>, } impl FromWorld for ButtonMaterials { fn from_world(world: &mut World) -> Self { let mut materials = world.get_resource_mut::<Assets<ColorMate...
true
a887a539085e7091803db9934585ce67ffbba7fe
Rust
folsen/ethcc-demo
/src/sample.rs
UTF-8
5,154
2.578125
3
[]
no_license
#![no_std] ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #![allow(non_snake_case)] #![feature(proc_macro)] extern crate parity_hash; extern crate pwasm_std; extern crate...
true
36be8a0825db6633e21b9e922eabd837e8503b3c
Rust
tpraxl/ratel-core
/core/src/parser.rs
UTF-8
34,230
3.125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use lexicon::Token; use lexicon::Token::*; use lexicon::TemplateKind; use tokenizer::Tokenizer; use grammar::*; use operator::OperatorKind; use operator::OperatorKind::*; use owned_slice::OwnedSlice; use error::{ Result, Error, ParseResult, ParseError }; /// Peek on the next token. Return with an error if tokenizer fa...
true
37064662b96098417c23b9a7a660d4188e02e6b9
Rust
FoseFx/UltimateGymWue
/UGWBackend/src/basics/set.rs
UTF-8
1,487
2.65625
3
[]
no_license
use crate::auth::guards::AuthGuard; use crate::basics::utils::Kurs; use rocket::State; use crate::SecretMgt; use rocket_contrib::json::Json; use crate::responses::CustomResponse; use rocket::http::Status; use std::ops::Deref; use crate::DBURL; #[derive(Deserialize,Serialize)] #[derive(Debug)] pub struct SetBasicsReque...
true
1a7cc1edcfaa9cda81205da25425fd709c0a8e30
Rust
gwy15/leetcode
/src/399.除法求值.rs
UTF-8
2,737
3.109375
3
[]
no_license
/* * @lc app=leetcode.cn id=399 lang=rust * * [399] 除法求值 */ struct Solution; // @lc code=start use std::collections::HashMap; type Edge = (String, f64); type Edges = HashMap<String, Edge>; #[allow(unused)] impl Solution { fn find(x: &str, edges: &mut Edges) -> Edge { let edge = edges.entry(x.into()).or_...
true
0d8063af9d11d62ca429cf4f4096595e9b9416d5
Rust
Juzley/adventofcode2019
/day14/src/main.rs
UTF-8
10,147
3.203125
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; const COLLECTED_ORE: u64 = 1000000000000; #[derive(Debug, Eq, PartialEq)] struct Reaction { output: (String, u64), ingredients: Vec<(String, u64)>, } type ReactionMap = HashMap<String, Reaction>; fn calc_ore(reactions: &Rea...
true
91edb52658d1ee627a77cdc6562a996cd00267aa
Rust
USER19112/rr-mod-tool
/src/main.rs
UTF-8
2,056
2.890625
3
[]
no_license
use std::env::args; use std::path::PathBuf; fn main() { let mut args = args().skip(1); match args.next() { Some(s) if s == "-p" => { work_in_pack_mode(args); } Some(s) if s == "-u" => { work_in_unpack_mode(args); } _ => { usage(); ...
true
aaaa7538c65a1088201d9387d483444483168770
Rust
hardik-satasiya/makepad
/code_editor/rope/src/cursor.rs
UTF-8
6,757
3.515625
4
[ "MIT" ]
permissive
use crate::{ChunkCursor, Slice}; /// A cursor over a [`Rope`] or [`Slice`]. /// /// [`Rope`]: crate::Rope #[derive(Clone, Debug)] pub struct Cursor<'a> { chunk_cursor: ChunkCursor<'a>, chunk: &'a str, byte_index: usize, } impl<'a> Cursor<'a> { /// Returns `true` if `self` is currently pointing to the...
true
7cc439e32f37184b443d6b0e8f2658e068e86628
Rust
shigedangao/maomao
/src/kube/workload/affinity/mod.rs
UTF-8
1,527
2.5625
3
[]
no_license
use k8s_openapi::api::core::v1::Affinity; use crate::lib::parser::affinity::Affinity as ParserAffinity; mod node; mod pod; pub struct AffinityWrapper { pub affinity: Affinity } impl AffinityWrapper { /// Create an AffinityWrapper which will be used to create: /// - NodeAffinity /// - PodAffinity ...
true
bdfe5f2f7dbd80e3d362a9010264f4a4483cf6e4
Rust
bushidocodes/hatchling
/src/lib.rs
UTF-8
3,689
2.796875
3
[ "MIT" ]
permissive
pub mod facebook_parser; pub mod profile_builder; use facebook_parser::{EducationExperience, FBFriends, FBProfileInformation}; use profile_builder::Profile; use std::error; pub fn convert_facebook_to_solid( profile: &str, friends: Option<&str>, ) -> Result<String, Box<dyn error::Error>> { let my_fb_profil...
true
a0caf1249c736cbdb758f60a7d0d5a4540c24847
Rust
barisAtmn/RUST101
/src/pointers.rs
UTF-8
111
2.734375
3
[]
no_license
pub fn heap() -> i32 { // e -> smart pointer let e = Box::new(7); // return value return *e; }
true
6ef17f01cde6a7032ffeb6f4607b38d678ef865f
Rust
nphyx/scrapsrl
/src/resource/asset/structure_template.rs
UTF-8
11,960
3.078125
3
[]
no_license
use crate::component::Description; use crate::resource::{Assets, Tile}; use crate::util::Rect; use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Serialize, Deserialize)] pub enum StructureConnectionType { Road, // place connection facing the nearest road, if on the structure perimeter St...
true
aae5f390db1187bb217a7f99659cd11ce171ddad
Rust
cointhink/yith
/src/etherscan.rs
UTF-8
5,648
2.59375
3
[]
no_license
use crate::exchanges; use reqwest::header; use serde::{Deserialize, Serialize}; use std::fmt; use std::fs; use std::time::Duration; #[derive(Debug, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] pub struct InternalTransaction { pub block_number: String, pub from: String, pub value: Stri...
true
0ee43916a234629a26aec89e70c32067515a53d3
Rust
espenbh/TTK4145_elevator_project
/project_main/src/mod_single_elevator_controller/elevator.rs
UTF-8
1,749
2.75
3
[]
no_license
//Implementing elevator.c and elevator.h in rust pub enum ElevatorBehaviour{ EB_Idle, EB_DoorOpen, EB_Moving } pub enum ClearRequestVariant{ CV_All, CV_InDirn, } pub struct Config { clearRequestVariant: ClearRequestVariant, doorOpenDuration_s: double, } pub struct Elevator{ floor:...
true
381560f51f6b50ea6795e3a3350558c815fc8f07
Rust
ephe-meral/halcyon
/src/mat.rs
UTF-8
1,128
3.34375
3
[]
no_license
/// Create a new (zeroed) matrix. /// Dimensions are [`dim_m`, `dim_n`]. /// (m are the rows, n the columns, each row is an array) /// /// # Examples /// `let a = mat![3, 4]` #[macro_export] macro_rules! mat { [$dim_x:expr, $dim_y:expr] => { [[0.0; $dim_y]; $dim_x] } } /// Creates an array of base vec...
true
f0261bdbea490d337649acaef06affbebc106019
Rust
HexColors60/llforth
/lib/tests/read_word.rs
UTF-8
1,059
2.890625
3
[ "MIT" ]
permissive
extern crate assert_cmd; use std::process::Command; use assert_cmd::prelude::*; fn run(stdin: &str, expected: &'static str) { let mut cmd = Command::cargo_example("read_word").unwrap(); cmd .with_stdin() .buffer(stdin) .unwrap() .assert() .stdout(expected); } #[test] f...
true
b891fa14bf15d53eecc9070c3c8fe238e5f70b4c
Rust
AlexanderThaller/advent_of_code_2020
/src/day07/bag.rs
UTF-8
12,557
3.15625
3
[]
no_license
use std::collections::{ HashMap, HashSet, }; use thiserror::Error; #[allow(clippy::empty_enum)] #[derive(Debug, Error)] pub enum Error { #[error("invalid input")] InvalidInput, } #[derive(Debug, Eq, PartialEq)] pub struct Bags(Vec<Bag>); impl Bags { fn find_containers(&self, for_bag_color: &str) ...
true
51eb2d6efa5edf4ab70ebb39fc7cacdfd57f6597
Rust
avmi/timely-dataflow
/timely/src/dataflow/operators/exchange.rs
UTF-8
1,497
2.984375
3
[ "MIT" ]
permissive
//! Exchange records between workers. use crate::ExchangeData; use crate::container::PushPartitioned; use crate::dataflow::channels::pact::ExchangeCore; use crate::dataflow::operators::generic::operator::Operator; use crate::dataflow::{Scope, StreamCore}; /// Exchange records between workers. pub trait Exchange<D> { ...
true
01a35fe06e1534c83b47477d1581f8820b4c12b1
Rust
apognu/candia
/src/datasource/fixed.rs
UTF-8
221
3.03125
3
[ "MIT" ]
permissive
pub struct Array { vec: super::Data, } impl Array { pub fn new(vec: &[String]) -> Array { Array { vec: vec.to_vec() } } } impl super::DataSource for Array { fn iter(self) -> super::Data { self.vec } }
true
30d8a70c93c661d116773aa8783fdf26d0cf61fb
Rust
sseering/AdventOfCode
/2020/aoc15/src/main.rs
UTF-8
6,314
3.546875
4
[]
no_license
// --- Day 15: Rambunctious Recitation --- // // You catch the airport shuttle and try to book a new flight to your vacation island. Due to the storm, all direct flights have been cancelled, but a route is available to get around the storm. You take it. // // While you wait for your flight, you decide to check in with ...
true
31365e9daf7098b78e3d0d63438a271352a6f7ef
Rust
neetdai/leetcode-SAO
/src/problems/problem121.rs
UTF-8
1,340
4.0625
4
[]
no_license
/// # 121. Best Time to Buy and Sell Stock /// /// Say you have an array for which the ith element is the price of /// a given stock on day i. If you were only permitted to complete at most /// one transaction (i.e., buy one and sell one share of the stock), design /// an algorithm to find the maximum profit. Note that...
true
a5408441ee55fd8f8a128db9670596a78572a466
Rust
playerdefault/rustybox
/tests/bc.rs
UTF-8
5,820
2.921875
3
[]
no_license
mod common; use common::exe; use duct::cmd; use std::io::Write; fn simple_test(stdin: &str, expected_stdout: &str) { let stdout = cmd!(exe(), "bc").stdin_bytes(stdin).read().unwrap(); assert_eq!(stdout, expected_stdout); } fn file_test(file: &str, stdin: &str, expected_stdout: &str) { let mut input_file = tempf...
true
837ea9593968ab00d244186412e8ffc1a10748b3
Rust
flintlang/flint
/Quartz/src/Parser/mod.rs
UTF-8
55,887
2.578125
3
[ "MIT" ]
permissive
use super::AST::*; extern crate nom; extern crate nom_locate; use nom_locate::{position, LocatedSpan}; use crate::environment::Environment; use nom::{branch::alt, bytes::complete::tag, combinator::map, multi::many0, sequence::preceded}; use std::collections::HashSet; type ParseResult = (Option<Module>, Environment);...
true
0c7bdae805cc51a75f148003d06d958f568d513d
Rust
AssafVa/aoc2018
/src/day5/mod.rs
UTF-8
653
2.859375
3
[ "Unlicense" ]
permissive
use std::fs::File; use std::io::{BufReader, BufRead, Read}; use super::utils; impl<'a> utils::IterableInput<'a> { pub fn get_as_string(&self) -> String { let file = File::open(self.path()).unwrap(); let mut reader = BufReader::new(file); let mut string = String::new(); reader.read...
true
05ee087359a45f10cb2a8194dbea44ce6a475017
Rust
Vengarioth/route-audio
/src/router.rs
UTF-8
2,703
2.515625
3
[]
no_license
use std::io::Error as IoError; use ::platform::windows::{ DataFlow, Role, DeviceState }; use ::devices::{ Devices, DeviceInformation }; use ::graph_builder::{ Graph, Node }; use ::graph::capture_node::CaptureNode; use ::graph::render_node::RenderNode; use ::graph::sample_rate_converter::SampleRateConverter; ...
true
78b3aed9968d290957337c180c45312a81274559
Rust
douglascook/game_of_life
/src/main.rs
UTF-8
2,189
3.515625
4
[]
no_license
fn main() { let mut state = seed_board(); print_board(&state); for i in 1..20 { println!("Iteration {}", i); state = get_next_state(state); print_board(&state); } } fn seed_board() -> [[char; 10]; 10] { let empty_row = [' '; 10]; let mut state = [empty_row; 10]; fo...
true
848401381737d770389b8d1bc8c3760a0721dd5f
Rust
RaasAhsan/just
/src/main.rs
UTF-8
3,660
2.953125
3
[]
no_license
// 0: iconst_3 // 1: istore_1 // 2: iload_1 // 3: iconst_3 // 4: iadd // 5: istore_2 // 6: return mod jvm; mod runtime; use jvm::opcode; use jvm::opcode::Opcode; fn main() { let program: Vec<u8> = vec![ Opcode::Iconst3 as u8, Opcode::Istore1 as u8, Opcode::Iload1 as u8, Opcode::I...
true
99912405ba4f34638ef3e5dca597f70686aaf488
Rust
hamish-miller/nand2tetris-toolchain
/vm-translator/src/codewriter.rs
UTF-8
10,903
2.71875
3
[]
no_license
/// Translates VM commands into Hack assembly code. use std::ffi::OsStr; use std::fs::File; use std::io::{prelude::*, BufWriter}; use std::iter::Zip; use crate::parser::CommandType; const VERBOSE: bool = true; fn arithmetic_binary(op: &str) -> Vec<&str> { vec!("@SP", "A=M-1", "D=M", "A=A-1", op, "@SP", "M=M-1")...
true
7c9ec7a3d9c775282f9b1ae53971d727044f3801
Rust
tylerreisinger/noise_visualizer
/src/uniform.rs
UTF-8
410
2.6875
3
[]
no_license
use glium::{self, uniforms}; pub struct UniformBlock<U: glium::buffer::Content + uniforms::UniformBlock> { values: Vec<U>, buffer: Option<uniforms::UniformBuffer<U>>, } impl<U> UniformBlock<U> where U: glium::buffer::Content + uniforms::UniformBlock, { pub fn new(data: Vec<U>) -> UniformBlock<U> { ...
true
fa57e2b86c2ad38d49a062d2215a595ce54d45c2
Rust
LaurentMazare/tch-rs
/src/nn/func.rs
UTF-8
1,165
3.140625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Layers defined by closures. use crate::Tensor; /// A layer defined by a simple closure. pub struct Func<'a> { f: Box<dyn 'a + Fn(&Tensor) -> Tensor + Send>, } impl<'a> std::fmt::Debug for Func<'a> { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "func") } } pub fn ...
true
1fcfefee410ec61a9f45bb34fc5ce0b167930569
Rust
fiplox/rust-exercism
/bob/src/lib.rs
UTF-8
808
3.453125
3
[]
no_license
// check if m has at least one letter fn has_letter(m: &str) -> bool { for c in m.chars() { if (c > 'a' && c < 'z') || (c > 'A' && c < 'Z') { return true; } } false } pub fn reply(message: &str) -> &str { let message = message.trim(); if message.is_empty() { ret...
true
c04080bf8adb06ba739da9fe94f0605f6b75a766
Rust
Oscuro87/kingslayer
/src/entity/lockable.rs
UTF-8
488
2.890625
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; use crate::types::CmdResult; #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum DoorLock { Locked, Unlocked, } impl DoorLock { pub fn is_locked(self) -> bool { match self { DoorLock::Locked => true, DoorLock::Unlo...
true
8c0a8a1788a9860489bca2ed8f0ad9cec8012b48
Rust
WarrenWeckesser/experiments
/rust/compensated_float_sum/src/bin/compsum_separate_typed_fns.rs
UTF-8
751
3.421875
3
[]
no_license
use std::println; fn compensated_sum_f32(x: &[f32]) -> f32 { let mut sum = 0.0f64; for &val in x { sum += val as f64; } sum as f32 } fn compensated_sum_f64(x: &[f64]) -> f64 { let mut sum = 0.0; let mut c = 0.0; for &val in x { let y = val - c; let t = sum + y; ...
true
fcb45ffbd397da3e299290d12b18a68c09668b7d
Rust
tbrand/rp
/rp-copier/src/fut.rs
UTF-8
1,839
2.734375
3
[]
no_license
use super::Copier; use futures::{future, *}; use futures_fs::{FsPool, FsReadStream, FsWriteSink}; use num_cpus; use rp_error::Result; use std::fs; use std::path::{Path, PathBuf}; pub struct Fut; type CopyFuture = stream::Forward<FsReadStream, FsWriteSink>; impl Fut { fn copy_fut(fs: &FsPool, src: &Path, target: ...
true
c1982ca8460a7ba35e95664600f1284e32c10905
Rust
sts10/advent-of-code-2018
/src/bin/day03.rs
UTF-8
4,252
3.34375
3
[ "BlueOak-1.0.0" ]
permissive
use std::fs::File; use std::io; use std::io::BufRead; use std::io::BufReader; use std::str::FromStr; fn main() { // let input: Vec<&str> = vec!["#1 @ 1,3: 4x4", "#2 @ 3,1: 4x4", "#3 @ 5,5: 2x3"]; // let mut whole_piece: [[usize; 8]; 8] = [[0; 8]; 8]; let input: Vec<String> = read_by_line("inputs/day03.txt"...
true
b8e59f469ca79e030004a9db1ed132b76978bed7
Rust
jamescarterbell/voxel_game
/v_game/v_voxels/src/lib.rs
UTF-8
27,480
2.609375
3
[]
no_license
use v_transform::*; use v_rle::*; use v_renderer::*; use v_windowing::*; use v_renderer::index::PrimitiveType; use nalgebra as na; use na::{Vector3, Vector2}; use specs::prelude::*; use specs::ParJoin; use dashmap::*; use dashmap::mapref::one::Ref; use std::sync::{Arc, Mutex}; use nalgebra::{Matrix, U1}; use std::col...
true