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
2560fa74288848396f77797ed1f991d5cdbb86c3
Rust
adjivas/telamon
/src/explorer/choice.rs
UTF-8
6,366
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Choices that can be applied to split the search space. use ir::mem::Block; use ir::{self, Statement}; use itertools::Itertools; use search_space::{Action, Domain, NumSet, Order, SearchSpace}; /// Represents a choice that splits a search space in multiple ones. // TODO(search_space): explore and lower loayouts dire...
true
c00dd0ecace4fc39e82c80b30b952ca359aedb7b
Rust
tawashichan/api-server-rs
/src/domain/model/user.rs
UTF-8
943
2.890625
3
[]
no_license
use crate::domain::model::{email::Email, identity::Id}; use anyhow::Result; use super::error::DomainError; pub type UserId = Id<User>; #[derive(Debug, Clone)] pub struct User { user_id: UserId, name: UserName, email: Email, } #[derive(Debug, Clone)] pub struct UserName(String); impl UserName { pub ...
true
fd456c87a83ccad94f5c2ac43dfc910187a7373e
Rust
Iniesta8/aoc2020
/src/bin/day11.rs
UTF-8
3,892
3.40625
3
[]
no_license
use std::fs; type Grid = Vec<Vec<char>>; fn parse(input: &str) -> Grid { input.lines().map(|l| l.chars().collect()).collect() } fn occupy_all_seats(grid: &mut Grid) { for i in 0..grid.len() { for j in 0..grid[0].len() { if grid[i][j] == 'L' { grid[i][j] = '#'; ...
true
01b9c9f00c5d08b79e1755fb74d6a37661a69c98
Rust
Ben435/simple-opengl-renderer
/src/render/ogl/gl_vertex.rs
UTF-8
634
3.1875
3
[]
no_license
use cgmath::{Vector3,vec3}; use gl::types::GLfloat; pub type Index = u16; pub struct Vertex { pub position: Vector3<GLfloat>, pub normal: Vector3<GLfloat>, } impl Vertex { pub fn new(position: Vector3<GLfloat>, normal: Vector3<GLfloat>) -> Vertex { Vertex { position, norma...
true
32f0a8b354588b1ebb4454a867cd70f3b7904266
Rust
noahmancino/Rust_Y86-64-simulator
/src/state.rs
UTF-8
1,515
3.15625
3
[]
no_license
/* This module defines the structure of the systems memory state. */ // "Processor" status code #[allow(dead_code)] pub enum Status { // Default status AOK, // Status after halt instruction HLT, // Status after attempting to access invalid memory ADR, // Invalid instruction. INS } ...
true
f783ec68de1e02476a806c89535be5578040f6f7
Rust
mstange/srcsrv
/src/lib.rs
UTF-8
26,063
3.25
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Parse a `srcsrv` stream from a Windows PDB file and look up file //! paths to see how the source for these paths can be obtained: //! //! - Either by downloading the file from a URL directly ([`SourceRetrievalMethod::Download`]), //! - or by executing a command, which will create the file at a certain path ([`Sou...
true
d6449a68804da7378567795ed1e48a24077d1ccf
Rust
rustkas/rust_javatpoint
/javatpoint_rust_src/vectors/src/vector4.rs
UTF-8
382
2.84375
3
[ "MIT" ]
permissive
/* cargo run -p vectors --bin vector4 cargo fmt --verbose --package vectors */ fn value(n: Option<&i32>) { match n { Some(n) => println!("Fourth element of a vector is {}", n), None => println!("None"), } } fn main() { let v = vec![20, 30, 40, 50]; let a: Option<&i32> = v.get(7); va...
true
ec7d9b9e614fe2087b02409f1c7162d76cab57e8
Rust
quantapix/qnarre
/workshop/too-many/src/bin/multithreaded.rs
UTF-8
1,826
3.234375
3
[ "MIT" ]
permissive
use std::{ io::{self, Read, Write}, net::{TcpListener, TcpStream}, }; fn main() { let listener = TcpListener::bind("localhost:3000").unwrap(); loop { let (connection, _) = listener.accept().unwrap(); std::thread::spawn(move || { if let Err(e) = handle_connection(connection...
true
14f5b070292eee1b12aaa75aca6f8e0a92e67309
Rust
Barogthor/GWBot
/src/commands/lang.rs
UTF-8
1,457
2.8125
3
[]
no_license
use serenity::framework::standard::{Args, CommandResult}; use serenity::framework::standard::macros::command; use serenity::model::channel::Message; use serenity::prelude::*; use serenity::utils::MessageBuilder; use crate::enums::Language; use crate::get_mut_bot_datas; use crate::utils::GuildsConfig; #[command] async...
true
3cd872695003487546f294cbf50cf9f80a47ce0e
Rust
Arunscape/ECE421
/assignments/assignment3/question2/src/main.rs
UTF-8
1,570
3.390625
3
[]
no_license
fn main() {} #[derive(Default)] #[allow(dead_code)] struct Player { id: i32, first_name: String, last_name: String, } #[cfg(test)] mod test { use super::*; use hamcrest2::prelude::*; #[test] fn player_has_first_name() { let p = Player::default(); assert_that!(p.first_name,...
true
60304dac7544cef1c725d602ffaac8569a1e26b1
Rust
dodgez/snappy
/src/index.rs
UTF-8
1,029
2.734375
3
[ "MIT" ]
permissive
use std::path::Path; use std::{fs, io}; use crate::objects::TreeEntry; use crate::repo; pub fn update_index(path: &Path, hash: &str) -> Result<(), io::Error> { let path = if path.starts_with(".") { path.strip_prefix(".").unwrap() } else { path }; let repo = repo::import()?; let co...
true
47cc667a3420bd333afdbd6a90a6afe8acb7833a
Rust
y-usuzumi/web-server-rs
/src/response.rs
UTF-8
375
2.890625
3
[]
no_license
pub struct Response { status_code: u32, body: String } impl Response { pub fn from_params(status_code: u32, body: &str) -> Self { Self { status_code, body: body.to_string() } } pub fn body(&self) -> String { self.body.clone() } pub fn status...
true
91df0c3df914352f967a8395409d685835ea5d8f
Rust
kaliumxyz/ctf-vm
/src/opcode.rs
UTF-8
29,001
3.515625
4
[]
no_license
use crate::util::read; use crate::util::read_x; use crate::util::read_argument; use crate::debug::Meta; use crate::vm::State; use crate::util::write_argument; use std::fmt; #[derive(Debug, PartialEq)] pub enum Code { /// halt: 0 /// stop execution and terminate the program Halt, /// set: 1 a b //...
true
acc0279b79878e99cd2e09fa0ae7349ef41984b6
Rust
LinusU/advent-of-code-2019
/src/day11.rs
UTF-8
13,377
3.078125
3
[]
no_license
use std::collections::{HashMap, VecDeque}; use std::fmt; use std::num::ParseIntError; use std::ops::{Index, IndexMut}; use std::str::FromStr; use aoc_runner_derive::aoc; struct Memory(Vec<i64>); impl Index<usize> for Memory { type Output = i64; fn index(&self, index: usize) -> &i64 { if index < self...
true
62a1634f193c78c988a0cff53d01405b341e3c4f
Rust
Ruddickmg/byThePeoples
/services/auth/src/handler/password_reset/request_password_reset.rs
UTF-8
2,213
2.6875
3
[]
no_license
use actix_web::{web, HttpResponse}; use crate::{ controller::password_reset, repository, model, }; pub async fn request_password_reset<L, C, R>( state: web::Data<model::ServiceState<L, C, R>>, json: web::Json<model::ResetRequest>, ) -> HttpResponse where L: repository::LoginHistory, ...
true
f30bec7dd9b7426375f5ade4eeb3b88096ddca78
Rust
arudei-dev/hep-framework
/src/math/hilbert/unit4/vec4/op_prod.rs
UTF-8
895
3.140625
3
[]
no_license
use std::ops::Mul; use crate::math::number::*; use super::*; impl Mul<Vec4> for Vec4 { type Output = Complex; #[inline] fn mul(self, rhs: Vec4) -> Self::Output { debug_assert!( self.basis == Bra && rhs.basis == Ket, "Operation Vec4 * Vec4 error: must be < bra | ket >!" ...
true
3c10b8f61de79bcc53267041ce78b3a676f180bb
Rust
eyebex/rust_ib_api
/tests/integration_tests.rs
UTF-8
7,079
2.578125
3
[ "MIT" ]
permissive
use rs_ib_api::ib_client::IBClient; use rs_ib_api::ib_contract::*; use rs_ib_api::order::Order; use tokio::time; use chrono::Duration; use chrono::{TimeZone, Utc, DateTime}; use rs_ib_api::ib_enums::*; use rust_decimal::prelude::*; #[tokio::test] async fn contract_details() { let mut client = match IBClient::con...
true
d982db14076a87f8eb4e5a6177cc1998babe780b
Rust
erezny/rusted-cypher
/src/lib.rs
UTF-8
4,992
3.4375
3
[ "MIT" ]
permissive
//! Rust crate for accessing the cypher endpoint of a neo4j server //! //! This is a prototype for accessing the cypher endpoint of a neo4j server, like a sql //! driver for a relational database. //! //! You can execute queries inside a transaction or simply execute queries that commit immediately. //! //! # Serializa...
true
b8ba72f7b868eaf474b303ad99ba9e30f64a8757
Rust
mozilla/gecko-dev
/third_party/rust/writeable/tests/writeable.rs
UTF-8
929
3
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 std::fmt; use writeable::assert_writeable_eq; use writeable::LengthHint; use writeable::Writeable; /// A sample ...
true
0ad386ac8393ebef57e5c0fa84c29600f6827b92
Rust
Sinjo/aoc2020
/src/aoc/day9.rs
UTF-8
2,038
3.75
4
[]
no_license
use std::collections::HashSet; use anyhow::anyhow; // Remember to change window size for smaller input files pub fn day9a(inputs: &[String]) -> anyhow::Result<String> { let numbers: Vec<usize> = inputs.iter().map(|i| i.parse().unwrap()).collect(); let answer = find_non_sum_of_previous(&numbers, 25); Ok(...
true
268c321ab90facada1e41ac9966a19e837446f8a
Rust
IThawk/rust-project
/rust-master/src/test/ui/pattern/slice-pattern-const-3.rs
UTF-8
984
2.75
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![deny(unreachable_patterns)] fn main() { let s = &["0x00"; 4][..]; //Slice of any value const MAGIC_TEST: &[&str] = &["4", "5", "6", "7"]; //Const slice to pattern match with match s { MAGIC_TEST => (), ["0x00", "0x00", "0x00", "0x00"] => (), ["4", "5", "6", "7"] => (), // FIXME(o...
true
4bdbe5e9ff829923b694e98c0f1cb081c37fbbcb
Rust
AleksandarMitrevski/sudoku
/src/game/solver/mod.rs
UTF-8
2,110
3.28125
3
[]
no_license
use super::SudokuBoard; /// Solves the given board if it is solvable and returns the solution found, else it returns None pub fn solve(board : &SudokuBoard) -> Option<SudokuBoard> { use super::check_for_errors; if check_for_errors(board).is_empty() { let mut board_clone = board.clone(); if solv...
true
a32be439ade4f8c7a5138d6962aa9ee7a1c0b4cc
Rust
koji-m/distributed_service_with_rust
/lets_rust/src/log.rs
UTF-8
951
3.34375
3
[]
no_license
use serde::{Deserialize, Serialize}; use std::sync::Mutex; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Record { value: String, offset: usize, } pub type Log = Mutex<Vec<Record>>; pub trait Logger { fn create_empty() -> Log; fn append(&self, record: Record) -> usize; fn read(&self, ...
true
d38d70958aad6a08896edaa66484a12f60544f1a
Rust
phasetr/mathcodes
/fundamental_for_CFD/4-3_convection_2nd_order_Lax-Wendroff.rs
UTF-8
5,322
2.953125
3
[]
no_license
// cargo-deps: chrono extern crate chrono; use chrono::Local; use std::env; use std::error; use std::fs; use std::fs::File; use std::io::prelude::*; use std::io::BufWriter; use std::process; const I_MAX: usize = 100; const NODE: usize = I_MAX + 1; const PI: f64 = std::f64::consts::PI; const C: f64 = 2.0 * PI * ((I_MAX...
true
bb9972924f1a0d2533196ab670bef1abaa4f5a21
Rust
NestedWorld/NestedWorld-Server-RealTime
/db/src/error.rs
UTF-8
2,368
2.84375
3
[]
no_license
//! Database errors definition. pub type Result<T> = ::std::result::Result<T, Error>; macro_rules! impl_sub_error { ($err_ty:ident::$variant:ident($ty:ty)) => { impl From<$ty> for $err_ty { fn from(err: $ty) -> $err_ty { $err_ty::$variant(err.into()) } } ...
true
253eb323bdfb7bd113e41d38647f28ce8e8c6bd9
Rust
prisma/prisma-engines
/schema-engine/connectors/sql-schema-connector/src/sql_destructive_change_checker/warning_check.rs
UTF-8
8,346
2.984375
3
[ "Apache-2.0" ]
permissive
use super::{ check::{Check, Column, Table}, database_inspection_results::DatabaseInspectionResults, }; #[derive(Debug)] pub(super) enum SqlMigrationWarningCheck { DropAndRecreateColumn { table: String, namespace: Option<String>, column: String, }, NonEmptyColumnDrop { ...
true
1f0d2ecb20fb506d8db1de01558df18898da2117
Rust
trevorsm7/advent_of_code_2017
/src/day24.rs
UTF-8
7,373
3.234375
3
[]
no_license
use std::usize; use std::{fs, env}; use std::io::Error; use std::collections::HashMap; type Port = u32; type Component = [Port; 2]; type PortLookup = HashMap<Port, Vec<usize>>; struct Visited { indices: Vec<usize>, outputs: Vec<Port>, } struct Pending { indices: Vec<usize>, parents: Vec<usize>, i...
true
3c8bb998d498ba599b2e4d3a771a8c45c7e354cd
Rust
ckuenzi/AoC
/aoc_2018/aoc_10_1/src/main.rs
UTF-8
2,070
3.40625
3
[ "Unlicense" ]
permissive
fn main() { let mut stars = include_str!("input.txt") .lines() .map(|line| { let nums = line .split(|c| c == '<' || c == ',' || c == '>' || c == ' ') .filter_map(|s| s.parse::<i64>().ok()) .collect::<Vec<_>>(); Star::new(nums[0]...
true
e7ed40725ee2cc87818dde46bc47a3772b34ba59
Rust
ehsan/rust
/src/lib/list.rs
UTF-8
2,773
2.734375
3
[ "LicenseRef-scancode-other-permissive", "bzip2-1.0.6", "BSD-1-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* Module: list A standard linked list */ import option::{some, none}; /* Section: Types */ /* Tag: list */ tag list<T> { /* Variant: cons */ cons(T, @list<T>); /* Variant: nil */ nil; } /*Section: Operations */ /* Function: from_vec Create a list from a vector */ fn from_vec<T>(v: [mutable? T]) ...
true
e11b8c1da8f59c83a3b00320c99f717191b8823b
Rust
Erutuon/enwiktionary-entries-by-language
/src/main.rs
UTF-8
7,238
2.8125
3
[]
no_license
use dump_parser::{ wiktionary_configuration, Namespace, Node, Page, Positioned, }; use std::{ fmt::Display, fs::File, io::{BufReader, BufWriter, Write}, path::Path, result::Result as StdResult, }; mod error; mod types; use error::{Error, Result}; use getopts::{Fail, Options}; use types::{Langu...
true
f1a846b9353a17734ac25cd14bab17ba8b1d99a3
Rust
wlongxiang/hello_cargo
/src/mydirmodule/mod.rs
UTF-8
589
3.09375
3
[]
no_license
/* This is a module organized in a directory, which has: - An entry point mod.rs, which can also expose submodules within this module by `pub mod` - Other submodules in a different file It is best to think of this file as a definition for API, ie, what to expose to end users. */ pub mod submodule; // such that this...
true
976d215892073199caf014fe077e887d580bbbcd
Rust
Hevia/Moray
/src/main.rs
UTF-8
2,616
3.046875
3
[ "Apache-2.0" ]
permissive
use clap::{App, Arg, SubCommand}; use std::io::{BufRead, BufReader, Error, ErrorKind}; use std::process::{ChildStdout, Command, Stdio}; fn main() { let matches = App::new("moray") .version("0.1") .author("Anthony Hevia. <anthony@hevia.dev>") .about("Rust's Cargo-style tooling for Python") ...
true
1c737affb44c3922988fbe5dca9a8fdeed08f1f1
Rust
microsoft/DiskANN
/rust/vector/src/metric.rs
UTF-8
872
3.0625
3
[ "MIT" ]
permissive
/* * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT license. */ #![warn(missing_debug_implementations, missing_docs)] use std::str::FromStr; /// Distance metric #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum Metric { /// Squared Euclidean (L2-Squared) L2, /// ...
true
8ec15a1fb08025e9cb105344274f8565f0de14e6
Rust
matklad/salsa
/examples/hello_world/implementation.rs
UTF-8
2,273
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::class_table; use crate::compiler::{CompilerQueryContext, Interner}; use salsa::query_context_storage; /// Our "query context" is the context type that we will be threading /// through our application (though 99% of the application only /// interacts with it through traits and never knows its real name). ///...
true
89bc3e9306ab10435bce7e30c5c421201302042b
Rust
image-rs/image
/src/codecs/webp/loop_filter.rs
UTF-8
4,312
3.046875
3
[ "MIT" ]
permissive
//! Does loop filtering on webp lossy images use crate::utils::clamp; #[inline] fn c(val: i32) -> i32 { clamp(val, -128, 127) } //unsigned to signed #[inline] fn u2s(val: u8) -> i32 { i32::from(val) - 128 } //signed to unsigned #[inline] fn s2u(val: i32) -> u8 { (c(val) + 128) as u8 } #[inline] fn diff...
true
20eb553ec0b53acdc1bcf25494a7a7881a100d4d
Rust
spacejam/demikernel
/src/rust/catnip/src/collections/hashttlcache/tests.rs
UTF-8
3,459
3.109375
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. use super::*; #[test] fn with_default_ttl() { // tests to ensure that an entry without an explicit TTL gets evicted at // the right time (using the default TTL). let now = Instant::now(); let later = now + Duration::from_secs(1...
true
71a17806c78f890881d8b7af4faf0efacf897211
Rust
p0lunin/teloxide-core
/src/payloads/set_passport_data_errors.rs
UTF-8
1,206
2.640625
3
[ "MIT" ]
permissive
// This file is auto generated by `cg` <https://github.com/teloxide/cg> (be02d84). // **DO NOT EDIT THIS FILE**, // edit `cg` instead. use serde::Serialize; use crate::types::{PassportElementError, True}; impl_payload! { /// Informs a user that some of the Telegram Passport elements they provided contains errors....
true
2ff81adb164143fa0bc04610de5d30bb32fcc7db
Rust
smessmer/screeps-game-api
/src/js_collections/js_vec.rs
UTF-8
9,223
3.328125
3
[ "MIT" ]
permissive
//! [`JsVec`] use crate::{ traits::{FromExpectedType, IntoExpectedType, TryFrom, TryInto}, ConversionError, }; use std::marker::PhantomData; use stdweb::{Array, InstanceOf, JsSerialize, Reference, ReferenceType, Value}; // // - InstanceOf // - AsRef<Reference> // - ReferenceType // - Into<Reference> //...
true
ef244e6080258857533d802611fcb0d309e7aace
Rust
xfoxfu/limeltl
/src/enforcers/mod.rs
UTF-8
3,471
3.078125
3
[]
no_license
//! 利用已有的例子或内容生成逻辑表达式以确保其符合约束。 //! //! `Enforcer` 是对于规则生成器的抽象。 //! //! 1. `AFASkTypeEnforcer` 保证每个节点属于且只属于一种 AFA 类型 //! 2. `AFASpecificStructureEnforcer` 保证对应节点类型的子树数量符合要求 //! 3. `SizeBoundEnforcer` 保证不存在节点重用,从而保证 AFA 大小符合要求 //! 4. `LTLSubtreeEnforcer` 保证每个节点存在编号大于其自身的子树。 //! 5. `LTLSizeEnforcer` 检查在 `N-2`(`N-1`)以后不存在二...
true
7c3de663a86020f24f04e93b2ca0dbeb875d8d92
Rust
vasilp98/Tetris
/src/bomb.rs
UTF-8
2,233
2.96875
3
[]
no_license
use ggez::audio::{self, SoundSource, Source}; use ggez::mint::Point2; use ggez::graphics; use ggez::graphics::{DrawParam}; use ggez::Context; use ggez::GameResult; use crate::constants::*; use crate::block::*; pub struct Bomb { pub pos: Point2<f32>, image: graphics::Image, pub sound: Source } impl Bomb {...
true
1e300ff040c78b4fbb5e44e024bbf7acfe4b05d9
Rust
alibaba/GraphScope
/interactive_engine/executor/engine/pegasus/benchmark/src/bin/amsk.rs
UTF-8
5,145
2.515625
3
[ "Apache-2.0", "LicenseRef-scancode-proprietary-license", "FSFAP", "BSD-3-Clause-Clear", "GPL-1.0-or-later", "BSD-2-Clause-Views", "Bitstream-Vera", "MPL-2.0", "LicenseRef-scancode-warranty-disclaimer", "OFL-1.1", "BSD-3-Clause", "APAFML", "0BSD", "LicenseRef-scancode-free-unknown", "CC-B...
permissive
use std::path::PathBuf; use std::sync::Arc; use std::time::Instant; use pegasus::{Configuration, JobConf, ServerConf}; use structopt::StructOpt; /// Search and count k-hop neighbors for each vertex in a list using only one job; /// Do k-hop searching for each vertex in async mode; #[derive(Debug, StructOpt)] #[struct...
true
171ed32c2ab60b49585c0786ed8428495ab2c4a5
Rust
timglabisch/easyssh
/src/ssh.rs
UTF-8
2,049
2.953125
3
[]
no_license
use std::net::TcpStream; use ssh2::{Channel, Session}; use std::io::Read; use std::io::Write; use std::borrow::Cow; pub struct SSHSession { inner: Session } pub struct SSHChannel { inner: Channel } impl SSHSession { fn authed_session(user : String, addr: String, port : u32) -> ssh2::Session { let...
true
6b4a72da4b8eff1d685736c81db199e72f950b27
Rust
universome/rtrs
/src/surface/quadrics.rs
UTF-8
7,495
2.890625
3
[]
no_license
use crate::surface::surface::{Surface, Hit, VisualData}; use crate::basics::*; use crate::matrix::{Mat3, AffineMat3, DiagMat3}; use crate::surface::MIN_RAY_T; #[derive(Debug, Clone)] pub struct Sphere { pub center: Point, pub radius: f32, pub vis: VisualData, } impl Sphere { pub fn new(vis: VisualDa...
true
5ef643142cbdb074eec884f4febce355dd1f9644
Rust
dahliaOS/fuchsia-pi4
/src/ui/lib/input_pipeline/src/touch.rs
UTF-8
21,399
2.703125
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { crate::input_device::{self, InputDeviceBinding, InputEvent}, crate::utils::{Position, Size}, anyhow::{format_err, Error}, async_trait...
true
2591a7f04b9923950bea292bade22132cd480078
Rust
SoundRabbit/soldoresol
/src/orgs/renderer.org/program/cube_program.rs
UTF-8
2,964
2.625
3
[]
no_license
use super::webgl::{WebGlAttributeLocation, WebGlRenderingContext}; use web_sys::WebGlUniformLocation; const VERTEX_SHADER: &str = r#" attribute vec4 a_vertex; attribute vec3 a_normal; uniform mat4 u_translate; uniform mat4 u_invModel; uniform vec3 u_light; uniform vec4 u_maskColor; uniform ...
true
91c5b7b6276b6bb337de9f2a2cd19151c974ee26
Rust
antstorm/matasano
/set_1/1.rs
UTF-8
1,752
3.421875
3
[]
no_license
// Convert hex to base64 // The string: // 49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d // Should produce: // SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t // So go ahead and make that happen. You'll need to use this code for the rest of the exer...
true
58958bf3ebd5d92ff69e52e92de2548bffa47a05
Rust
LukasKalbertodt/beaver
/src/cmd/full/summary.rs
UTF-8
11,672
3.0625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cmp::min; use ahash::AHashMap; use crate::outcome::OutcomeSink; pub struct Summary { /// The most number 1s written. high_score: u32, /// The number of TMs that have written `high_score` many 1s. num_winners: u64, /// The fewest number of steps a winner required to write `high_score` ...
true
513bbfb9b32fd8a1a09c7e4c893931d340eb76e4
Rust
evan-brass/weekend-raytracing
/renderer/src/image.rs
UTF-8
1,911
3.484375
3
[]
no_license
use std::convert::Into; use std::ops::Mul; // Color: #[repr(packed)] #[repr(C)] #[derive(Clone, Copy)] #[derive(Debug)] pub struct Color { pub red: u8, pub green: u8, pub blue: u8, pub alpha: u8 } impl Color { pub fn new(red: u8, green: u8, blue: u8, alpha: u8) -> Self { Color { red, green, blue, alpha } } } i...
true
13849de187cc0963edf2b2f2738c4bd7191e10d3
Rust
KeisukeYamashita/vasputils
/src/source.rs
UTF-8
2,928
3.171875
3
[ "MIT" ]
permissive
extern crate reqwest; extern crate dirs; extern crate serde; extern crate serde_json; use std::error::Error; use std::path::{PathBuf}; use std::fs::File; use std::io::{BufWriter, Write, BufReader, Read}; use std::str::FromStr; use self::serde_json::{Value}; /// `Source` is a struct for interracting with external sour...
true
6342a5559128427a6f234c294282e9694e45e103
Rust
ktfleming/rhc
/src/http.rs
UTF-8
3,874
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::config::Config; use crate::request_definition::{Content, RequestDefinition}; use attohttpc::body; use attohttpc::Response; use std::time::Duration; // Wrapper around attohttpc's PreparedRequest, in order to // make the types simpler enum OurPreparedRequest { Bytes(attohttpc::PreparedRequest<body::Bytes<...
true
4f23a48049a687b06cc78ab1f6b5dd98bb6e03ca
Rust
Kinrany/hammerpipe
/src/game/field.rs
UTF-8
765
2.734375
3
[]
no_license
use quicksilver::{ geom::{Rectangle, Vector}, graphics::{Background, Color}, lifecycle::Window, }; pub struct Field; impl Field { pub fn size(w: &Window) -> Vector { let screen_size = w.screen_size(); Vector::ONE * f32::min(screen_size.x, screen_size.y) } pub fn pos(w: &Window) -> Vector { (w...
true
70511facda3ef34f9fb4aef0544a8f5d366fcaf9
Rust
CertainLach/kct
/crates/kct_package/tests/fixtures/mod.rs
UTF-8
544
2.765625
3
[ "MIT" ]
permissive
use std::env; use std::fs; use std::path::{Path, PathBuf}; pub struct Fixture {} impl Fixture { fn root() -> PathBuf { let root_dir = &env::var("CARGO_MANIFEST_DIR").expect("$CARGO_MANIFEST_DIR"); let mut source = PathBuf::from(root_dir); source.push("tests/fixtures"); source } pub fn path<T: AsRef<Path>...
true
1b417381d31c0c6c75eb92c8ede36a2d1c97d507
Rust
PSeitz/tantivy
/columnar/src/column_values/vec_column.rs
UTF-8
1,256
3.03125
3
[ "MIT" ]
permissive
use std::fmt::Debug; use tantivy_bitpacker::minmax; use crate::ColumnValues; /// VecColumn provides `Column` over a slice. pub struct VecColumn<'a, T = u64> { pub(crate) values: &'a [T], pub(crate) min_value: T, pub(crate) max_value: T, } impl<'a, T: Copy + PartialOrd + Send + Sync + Debug> ColumnValues...
true
9d49ac79729791eb5318bdfe39f57a160a2626cf
Rust
mvernacc/advent_of_code_2020
/day1/day1.rs
UTF-8
3,209
3.578125
4
[]
no_license
use std::env; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; /// Run with `./day1 input.txt` fn main() { let args: Vec<String> = env::args().collect(); let filename = &args[1]; println!("{}", filename); let mut numbers = Vec::<u32>::new(); if let Ok(lines) = read_lines(file...
true
6832c3fe7ccaa6e56f5f45b275b7a9e47a63a1a8
Rust
wyfcyx/cs110l-spr-2020-starter-code
/proj-1/deet/src/dwarf_data.rs
UTF-8
6,464
2.765625
3
[ "MIT" ]
permissive
use crate::gimli_wrapper; use addr2line::Context; use object::Object; use std::convert::TryInto; use std::{fmt, fs}; #[derive(Debug)] pub enum Error { ErrorOpeningFile, DwarfFormatError(gimli_wrapper::Error), } pub struct DwarfData { files: Vec<File>, addr2line: Context<addr2line::gimli::EndianRcSlice...
true
0f42abc6f5ac362afc3fa88b607452e3ae9f8540
Rust
wasmerio/wasmer
/lib/types/src/entity/primary_map.rs
UTF-8
11,822
3.21875
3
[ "MIT" ]
permissive
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md //! Densely numbered entity references as mapping keys. use crate::entity::boxed_slice::BoxedSlice; use crate::entity::iter::{IntoIter, Iter, IterMut}; use crate::entity::keys::Keys; use cr...
true
f8ae93e3f597746a259eb8647d6c123375c109bd
Rust
simbahebinbo/actix-web-myworld-demo
/src/app/services/user.rs
UTF-8
1,736
2.53125
3
[]
no_license
use rbatis::plugin::page::Page; use validator::Validate; use crate::{models::{pageable::Pageable, user::{User, UserForm}}}; use crate::error::Error; use crate::db::user::UserDB; use crate::utils::hasher::HASHER; pub struct UserService; impl UserService { pub async fn register(&self, uf: &UserForm) -> Result<(), ...
true
1d4a01f31abe383f1f7fb74597c059d00752ac69
Rust
angi2/esprit
/src/context.rs
UTF-8
1,488
2.96875
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::rc::Rc; use token::Name; #[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)] pub enum Mode { Sloppy, Strict, Module } impl Mode { pub fn is_strict(self) -> bool { match self { Mode::Sloppy => false, Mode::Strict ...
true
de1cfc4dcb2e232c93043e063e884006ac8407b1
Rust
msoermc/rmc-core-2018-2019
/src/mechatronics/dumper/tests.rs
UTF-8
4,369
2.78125
3
[]
no_license
use std::sync::Arc; use crate::motor_controllers::test_motor::TestMotor; use super::*; fn setup() -> (Arc<GlobalLifeState>, Arc<GlobalDumperState>, Dumper) { let life = Arc::new(GlobalLifeState::new()); let state = Arc::new(GlobalDumperState::new()); let motor = Box::new(TestMotor::new(state.get_motor())...
true
c4aedbc8bcb4b37f4b67e1babea048b97f3a48e4
Rust
seansfkelley/rt-rs
/src/geometry/triangle_mesh.rs
UTF-8
6,470
3.1875
3
[]
no_license
use std::sync::Arc; use core::*; use math::*; pub type TriangleIndices = (usize, usize, usize); #[derive(Debug)] pub enum Smoothing { None, Implicit, Explicit(Vec<Normal>), } #[derive(Debug)] pub struct TriangleMeshData { pub positions: Vec<Point>, pub indices: Vec<TriangleIndices>, pub norma...
true
f2ae25aee3134697afafd66741b8e093870965ae
Rust
Ethan826/card-chameleon
/src/deck.rs
UTF-8
5,782
2.875
3
[]
no_license
use crate::card::*; use itertools::Itertools; use rand::{Rng, ThreadRng}; pub struct Deck(Vec<Card>); impl std::fmt::Debug for Deck { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self.0.iter().collect::<Vec<_>>()) } } impl Deck { pub fn new() -> Self { ...
true
5f5d44d238b2f6cec9b4f9a7334808b708f9db6c
Rust
risooonho/shipyard
/src/system/mod.rs
UTF-8
2,185
2.921875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
mod all_storages; // mod as_struct; pub use all_storages::AllSystem; use crate::borrow::{Borrow, IntoBorrow}; use crate::error; use crate::world::World; pub struct Nothing; pub trait System<'s, Data, B, R> { fn run(self, data: Data, world: &'s World) -> Result<R, error::GetStorage>; } // Nothing has to be used...
true
74b6a203bdfb1e0c3fa67d2b04795efc59db0237
Rust
knpwrs/learning-rust
/code/c13-03-io-cli-improved/src/lib.rs
UTF-8
2,169
3.71875
4
[]
no_license
use std::fs::File; use std::error::Error; use std::io::prelude::*; use std::env; pub struct Config { needle: String, haystack: String, case_sensitive: bool, } impl Config { pub fn new(mut args: env::Args) -> Result<Config, &'static str> { args.next(); // skip executable name let needle...
true
b609f7a573fd62dbb3b195abc42a772a28e07e67
Rust
nathan-at-least/tokio-childstream
/exoshell/aui/src/rect.rs
UTF-8
536
3.0625
3
[]
no_license
use derive_more::{Constructor, From, Into}; #[derive(Clone, Copy, Debug, From, Into, Constructor)] pub struct Rect<N> where N: Copy, { width: N, height: N, } impl<N> Rect<N> where N: Copy, { pub fn width(&self) -> N { self.width } pub fn height(&self) -> N { self.height ...
true
5814e1a9ab8cc28c97dd37af13e183afc9897332
Rust
mgostIH/dash-rs
/src/request/user.rs
UTF-8
2,724
3
3
[ "MIT" ]
permissive
//! Module containing request definitions for retrieving users use crate::request::{BaseRequest, GD_21}; use serde::Serialize; use std::fmt::{Display, Error, Formatter}; /// Struct modelled after a request to `getGJUserInfo20.php`. /// /// In the geometry Dash API, this endpoint is used to download player profiles fr...
true
d9cdb592f538b6a3caaf058ed7bfa6eb42a1044d
Rust
thommay/rit_save
/src/index/entry.rs
UTF-8
5,589
2.609375
3
[]
no_license
use crate::database::marker::Kind; use crate::utilities::{decode_hex, is_executable, pack_data}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use failure::Error; use std::cmp::{Ord, Ordering}; use std::fs::Metadata; use std::io::{Read, Write}; use std::os::unix::fs::MetadataExt; use std::path::{Ancestors, P...
true
01ccb0246482815bb061ad4440f6558ef69a7fed
Rust
38/d4-format
/d4/src/stab/sparse_array/record_block.rs
UTF-8
9,075
3.0625
3
[ "MIT" ]
permissive
use super::record::Record; use flate2::read::DeflateDecoder; use std::cell::RefCell; use std::io::{Read, Result}; /// The secondary table is represented by a list of record blocks /// Each record blocks carries multiple records. pub(crate) enum RecordBlock<'a, R: Record> { /// The record block is backed by a memor...
true
d2daf34881ef613f6be67ca4713c6cb5175f1503
Rust
CarloMicieli/trenako
/crates/catalog/src/scales/ratio.rs
UTF-8
1,894
3.640625
4
[ "MIT", "Apache-2.0" ]
permissive
use rust_decimal::Decimal; use std::cmp::Ordering; use std::convert::TryFrom; use std::fmt; use std::fmt::{Display, Formatter}; /// It represents the {@code Ratio} between a model railway size /// and the size of an actual train. #[derive(Debug, Eq, PartialEq, Clone)] pub struct Ratio(Decimal); impl TryFrom<Decimal> ...
true
2a658271fdfc60afab5ae91030621b686d9beb43
Rust
uamhforever/rs_illume
/src/core/interaction.rs
UTF-8
14,571
2.546875
3
[ "BSD-3-Clause" ]
permissive
use super::pbrt::{Float, Spectrum, consts::SHADOW_EPSILON}; use super::geometry::{Vector3f, Normal3f, Point2f, Point3f, Ray, offset_ray_origin, dot_normal_vec}; use super::medium::{Medium, MediumInterface, PhaseFunction}; use super::shape::Shape; use super::primitive::Primitive; use super::reflection::BSDF; use super::...
true
f38f3b7deb47b5a7328fad2f555c073f336375f2
Rust
azdavis/advent-of-code
/years/y2016/src/d10.rs
UTF-8
2,726
3.1875
3
[ "MIT" ]
permissive
use helpers::{static_regex, HashMap}; use std::str::FromStr; static_regex!(BOT = r"^bot (\d+) gives low to (\w+) (\d+) and high to (\w+) (\d+)$"); static_regex!(VALUE = r"^value (\d+) goes to bot (\d+)$"); #[derive(Debug, Clone, Copy)] enum Give { Bot, Out, } impl FromStr for Give { type Err = (); fn from_...
true
7418be7fe531f85a0871335fa3e080e3340c6f02
Rust
jhagans3/my-redis-with-tokio
/examples/channels.rs
UTF-8
3,833
3.59375
4
[]
no_license
use bytes::Bytes; use mini_redis::client; use tokio::sync::{mpsc, oneshot}; /// Provided by the requester and used by the manager task to send the command /// response back to the requester. // oneshot - single-producer, single consumer channel. A single value can be sent. type Responder<T> = oneshot::Sender<mini_redi...
true
4f820ba7ac8405e20a7338575eb06d514824caf2
Rust
crossterm-rs/crossterm-style
/src/enums/colored.rs
UTF-8
1,272
3.5625
4
[ "MIT" ]
permissive
use std::fmt::Display; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::color; use crate::enums::Color; /// Represents a foreground or a background color. /// /// Can be used to easily change the text colors. /// /// # Examples /// /// `Colored` implements `Display` therefore you can use it ...
true
e6523198c574fd0e24fd79d016fb549c3e549d01
Rust
mattiasgronlund/cubemx-db-decoder
/examples/dump_db.rs
UTF-8
3,664
2.75
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
#![allow(unused_variables)] #![allow(unused_assignments)] use anyhow::Error; use clap::Clap; use cubemx_db_decoder::{Config, CubeMxDoc}; use log::{error, info}; use std::collections::HashSet; use std::sync::mpsc::channel; use threadpool::ThreadPool; use env_logger::Env; /// Currently only verifies that loading the db...
true
ad646426989ce6c09cd43be3cca2166e5cbde747
Rust
lamaboy2018/ritual
/cpp_utils/src/cmp.rs
UTF-8
713
4.03125
4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
pub trait Lt<Rhs: ?Sized = Self> { /// This method tests less than (for `self` and `other`) and is used by the `<` operator. fn lt(&self, other: &Rhs) -> bool; } pub trait Le<Rhs: ?Sized = Self> { /// This method tests less than or equal to (for `self` and `other`) and is used by the `<=` fn le(&self, ...
true
e92e73b63ee4bdbe94dd06cda647a23d4a9f1b8d
Rust
mavallad/ahorcado_rust
/src/main.rs
UTF-8
3,052
3.140625
3
[]
no_license
mod graphics; mod sound; #[macro_use] extern crate text_io; extern crate colored; use std::io::prelude::*; use std::io; use std::collections::HashSet; use std::env; use colored::*; fn main() { let args: Vec<String> = env::args().collect(); if args.len() != 2 { println!("Invalid parameters ...
true
b60955d9a779439d54ede363e532f4d3ef0f2802
Rust
sogapalag/contest
/atcoder/abc054/d.rs
UTF-8
1,904
2.953125
3
[]
no_license
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::*; #[allow(dead_code)] fn getline() -> String { let mut ret = String::new(); std::io::stdin().read_line(&mut ret).ok(); return ret; } fn get_word() -> String { let mut stdin = std::io::stdin(); l...
true
5e03fc7f9505e6d2606e21c402becb0e60dc6a8d
Rust
mydotey/lang-extension
/rust/src/convert/default/inplace_converter.rs
UTF-8
1,171
2.703125
3
[ "Apache-2.0" ]
permissive
use super::*; #[macro_export] macro_rules! inplace_converter { ($type:ty, $name:ident, $raw_name:ident) => { lazy_static! { pub static ref $name: Box::<InplaceTypeConverter<$type>> = new_inplace_type_converter(); pub static ref $raw_name: Box::<dyn RawTypeConverter> = RawTypeConverter::clo...
true
36156adee474865a9cd57260c4309413501df738
Rust
port-finance/anchor
/lang/syn/src/codegen/accounts/constraints.rs
UTF-8
25,309
2.671875
3
[ "LicenseRef-scancode-warranty-disclaimer", "Apache-2.0" ]
permissive
use crate::*; use proc_macro2_diagnostics::SpanDiagnosticExt; use quote::quote; use syn::Expr; pub fn generate(f: &Field) -> proc_macro2::TokenStream { let constraints = linearize(&f.constraints); let rent = constraints .iter() .any(|c| matches!(c, Constraint::RentExempt(ConstraintRentExempt::...
true
75b058e14ef3983afcaf9df02bd52eff658684cd
Rust
getsentry/symbolicator
/crates/symbolicator-crash/src/lib.rs
UTF-8
2,815
3.078125
3
[ "MIT" ]
permissive
//! Native crash reporting for Symbolicator. //! //! Use [`CrashHandler`] to configure and install a crash handler. use std::path::Path; #[cfg(unix)] mod native { // Code generated by bindgen contains some warnings and also offends the linter. Ignore all of // that since they do not have a consequence on the ...
true
4f76f15bfd68c48eff223f05353ca92a043d9629
Rust
rust-chainblock/blockchain7
/fog/sample-paykit/src/cached_tx_data/memo_handler.rs
UTF-8
4,823
2.6875
3
[]
no_license
// Copyright (c) 2018-2021 The MobileCoin Foundation //! A memo handler object which processes memos, for use in integration tests use displaydoc::Display; use mc_account_keys::{AccountKey, PublicAddress, ShortAddressHash, CHANGE_SUBADDRESS_INDEX}; use mc_common::logger::{log, Logger}; use mc_crypto_keys::{KeyError, ...
true
fca3a75c9d4379a3cfb12a5dbb49e4b0f07ba439
Rust
acoshift/learn-rust
/p03-find-number/src/main.rs
UTF-8
309
3.578125
4
[]
no_license
fn main() { let arr = [1, 2, 5, 3, 2, 7, 8, 9, 2]; let p = find_number(&arr[..], &7); println!("found index {} from {:?}", p, arr); } fn find_number(s: &[i32], p: &i32) -> i32 { for (i, it) in s.iter().enumerate() { if it == p { return i as i32; } } -1 }
true
7f3435c9e3b51e6b01b91c1df99ec5885d26b169
Rust
jameswlee/utuntap
/src/interface/linux.rs
UTF-8
1,677
2.546875
3
[ "MIT" ]
permissive
use libc::{c_int, c_short, c_ulong, IFNAMSIZ}; use std::io::{self, Result}; use std::mem; use std::os::unix::io::RawFd; pub const IFF_TUN: c_short = 0x0001; pub const IFF_TAP: c_short = 0x0002; pub const IFF_NO_PI: c_short = 0x1000; union RequestUnion { flags: c_short, } type Name = [u8; IFNAMSIZ]; #[repr(C)] p...
true
7d89ad6867449fc23bf0a6341dd7616aa7890a7b
Rust
nguyenvanquanthinh97/rust-1
/lifetime_and_memory/src/ownership.rs
UTF-8
922
3.71875
4
[]
no_license
// Only a single variable kind of owns the memory at any given time pub fn main() { let v = vec![1,2,3]; // let v2 = v; // because v2 has already take ref value of v => v is invalid to access // println!("{:?}", v); let foo = |x:Vec<i32>| {}; // foo(v); // v has been borrowed by foo function // print...
true
12c6d09b505282aa90c9b2e182b3f4e81d1ed09a
Rust
BielosX/rust-pong
/build.rs
UTF-8
1,043
2.625
3
[]
no_license
extern crate reqwest; extern crate zip; use std::env; use std::fs::File; use std::io::Write; use std::fs::create_dir_all; use std::fs::OpenOptions; fn main() { let profile = env::var("PROFILE").unwrap(); let download_link = "https://www.1001freefonts.com/d/5722/lato.zip"; let mut bytes = reqwest::blocking...
true
d21b58ea186a4ff30e13b73110ce8846e20d0594
Rust
Grouter/ram
/src/token.rs
UTF-8
1,913
3.71875
4
[]
no_license
use std::fmt::Display; use regex::Regex; const PATTERN: &str = r"([A-Z]+)( ?)(=?[0-9]+|[a-zA-Z]+|:|)"; #[derive(PartialEq, Eq)] pub enum TokenType { Operation, Value, Label, } impl Display for TokenType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match *self { ...
true
97d465be693210bf2f0d6ff1e38cc050459c0edb
Rust
mnilsson/m68k
/src/decoder.rs
UTF-8
20,308
2.875
3
[]
no_license
use addressing_mode::{decode_addressing_mode, AddressingMode, DataSize, DataSizeIdentifier}; use instruction_set::Instruction; pub fn decode(opcode: usize) -> Instruction { let part1 = opcode >> 12; let part2 = (opcode >> 6) & 0b111111; let part3 = opcode & 0b111111; let part2h = (part2 & 0b111000) >>...
true
cd5ac5cff44b3f994bede4c862fe3d9024b31894
Rust
leod/bit_manager
/src/data.rs
UTF-8
10,648
3.640625
4
[ "MIT" ]
permissive
//! Provides methods for reading and writing data both directly //! (using [`BitStore`]) and indirectly //! (using [`BitConvert`]). //! //! [`BitStore`]: http://docs.rs/bit_manager/0.5.3/bit_manager/data/trait.BitStore.html //! [`BitConvert`]: http://docs.rs/bit_manager/0.5.3/bit_manager/data/trait.BitConvert.html use...
true
aa4df8a19ba3b72b01b4cda2f978e206b2f29f5c
Rust
whoisjg/alone_in_dark
/src/components/light.rs
UTF-8
485
3
3
[]
no_license
use crate::constants::*; use specs::prelude::*; #[derive(Component, Debug, Clone)] pub struct Light { pub radius: f32, pub color: raylib::Color, } impl Light { pub const fn new(radius: f32, color: raylib::Color) -> Self { Light { radius, color } } /// light power at a distance pub fn p...
true
36a8ac2335d3fa4c25f71177015eb26ffeee1a68
Rust
samdoiron/butter
/src/main.rs
UTF-8
8,237
2.578125
3
[]
no_license
#![warn(rust_2018_idioms)] use git2::{ObjectType, Oid, Repository}; use anyhow::{bail, Context, Result}; use chrono::{Duration, Local}; use clap::Clap; use std::collections::BTreeMap; use std::{ path::{Path, PathBuf} }; #[derive(Debug)] struct DirectoryNode { last_revision: Oid, children: BTreeMap<Vec<u...
true
93009512064f938e23c9dbdce192d3a32c346c51
Rust
ncoif/advent-2017
/src/day14.rs
UTF-8
3,447
3.046875
3
[]
no_license
use crate::day10; pub fn title() -> &'static str { "Day 14: Disk Defragmentation" } fn from_char_count_ones(c: char) -> u32 { match c { '0' => 0, //0000 '1' => 1, //0001 '2' => 1, //0010 '3' => 2, //0011 '4' => 1, //0100 '5' => 2, //0101 '6' => 2, //0110...
true
e4eb9a68902475fb3ff0b271f071bb544e68df60
Rust
CBenoit/nushell
/crates/nu-command/src/conversions/into/duration.rs
UTF-8
20,062
2.6875
3
[ "MIT" ]
permissive
use nu_engine::CallExt; use nu_parser::parse_duration_bytes; use nu_protocol::{ ast::{Call, CellPath, Expr}, engine::{Command, EngineState, Stack}, Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Unit, Value, }; #[derive(Clone)] pub struct SubCommand; impl Command f...
true
93dadae0c3002809fb8964d1612cd0d0a114b90a
Rust
tomhoule/rust-experiment
/src/language_server.rs
UTF-8
6,524
2.71875
3
[]
no_license
use slog::Logger; use std::process::{Child, Command}; use std::io::{Read, Write}; use std::marker::PhantomData; use supported_languages::SupportedLanguage; use neovim::NeovimRPCEvent; use requests::*; use futures::{Async, Future, Poll}; use futures::stream::{Stream, BoxStream, Filter, empty}; use std::sync::mpsc; use s...
true
81a8fe509f5369162e50222478c5f914b16b6672
Rust
ryo33/cdb-rust
/src/figure.rs
UTF-8
421
2.65625
3
[ "MIT" ]
permissive
use graphics::math::{ Scalar, Matrix2d }; use piston_window::{ G2d }; use graphics; pub fn circle(x: Scalar, y: Scalar, r: Scalar, color: [f32; 4], t: Matrix2d, g: &mut G2d) { graphics::ellipse(color, [x - r, y - r, r * 2., r * 2.], t, g); } pub fn rect(x: Scalar, y: Scalar, width: Scalar, height: Scalar, color: ...
true
92a269de1b11327a1fb11e785f1a98459a345682
Rust
will14smith/rlox
/rlox-parser/src/stmt.rs
UTF-8
707
2.671875
3
[]
no_license
use rlox_scanner::SourceToken; use crate::Expr; #[derive(Clone, Debug, PartialEq)] pub enum Stmt { Block(Vec<Stmt>), Class(SourceToken, Vec<Func>), Expression(Expr), Function(Func), If(Expr, Box<Stmt>, Option<Box<Stmt>>), Print(Expr), Return(SourceToken, Option<Expr>), Var(SourceToken, ...
true
a11cd6b17bcaedb46ce9e63c8646cad8bfcbb299
Rust
izderadicka/alphametics
/src/lib.rs
UTF-8
8,613
3.0625
3
[]
no_license
use fastmap::{FastMap, FastSet}; use std::collections::HashMap; mod fastmap; pub mod other; #[derive(Debug)] struct Column<'a> { left: Vec<u8>, right: u8, letters: FastSet, leading_letters: &'a FastSet, } impl<'a> Column<'a> { fn evaluate(&self, mapping: &FastMap, carry: u32) -> Option<u32> { ...
true
25bdffd9a02d7ff00fc2a1da346c873db8747825
Rust
mattnenterprise/rust-box2d
/examples/bouncing_circle.rs
UTF-8
5,623
2.640625
3
[ "MIT" ]
permissive
extern crate sfml; extern crate box2d; extern crate time; use sfml::system::Vector2f; use sfml::window::{ContextSettings, VideoMode, event, window_style}; use sfml::graphics::{RenderWindow, RenderTarget, CircleShape, Color, Vertex, Shape, Transformable, Lines, LinesStrip, VertexArray}; use box2d::world::World; use bo...
true
fb00c4e3219c6fedc0b649a6bbe9108005566a81
Rust
provable-things/ptokens-core
/src/chains/evm/get_linker_hash.rs
UTF-8
1,354
2.828125
3
[]
no_license
use crate::{ chains::evm::{ eth_constants::PTOKEN_GENESIS_HASH_KEY, eth_database_utils::get_eth_linker_hash_from_db, eth_types::EthHash, }, traits::DatabaseInterface, types::Result, }; pub fn get_linker_hash_or_genesis_hash<D: DatabaseInterface>(db: &D) -> Result<EthHash> { ...
true
344d9236a44c64b6eacb42f82b456196804dedf5
Rust
BroderickCarlin/embedded-graphics
/simulator/src/lib.rs
UTF-8
4,482
3.5625
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! ![It can display all sorts of embedded-graphics test code.](https://raw.githubusercontent.com/jamwaffles/embedded-graphics/master/assets/simulator-demo.png) //! //! The simulator can be used to test and debug //! [embedded-graphics](https://crates.io/crates/embedded-graphics) code, or produce examples and //! inter...
true
657ae5fabfbdd8622073d51bf9863d8bf3a4d11c
Rust
math-fehr/lucyrs
/src/ident.rs
UTF-8
1,523
3.75
4
[]
no_license
//! The module contains IdentGenerator, which is used to generate new identifiers use std::cell::RefCell; use std::rc::Rc; /// Struct used to generate new identifiers based an a base one /// For identifier a, the identifiers generated will be: /// a_, a_0, a_1, ... #[derive(Debug, Clone)] pub struct IdentGenerator { ...
true
4469b7b19aaf56c161d0774d9d51388a364759d4
Rust
E-Neo/tapl
/src/tyarith/checker.rs
UTF-8
1,155
3.28125
3
[]
no_license
use crate::arith::AstNode; use derive_more::{Display, Error}; #[derive(Debug, Display, PartialEq)] pub enum Type { Bool, Nat, } #[derive(Debug, Display, Error)] pub enum Error { TypeError, } pub fn type_of(ast: &AstNode) -> Result<Type, Error> { match ast { AstNode::True | AstNode::False => O...
true