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
4931955609689bc4a1ce327f3ef32e90cf55bcb9
Rust
Caluka/CHIP8
/src/kb.rs
UTF-8
4,383
2.859375
3
[]
no_license
use winit::event::VirtualKeyCode; use winit::event_loop::ControlFlow; use winit_input_helper::WinitInputHelper; pub struct Keyboard { pub keys: [bool; 16], pub register: u8, } impl Keyboard { pub fn new() -> Self { Self { keys: [false; 16], register: 0, ...
true
3dec0d7b0e4ece7b8bb1c82f44efbef9788a2690
Rust
mdm/adventofcode2020
/day23/src/main.rs
UTF-8
4,940
3.140625
3
[]
no_license
use std::{collections::HashMap, io::BufRead}; fn play_game_naive(mut cups: Vec<u32>, iterations: u32) -> Vec<u32> { let min_label = cups.iter().copied().min().unwrap(); let max_label = cups.iter().copied().max().unwrap(); let mut current_index = 0; let mut current_label = cups[current_index]; for ...
true
1613544bce8ba46514c7f2c23bc3fa053d47ee4f
Rust
danielhuang/aoc-2020
/src/bin/6.rs
UTF-8
634
2.734375
3
[]
no_license
#![feature(iterator_fold_self)] use std::collections::HashSet; #[util::bench] fn main() -> (usize, usize) { let input = include_str!("6.txt"); let texts: Vec<_> = input.split("\n\n").collect(); let p1 = texts .iter() .copied() .map(|x| { x.lines() .map(|x| x.chars().collect::<HashSet<_>>()) .fold...
true
cf1c5b7802d65dcd386e10cbe9e51e17e15a07c8
Rust
pourplusquoi/learn-rust
/leetcode/1361.rs
UTF-8
1,258
2.875
3
[]
no_license
impl Solution { pub fn validate_binary_tree_nodes( n: i32, left_child: Vec<i32>, right_child: Vec<i32>) -> bool { let mut prev = Vec::new(); for i in 0..n { prev.push(i); } for i in 0..n { let left_child = left_child[i as usize]; let right_child = right_child[i as usize]; ...
true
f02cbb4cbc2551e28dc9e1b4d3e5abdcbe3b192e
Rust
zmilan/runner-server
/src/db_connection.rs
UTF-8
355
2.578125
3
[]
no_license
use std::env; use diesel::prelude::*; use dotenv::dotenv; pub fn establish_connection() -> MysqlConnection { // 加载.env文件 dotenv().ok(); let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set in env"); MysqlConnection::establish(&database_url).expect(&format!("Can not connec...
true
42ec928475cb79f8f283bf6ee8d2e640c6cb98b9
Rust
Leinnan/doppler
/src/imgui_helper.rs
UTF-8
2,107
2.9375
3
[ "MIT" ]
permissive
use cgmath::{Point3, Vector3}; use imgui; use imgui_inspect::InspectArgsDefault; use imgui_inspect::InspectRenderDefault; pub struct CgmathPoint3f32; pub struct CgmathVec3f32; impl InspectRenderDefault<Vector3<f32>> for CgmathVec3f32 { fn render( data: &[&Vector3<f32>], label: &'static str, ...
true
54950efc86052eb35af0301bf2d62a05fbbeb15c
Rust
NovatecConsulting/kitchen-kata-async-rust
/src/food.rs
UTF-8
2,385
3.1875
3
[]
no_license
use std::collections::VecDeque; use std::{fmt, fmt::Display}; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum CookingStep { Cut, Spice, Bake, Grill, Peel, } pub static COOKING_STEPS: [CookingStep; 5] = [ CookingStep::Cut, CookingStep::Spice, CookingStep::Bake, CookingStep::Gr...
true
e8bd6043f9e3a1fe100dbf246331b81a8e4c008e
Rust
bburdette/oscpad
/example_projects/guisend/src/tryopt.rs
UTF-8
996
3
3
[ "MIT" ]
permissive
#[macro_export] macro_rules! try_opt { ($e: expr) => { match $e { Some(x) => x, None => return None } } } #[macro_export] macro_rules! try_opt_resbox { ($e: expr, $s: expr) => { match $e { Some(x) => x, None => return Err(stringerror::string_box_err($s)), ...
true
930514a2f1e019326b5ae6a4670e5e996cd31f22
Rust
rustic-games/prototype
/src/error.rs
UTF-8
603
3.21875
3
[]
no_license
//! The module keeping track of the possible game errors. use std::error::Error; use std::fmt; /// All possible error states the game can end up in. #[derive(Debug)] pub(crate) enum GameError { Unknown, } impl Error for GameError { fn source(&self) -> Option<&(dyn Error + 'static)> { use GameError::*...
true
62c380c88722e6caee48edbc9bba896d752265bd
Rust
cgaebel/mio
/test/test_echo_server.rs
UTF-8
5,135
2.65625
3
[]
no_license
use mio::*; use super::localhost; use std::cell::Cell; use std::mem; use std::rc::Rc; struct EchoServer { num_msgs: uint } impl EchoServer { fn new(num_msgs: uint) -> EchoServer { EchoServer { num_msgs: num_msgs } } } impl PerClient<()> for EchoServer { fn on_read(&mut sel...
true
1b77fa34a1047271ecd7ab9d84ba8dff516f1f80
Rust
jayrave/android_localization
/core/src/localized_string.rs
UTF-8
950
3.234375
3
[ "Apache-2.0" ]
permissive
#[derive(Clone, Debug, PartialEq)] pub struct LocalizedString { name: String, default: String, localized: String, } impl LocalizedString { pub fn new(name: String, default: String, localized: String) -> LocalizedString { LocalizedString { name, default, local...
true
10b9c049ce2aac13790f285de07d714f318bfd87
Rust
CatLava/rust_webpage
/src/http/request.rs
UTF-8
3,916
3.484375
3
[]
no_license
use super::method::{Method, MethodError}; use std::convert::TryFrom; use std::error::Error; use std::fmt::{Result as FmtResult, Display, Formatter, Debug}; use std::str; use std::str::Utf8Error; use super::{QueryString, QueryStringValue}; // we are adding lifetimes to this struct, the pub struct // this case the buff...
true
7934085af626e1f29335eba31b4422b07232787b
Rust
Ningsir/GraphScope
/interactive_engine/executor/store/src/db/api/entity.rs
UTF-8
1,189
2.6875
3
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla", "BSL-1.0", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-elastic-license-2018", "LicenseRef-scancode-other-permissive" ]
permissive
use std::marker::PhantomData; use super::{VertexId, LabelId, PropId, EdgeId, EdgeKind, ValueRef}; pub trait Vertex: std::fmt::Debug { type PI: PropIter; fn get_id(&self) -> VertexId; fn get_label(&self) -> LabelId; fn get_property(&self, prop_id: PropId) -> Option<ValueRef>; fn get_properties_iter(...
true
cbbfb0be653d849226047136e600f0c1355f5d25
Rust
dmolokanov/iotedge-aad
/src/context.rs
UTF-8
852
2.890625
3
[ "MIT" ]
permissive
use crate::Result; use config::{Config, File}; use serde::Deserialize; use std::path::Path; #[derive(Clone, Debug, Deserialize)] #[serde(rename_all(deserialize = "camelCase"))] pub struct Context { client_id: String, cert: String, tenant_id: String, } impl Context { pub fn from(path: &Path) -> Result<...
true
c48e44b5af82a90c530e38d512360e093c498c41
Rust
tkocmathla/advent-of-code
/year2021/src/lib.rs
UTF-8
201
2.53125
3
[]
no_license
pub mod io { pub fn read_input(day: i32) -> String { let input = std::fs::read_to_string(format!("src/res/day{}.txt", day)).unwrap(); return String::from(input.trim_end()); } }
true
92434bbe78f79665844cd3566a9025f36f3a871b
Rust
finos/perspective
/rust/perspective-viewer/src/rust/session/view.rs
UTF-8
5,594
2.796875
3
[ "Apache-2.0" ]
permissive
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄...
true
5b08e6580548092c328571c9dc046a9eac335a5a
Rust
lespea/aoc2019
/intcode/src/lib.rs
UTF-8
443
2.546875
3
[]
no_license
use crossbeam::unbounded; use crossbeam::Receiver; use crossbeam::Sender; pub type Bit = i64; pub fn bit_from_bool(b: bool) -> Bit { if b { 1 } else { 0 } } pub fn chan_pair(start_ins: &[Bit]) -> (Receiver<Bit>, Sender<Bit>) { let (send, recv) = unbounded(); for i in start_ins { ...
true
b6532915750fc4cc1afac8b9eee94321274325f0
Rust
cmsd2/rogue1
/src/input.rs
UTF-8
5,345
3.078125
3
[ "MIT", "LicenseRef-scancode-ubuntu-font-1.0" ]
permissive
use std::collections::HashMap; use std::collections::hash_map::Entry; use piston::input::*; use piston::input::keyboard::ModifierKey; #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct KeyboardKey { pub button: Button, pub scancode: Option<i32>, } impl From<ButtonArgs> for Keyboard...
true
aeac6f88ed4b6992a60fa993caa02cfb1229c835
Rust
AdrienChampion/fast_expr
/fast_expr_gen/src/front.rs
UTF-8
4,721
3.046875
3
[ "Apache-2.0" ]
permissive
//! Frontend representation of an expression type and its sub-expressions. use syn::{ parse::{Parse, ParseStream}, punctuated::Punctuated, }; prelude! {} /// Keywords of the fast-expr DSL. pub mod keyword { syn::custom_keyword! { // Keyword indicating the start of a spec trait. spec }...
true
f83635bbfcdec8ae7622a7503ded7609f8b65393
Rust
lucarge/rust-playground
/ch03/src/main.rs
UTF-8
129
3.359375
3
[]
no_license
fn plus_one(x: i32) -> i32 { x + 1 } fn main() { let result = plus_one(5); println!("The result is {}", result); }
true
d61518cfcedebc4a8cb5affbbeb936ad7f41e779
Rust
gleroi/dojo
/rust/pacman/src/game.rs
UTF-8
11,064
2.96875
3
[]
no_license
extern crate rand; use self::rand::{Rng, SeedableRng, StdRng}; use self::rand::distributions::{IndependentSample, Range}; use std; use map::*; use ai; #[derive(PartialEq, Clone, Debug)] pub struct Position { pub x: i32, pub y: i32, } impl Position { pub fn new(x: i32, y: i32) -> Position { Pos...
true
0f3a5f7c5b66cd755293ba179f42a33afc527a55
Rust
bytecodealliance/wasmtime
/examples/tokio/main.rs
UTF-8
3,677
3.1875
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
use anyhow::Error; use std::sync::Arc; use tokio::time::Duration; use wasmtime::{Config, Engine, Linker, Module, Store}; // For this example we want to use the async version of wasmtime_wasi. // Notably, this version of wasi uses a scheduler that will async yield // when sleeping in `poll_oneoff`. use wasmtime_wasi::{t...
true
e650746b1b8a1b570747e4956ab7e2fa7fce99d8
Rust
Michael-F-Bryan/cargo-edit
/src/bin/add/args.rs
UTF-8
12,276
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
//! Handle `cargo add` arguments use cargo_edit::{find, registry_url, Dependency}; use cargo_edit::{get_latest_dependency, CrateName}; use semver; use std::path::PathBuf; use structopt::StructOpt; use crate::errors::*; #[derive(Debug, StructOpt)] #[structopt(bin_name = "cargo")] pub enum Command { /// Add depend...
true
6a71a5e58625519d49dbbb49c4393ac633f1da50
Rust
fussybeaver/bollard
/examples/exec_term.rs
UTF-8
3,205
2.90625
3
[ "Apache-2.0" ]
permissive
//! This example will run a interactive command inside the container using `docker exec`, //! passing trough input and output into the tty running inside the container use bollard::container::{Config, RemoveContainerOptions}; use bollard::Docker; use bollard::exec::{CreateExecOptions, ResizeExecOptions, StartExecResu...
true
3ff3aa989073d6fbe8d1647257d0c9b694299e99
Rust
jolestar/starcoin
/network/api/src/peer_provider.rs
UTF-8
6,370
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::PeerId; use crate::PeerInfo; use anyhow::Result; use futures::future::BoxFuture; use futures::{FutureExt, TryFutureExt}; use itertools::Itertools; use rand::prelude::IteratorRandom; use rand::prelude::SliceRandom; use sta...
true
fdcdc9f9a638625a665f940b4767045e075a20b4
Rust
csssuf/slackfm-rs
/src/db/mod.rs
UTF-8
1,632
2.609375
3
[]
no_license
use std::env; use std::ops::Deref; #[cfg(feature = "postgres")] use diesel::pg::PgConnection; #[cfg(feature = "sqlite")] use diesel::sqlite::SqliteConnection; use r2d2; use r2d2_diesel::ConnectionManager; use rocket::http::Status; use rocket::request::{self, FromRequest}; use rocket::{Request, State, Outcome}; pub mo...
true
697684fece3f47b3da3958ded857c19f84b07a19
Rust
aki-ks/mineroute
/src/net/connection.rs
UTF-8
1,552
2.640625
3
[]
no_license
use std::rc::Rc; use std::sync::RwLock; use actix::AsyncContext; use actix::io::SinkWrite; use tokio::net::TcpStream; use crate::net::{Protocol, ConnectionType}; use crate::net::pipeline::{HandlerPipeline, PipelineSink}; use crate::net::manager::ConnectionManager; /// A connection to a remote minecraft server or clien...
true
753b49c70152692557f6276498f840aeb45d8ebf
Rust
thomas9911/big_int
/src/error.rs
UTF-8
2,416
3.234375
3
[]
no_license
use crate::Sign; pub type Result<T> = std::result::Result<T, Error>; #[derive(Debug, PartialEq)] pub enum Error { IntegerError(IntegerError), ParseError(ParseError), OperatorError(OperatorError), } impl std::fmt::Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {...
true
b786f09ea2a48115b12c1495eccb13e905d20e69
Rust
udoprog/async-injector
/tests/complex_tag.rs
UTF-8
409
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(unused)] use async_injector::Provider; #[derive(serde::Serialize)] pub enum Tag { A, } #[derive(Provider)] struct TestTagged { fixed: String, #[dependency(tag = "bar")] tag0: String, #[dependency(tag = TestTagged::bar_tag(&fixed))] tag1: String, #[dependency(tag = 42)] tag2: ...
true
1dff6fa056fbf5eec9b72a4100baa58c19560c7c
Rust
andersengqvist/open_kattis
/rust/k1_5-6/src/bin/hangman.rs
UTF-8
1,343
3.515625
4
[]
no_license
use std::collections::HashSet; use std::io; fn main() -> Result<(), std::io::Error> { let mut word = String::new(); io::stdin().read_line(&mut word)?; let mut permutation = String::new(); io::stdin().read_line(&mut permutation)?; if guess(word.trim_end(), permutation.trim_end()) { println!...
true
cd5942e16596eb29e67a0e5864a1d2c2003c062e
Rust
ggriffiniii/lateral
/src/cmds/wait.rs
UTF-8
1,027
2.6875
3
[ "MIT" ]
permissive
use crate::{resp, Error, GlobalOpts, Req}; use std::os::unix::net::UnixStream; /// Options for the wait subcommand. #[derive(StructOpt, Debug)] pub struct Opts { #[structopt(short = "n")] no_shutdown: bool, } pub fn execute(global_opts: &GlobalOpts, opts: &Opts) -> Result<(), Error> { debug!("wait command...
true
bcae35e0b842debf230ee11ca39f937a7d97380f
Rust
mrknmc/advent-of-code-2018
/src/bin/day03-part2.rs
UTF-8
1,856
2.9375
3
[]
no_license
extern crate regex; use std::env; use std::fs::File; use std::io::BufReader; use std::io::BufRead; use std::collections::HashMap; use std::collections::HashSet; use regex::Regex; #[derive(Debug)] struct Patch { id: u64, x: u64, y: u64, w: u64, h: u64, } impl Patch { fn points(&self) -> Vec<(u...
true
9021f4884e865013b1887d8f2186657c518ff9f4
Rust
rusty-ecma/RESS
/src/lib.rs
UTF-8
30,790
3.0625
3
[ "MIT" ]
permissive
//! ress //! A crate for parsing raw JS into a token stream //! //! The primary interfaces are the function [`tokenize`][tokenize] and //! the struct [`Scanner`][scanner]. The [`Scanner`][scanner] struct impls [`Iterator`](https://doc.rust-lang.org/std/iter/trait.Iterator.html) //! and the [`tokenize`][tokenize] functi...
true
756c0d1a931b17e99c5d8020225564a528d6a07d
Rust
Andlon/rulinalg
/src/macros.rs
UTF-8
1,362
3.390625
3
[ "MIT" ]
permissive
//! Macros for the linear algebra modules. macro_rules! count { () => (0usize); ( $x:tt $($xs:tt)* ) => (1usize + count!($($xs)*)); } /// Should be able to do the following: /// /// # Specification /// /// ``` /// let a = mat![1,2,3] // 1 row, 3 cols /// let b = mat![1;2;3] // 3 rows, 1 col /// let c = mat![1...
true
7a425f653d1f9f387f0ea1f61219a43f40181e93
Rust
MindFlavor/azure-sdk-for-rust
/sdk/security_keyvault/src/secret.rs
UTF-8
24,241
2.6875
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use crate::client::API_VERSION_PARAM; use crate::Error; use crate::KeyClient; use azure_core::TokenCredential; use chrono::serde::{ts_seconds, ts_seconds_option}; use chrono::{DateTime, Utc}; use const_format::formatcp; use getset::Getters; use reqwest::Url; use serde::Deserialize; use serde_json::{Map, Value}; const...
true
a03b01f6edc9c178a7dc90ab93d8b1e7866dc386
Rust
zhxiaogg/dylib-pack
/src/main.rs
UTF-8
760
2.6875
3
[]
no_license
mod dylib; use std::env; use std::fs; use std::path::Path; fn main() { let args:Vec<String> = env::args().collect(); let file = &args[1].trim(); let libs_dir = &args[2].trim().trim_right_matches("/"); let libs_prefix = &args[3].trim().trim_right_matches("/"); // create libs dir if not existed ...
true
65e3b02a70332bd7c668cb3fc40eec050853621e
Rust
drewet/name-my-indie-game-please
/shared/src/network/channel.rs
UTF-8
3,317
3
3
[]
no_license
use std; use std::collections::{Deque, RingBuf}; use std::io::IoResult; pub type SequenceNr = u32; pub fn overflow_aware_compare(a: SequenceNr, b: SequenceNr) -> std::cmp::Ordering { use std::cmp::{max, min}; let abs_difference = max(a, b) - min(a, b); if abs_difference < std::u32::MAX / 2 { ...
true
54d30be3e5100892205597f10e389d224dd1cbce
Rust
klaxit/heroku_rs
/src/endpoints/builds/mod.rs
UTF-8
4,387
2.765625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::framework::response::ApiResult; use serde::Deserialize; pub mod delete; pub mod get; pub mod patch; pub mod post; pub mod put; pub use delete::BuildDelete; pub use get::{BuildDetails, BuildList, BuildPackInstallationList}; pub use post::{BuildCreate, BuildCreateParams, BuildpackParam, SourceBlobParam}; pub...
true
f293d9bfa4faf3fa67bbdae2c60d2e92677eddce
Rust
flaminggoat/embedded-graphics-menu
/src/lib.rs
UTF-8
7,653
2.78125
3
[]
no_license
#![no_std] use embedded_graphics::draw_target::DrawTarget; use embedded_graphics::fonts::Font; use embedded_graphics::fonts::{Font6x8, Text}; use embedded_graphics::geometry::Size; use embedded_graphics::pixelcolor::PixelColor; use embedded_graphics::prelude::*; use embedded_graphics::primitives::Rectangle; use embedd...
true
274e34facdf5d7d9bb07199c71033ac15e35d856
Rust
mdzik/hyperqueue
/crates/hyperqueue/src/server/autoalloc/descriptor/common.rs
UTF-8
959
2.546875
3
[ "MIT" ]
permissive
use bstr::ByteSlice; use std::path::PathBuf; use std::process::Output; use std::time::Duration; use crate::server::autoalloc::AutoAllocResult; pub fn create_allocation_dir( server_directory: PathBuf, name: &str, ) -> Result<PathBuf, std::io::Error> { let mut dir = server_directory; dir.push("autoalloc...
true
e3d6596e0e1208b33826b28d1709282f37ff95c0
Rust
dogunyoye/advent-of-code-2018
/src/bin/day_18.rs
UTF-8
8,532
3.296875
3
[ "Apache-2.0" ]
permissive
//! `cargo run --bin day_18` use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Clone, Debug)] struct Acre { current: char, next: char } struct Point { x: i32, y: i32 } fn build_initial_grid() -> Vec<Vec<Acre>> { let default = Acre { current: '?', next: '?' }; let grid_size = 50;...
true
3e0d6b8551282d3c6423b8158599e15c65054262
Rust
dwalker109/aoc-2015
/day11/src/password.rs
UTF-8
2,016
3.390625
3
[]
no_license
use std::fmt::Display; #[derive(Debug)] pub struct Password { raw: [u8; 8], } impl Password { pub fn from(input: &str) -> Password { let mut raw: [u8; 8] = [0; 8]; for (i, &digit) in input.as_bytes().iter().enumerate() { raw[i] = digit; } Password { raw } } ...
true
35906756f2baa9ac277272ab1a92f6a1c8b0ffa3
Rust
1aim/state_machine_future
/tests/private_type_in_description.rs
UTF-8
924
2.578125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Test that we don't leak private types in public API. #![feature(futures_api, pin, arbitary_self_types)] extern crate futures; #[macro_use] extern crate state_machine_future; use futures::Poll; use state_machine_future::RentToOwn; struct PrivateType; // Should not get this error: // // error[E0446]: private type...
true
a00db6166c767f60ebac157882772af4ed6384b3
Rust
VoxWave/dungenon-rs
/src/level/test.rs
UTF-8
2,079
2.953125
3
[ "MIT" ]
permissive
use Vector; use super::Hitbox; #[test] fn circle_circle_collision() { let circle1 = Hitbox::Circle(Vector::new(0., 0.), 1.); let circle2 = Hitbox::Circle(Vector::new(1.9, 0.), 1.); let circle3 = Hitbox::Circle(Vector::new(2.,2.), 1.); assert!(circle1.collides(&circle2)); assert!(circle2.collides(...
true
0c7c450b69177772284a92da1db48b1ff40f64be
Rust
zehreken/nannou-cc
/src/sketches/a5/mod.rs
UTF-8
1,672
2.59375
3
[]
no_license
use super::sketch_utils::*; use nannou::prelude::*; const TITLE: &str = "a5"; pub fn start_a5() { nannou::app(model).run(); } struct Model { window_id: WindowId, } fn model(app: &App) -> Model { let window_id = app .new_window() .size(512, 512) .key_pressed(key_pressed) ....
true
ecd41626aaae1d55bed313a1ee971139e159c5cd
Rust
lewiszlw/hello-world
/hello-world-rust/src/lang/references.rs
UTF-8
818
4.21875
4
[]
no_license
// 引用(reference)像一个指针,因为它是一个地址,我们可以由此访问储存于该地址的属于其他变量的数据。 // 与指针不同,引用确保指向某个特定类型的有效值。 fn main() { let s1 = String::from("hello"); let len = calculate_length(&s1); println!("The length of '{}' is {}.", s1, len); let mut s2 = String::from("hello"); change(&mut s2); println!("changed s2: {}", s2); ...
true
4824caba04c2a025d1bd2095c9ee4d256ab1dba2
Rust
MarimeGui/fancy_read
/src/lib.rs
UTF-8
1,842
2.84375
3
[]
no_license
use std::io::Read; use std::mem::transmute; pub fn read_to_u8<R: Read>(reader: &mut R) -> u8 { let mut temp: [u8; 1] = [0]; reader.read_exact(&mut temp[..]).expect("Failed to read"); temp[0] } pub fn read_le_to_u16<R: Read>(reader: &mut R) -> u16 { let mut temp: [u8; 2] = [0; 2]; reader.read_exac...
true
3fb48a61efa8869461a5bb4e0b2af0410212809e
Rust
jchambers/clarus
/src/binhex/mod.rs
UTF-8
1,064
2.625
3
[]
no_license
//! Tools for extracting data from BinHex 4.0 archives. //! //! BinHex is an encoding system for "classic" Mac files that combines the binary data from a file's //! data and resource forks into a single ASCII-encoded file. BinHex was generally used to transfer //! files via email or online services that didn't have rob...
true
d1a38f5eb4712b56b222f5c4abcaa144c34bb931
Rust
cronosun/abin
/abin/src/implementation/reference_counted/data.rs
UTF-8
6,507
2.828125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::{mem, slice}; use crate::spi::{BinData, UnsafeBin}; use crate::{Bin, DefaultExcessShrink, RcCounter, RcDecResult, RcMeta, RcUtils}; #[repr(C)] pub struct RcData<TCounter: RcCounter> { /// pointer to the data. Note: This is not always the same as the vector data (if you /// slice the rc-data this mig...
true
59a1a1a2a042d2c30520382d00c4973a373458c7
Rust
mindbeam/mindbase
/crates/fuzzyset/tests/basic.rs
UTF-8
4,396
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
use std::f32::INFINITY; use fuzzyset::{fuzzyset::FuzzySet, test_util::SimpleMember}; #[test] fn basic_vector_space() { // This example illustrates a self-coherant vector space similar to that created by word2vec. // In such a scenario, weights are determined by a neural network hidden layer which is trained ...
true
f04acd257d6c7d256db6afac163e2c095bb6d7d2
Rust
pchampin/sophia_rs
/api/src/ns/_term.rs
UTF-8
2,683
3.609375
4
[ "LicenseRef-scancode-cecill-b-en", "CECILL-B" ]
permissive
use super::*; use crate::term::{Term, TermKind}; /// A [`Term`] produced by a [`Namespace`]. /// /// The raison d'être of this type, compared to [`IriRef<&str>`], /// is that it stored the IRI in two parts (namespace and suffix), /// so that the namespace can be reused by multiple distinct terms. /// /// It makes sens...
true
130fab71e415454dec1ec57da10c63331c85ed82
Rust
Mvdboon/ScalingUpStayingSecure
/Experimentation/src/parse/functions.rs
UTF-8
3,873
2.578125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::{Path, PathBuf}; use csv::Writer; use flate2::read::GzDecoder; use flate2::write::GzEncoder; use flate2::Compression; use serde::Serialize; use crate::creator::Context; use crate::parse::structs::{ReservePower, *}; pub fn output_csv_gz<Row: Seriali...
true
4da0b8fa6049ad03e581f7a3a2bf1619bdd8f9e5
Rust
tylerwhall/rmp-rpc
/examples/server.rs
UTF-8
2,952
3.328125
3
[ "MITNFA" ]
permissive
//! Here is an simple example with a pure server. A "pure" server cannot send requests or //! notifications, and only handles incoming requests and notifications. `rmp-rpc` makes it //! possible to have a server that also act as a client and is able to send requests and //! notifications to the remote endpoint. extern ...
true
4932e817df9590b31dc619091b5e4e14dfc9a1e2
Rust
fabriziomello/postgres-parser
/tests/scanner-tests.rs
UTF-8
5,062
3
3
[]
permissive
use postgres_parser::{ScannedStatement, SqlStatementScanner}; #[test] fn test_no_statements() { let mut statements = SqlStatementScanner::new("").into_iter(); assert!(statements.next().is_none()) } #[test] fn test_only_whitespace() { let mut statements = SqlStatementScanner::new(" \n\r\n\t ").into_ite...
true
43e45210a1a4980fed39b73375869dfdd8abd24b
Rust
MarkSort/auth-spec
/src/checker.rs
UTF-8
11,871
2.78125
3
[]
no_license
use hyper::{Body, Method, Request, Response, StatusCode}; pub struct Checker { pub passed: u16, pub failed: u16, group: &'static str, base_url: String, pub path: &'static str, method: Method, expect_json: bool, client: hyper::Client<hyper::client::HttpConnector, Body>, } impl Checke...
true
43757e47ce19ad333c78ec11e6a1a614dc8eafb7
Rust
storyfeet/str_tools
/src/char_match.rs
UTF-8
483
3.09375
3
[]
no_license
pub trait CharMatch { fn char_match(&self, c: char) -> bool; } impl CharMatch for str { fn char_match(&self, c: char) -> bool { self.contains(c) } } impl CharMatch for &str { fn char_match(&self, c: char) -> bool { self.contains(c) } } impl CharMatch for char { fn char_match(&se...
true
121b9ab488d00190bd90f6c02be7eefae125e706
Rust
dennisss/dacha
/pkg/fan_controller/src/avr/progmem.rs
UTF-8
3,810
3.3125
3
[ "Apache-2.0" ]
permissive
/// NOTE: Do not use me directly. Instead use the progmem macro pub struct ProgMem<T> { value: T, } impl<T> ProgMem<T> { pub const unsafe fn new(value: T) -> Self { Self { value } } pub fn size_of(&'static self) -> usize { core::mem::size_of::<T>() } // pub fn load_byte(&'stat...
true
2ff4decf4a79effa13f12e67303be7351d37287f
Rust
ma2gedev/advent-of-code
/2019/day08/aoc_rust/src/main.rs
UTF-8
1,680
3.171875
3
[]
no_license
use std::fs; fn main() -> std::io::Result<()> { let input: String = fs::read_to_string("../resources/input.txt")?; let input_str: &str = input.trim(); let input_num: Vec<u32> = input_str.chars().map(|num_char| { num_char.to_digit(10).unwrap() }).collect(); // first let width = 25; ...
true
6691047c07f6b2ffc7f66810f1493ec7cf6bbd0a
Rust
toku-sa-n/pci_config
/src/space/accessor.rs
UTF-8
2,843
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use { core::ops::Add, x86_64::instructions::port::{Port, PortWriteOnly}, }; pub(crate) struct Accessor { bus: Bus, device: Device, function: Function, index: RegisterIndex, } impl Accessor { const PORT_CONFIG_ADDR: PortWriteOnly<u32> = PortWriteOnly::new(0xcf8); const PORT_CONFIG_DATA:...
true
50dd259525b38ee3cd78848ea8c8932c512f70b2
Rust
jimberlage/stl_parser
/src/parser/ascii.rs
UTF-8
4,277
2.640625
3
[]
no_license
use crate::coordinate::Coordinate; use crate::facet::Facet; use crate::parser::error::SolidError; use crate::solid::Solid; use nom::bytes::complete::{tag_no_case, take_while1}; use nom::character::is_space; use nom::character::complete::{multispace0, multispace1}; use nom::combinator::{map, map_parser, not, opt}; use n...
true
f00afd3db4d653039700cae10820c6166e1fd8c3
Rust
marcoesposito1988/ros2_rust
/rclrs_examples/src/rclrs_subscriber.rs
UTF-8
429
2.53125
3
[ "Apache-2.0" ]
permissive
extern crate rclrs; extern crate std_msgs; fn topic_callback(msg: &std_msgs::msg::String) { println!("I heard: '{}'", msg.data); } fn main() { rclrs::init().unwrap(); let mut node = rclrs::create_node("minimal_subscriber"); let subscription = node.create_subscription::<std_msgs::msg::String>( ...
true
6497d5b63b94ec3f4e65df8df172f20b051eab4a
Rust
Mathspy/euler_rust_practice
/006_sum_square_difference/src/main.rs
UTF-8
729
3.5625
4
[]
no_license
use std::env; fn main() { let args: Vec<String> = env::args().collect(); println!( "{}", solve(args[1].parse().expect("Please input a valid integer")) ); } fn solve(amount: u32) -> u64 { let sum_of_squares: u32 = (1..=amount).into_iter().map(|x| x * x).sum(); let sum_of_values: u...
true
26250246a652e05d778e264f8237b986c0e76c36
Rust
southpawgeek/perlweeklychallenge-club
/challenge-194/ulrich-rieke/rust/ch-2.rs
UTF-8
851
3.25
3
[]
no_license
use std::io ; use std::collections::HashMap ; fn main() { println!("Please enter a string consisting of lowercase letters!") ; let mut inline : String = String::new( ) ; io::stdin( ).read_line( & mut inline ).unwrap( ) ; let entered_line : &str = &*inline ; let mut frequencies = HashMap::new( ) ; ...
true
d46d2a8a30bc5295b29b986cde7a8be537e48004
Rust
nilq/sloth
/src/sloth/syntax/compiler/value.rs
UTF-8
2,174
2.953125
3
[ "MIT" ]
permissive
use std::hash::{Hash, Hasher}; use std::mem; use std::rc::Rc; use std::fmt::*; use super::*; #[derive(Debug, Clone)] pub enum HeapKind { Str(Rc<String>), Function(CompiledBlock), } #[derive(Debug, Clone)] pub struct HeapObject { pub next: *mut HeapObject, pub marked: bool, pub kind: HeapKind,...
true
238d36b736c40296a419e848e4169b2c70f21143
Rust
forensic-architecture/annotate-syn
/rust/src/util.rs
UTF-8
1,879
2.8125
3
[]
no_license
// use flate2::write::ZlibEncoder; // use flate2::Compression; use image::{DynamicImage, GrayImage, Luma, Rgba}; use serde::Serialize; use std::cmp::{max, min}; // use std::io::prelude::*; pub type Pos = [u32; 2]; pub type Bbox = [Pos; 2]; pub type Pixel = Rgba<u8>; pub trait PixelMethods { fn to_str(&self) -> St...
true
d52d0ea5170d2ca47412bf168221d4c417caf77b
Rust
yeluyang/playground
/dss/projects/raft/src/peer.rs
UTF-8
12,789
2.75
3
[]
no_license
use std::{ collections::HashMap, fmt::{self, Display, Formatter}, sync::{mpsc, Arc, Mutex}, thread, time::Duration, }; extern crate rand; use rand::Rng; use crate::{ error::Result, logger::{LogSeq, Logger}, rpc::{EndPoint, PeerClientRPC}, }; #[derive(Debug)] pub struct Vote { pub ...
true
f964295146cf629409f123706905498e29ba75dc
Rust
cryptomental/beacon-fuzz
/files/fuzzers/shuffle/lighthouse/src/lib.rs
UTF-8
722
2.578125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{mem, ptr, slice}; use swap_or_not_shuffle::shuffle_list; #[no_mangle] pub fn shuffle_list_c(input_ptr: *mut usize, input_size: usize, seed_ptr: *mut u8) -> bool { assert_eq!( mem::size_of::<usize>(), mem::size_of::<u64>(), "Other implementations return u64" ); let input: ...
true
0e80ec194272aeeaadea181b7b5653a6782dce3c
Rust
Hyumin/AdventOfCode2020
/src/day_11.rs
UTF-8
7,357
3.328125
3
[]
no_license
#[path = "utility.rs"] mod utility; fn check_seat_occupied( arg : &Vec<i32>) ->u32 { let mut result =0; for c in arg { if *c == 2 { result+=1; } } return result; } fn check_adjacent_for_hekje(arg: &Vec<i32>, x: i32 , y :i32, w :i32, h :i32) -> u32 { le...
true
6f6492c700821969871470610bb0f1cd65a8beba
Rust
play-stm32/firmware
/src/config.rs
UTF-8
1,032
2.6875
3
[]
no_license
use sdio_sdhc::sdcard::Card; use fat32::base::Volume; use serde::Deserialize; pub static mut CONFIG_BUF: [u8; 512] = [0; 512]; #[derive(Debug)] pub enum ConfigError { NoConfig, FormatError } #[derive(Deserialize)] pub struct Config { pub wifi_ssid: &'static str, pub wifi_pwd: &'static str, pub se...
true
5d18945629c56fa92704122761198d08b4f6dde2
Rust
discordance/schemafy
/schemafy_lib/src/generator.rs
UTF-8
3,903
2.921875
3
[ "MIT" ]
permissive
use crate::Expander; use std::{ io, path::{Path, PathBuf}, }; /// A configurable builder for generating Rust types from a JSON /// schema. /// /// The default options are usually fine. In that case, you can use /// the [`generate()`](fn.generate.html) convenience method instead. #[derive(Debug, PartialEq)] #[m...
true
f4f8079a59337eac67fc6da5f0eaea336b371979
Rust
seguidor777/dcoder-solutions
/medium/prime_ranges.rs
UTF-8
865
3.484375
3
[]
no_license
use std::io; fn is_prime(n: &u32) -> bool { // Assumes that 1 is not a prime number if *n == 1 { return false; } for i in 2..=((*n as f64).sqrt() as u32) { if *n % i == 0 { // This means that n has a factor in between 2 and sqrt(n) // So it is not a prime number...
true
4d56c16d3162e6280190feff5c62711d37def884
Rust
arthmis/windows-task-scheduler
/src/principal.rs
UTF-8
2,394
2.953125
3
[ "Apache-2.0" ]
permissive
use std::{ptr, unreachable}; use bindings::Windows::Win32::TaskScheduler::IPrincipal; use log::error; /// Provides the security credentials for a principal. These security credentials define the security context for the tasks that are associated with the principal. /// /// https://docs.microsoft.com/en-us/windows/win...
true
54db970fd0eb3a8becd604701926784215dbcfee
Rust
atollk/rust-practice-interpreter
/src/execute.rs
UTF-8
31,658
3.140625
3
[]
no_license
use crate::parse::parsetree; use std::collections::HashMap; #[derive(Debug, Clone)] pub struct ExecutionError { pub message: String, } pub fn execute_program( program: &parsetree::Program, input: &str, ) -> Result<String, ExecutionError> { let definitions = definitions_from_program(program); let m...
true
98e50543f7b5352132a4b0c8d63818a621cb2aae
Rust
cmisenas/aoc2019
/src/day4.rs
UTF-8
1,904
3.265625
3
[]
no_license
use std::collections::HashSet; use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; pub fn main() { let input = read_lines_as_str("./day4.input")[0] .split("-") .map(|x| x.parse::<u32>().unwrap()) .collect::<Vec<u32>>(); let min = input[0]; let max = input[1]; l...
true
aa9630ffc07fe7f3704a1a50288b19aa4b01f21d
Rust
kod-kristoff/rust-playground
/kxparser/src/domain/services/print.rs
UTF-8
839
2.75
3
[]
no_license
use crate::domain::models::Chart; pub fn print_chart(chart: &Chart, positions: &[i32], cutoff: Option<usize>) { let cutoff: usize = cutoff.unwrap_or(8); println!("Chart size: {} edges", chart.chartsize()); for (k, edgeset) in chart.chart.iter().enumerate() { if edgeset.len() > 0 && (positions.conta...
true
f60f9554716d23bdc6a215be05d4f7adeabbfa3a
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/rand_pcg-0.1.1/src/pcg64.rs
UTF-8
6,518
2.703125
3
[ "BSD-2-Clause", "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2018 Developers of the Rand project. // Copyright 2017 Paul Dicker. // Copyright 2014-2017 Melissa O'Neill and PCG Project contributors // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or https://opens...
true
c6c9c81bb5adcf65d4a86a8cf086817856ba2142
Rust
shamil-gadelshin/raft
/src/common/peer_consensus_requester.rs
UTF-8
2,026
2.578125
3
[ "MIT" ]
permissive
use rayon::prelude::*; use std::ops::Fn; use std::result::Result; use std::string::*; use crate::errors; use crate::errors::RaftError; use crate::operation_log::QuorumResponse; pub fn request_peer_consensus<Req, Resp, Requester>( request: Req, node_id: u64, peers: Vec<u64>, quorum: Option<u32>, re...
true
7178ac2b2d35b34b4c5d8d8a01cf9ac35b154e4e
Rust
Cloudxtreme/astro-rust
/src/orbit/near_parabolic.rs
UTF-8
2,438
3.046875
3
[ "MIT" ]
permissive
//! Near-parabolic orbits use angle; use consts; /** Computes the true anomaly and radius vector of a body in a near-parabolic orbit at a given time # Returns `(true_anom, rad_vec)` * `true_anom`: True anomaly of the body at time `t` *| in radians* * `rad_vec` : Radius vector of the body at time `t` *| in AU* # ...
true
769db301c377823184ac318e3e7f30780c8d849a
Rust
cipepser/minna-data
/chap3_Linked_Lists/basic/src/doubly_linked_list.rs
UTF-8
5,229
3.1875
3
[]
no_license
use common::traits::List; use std::rc::{Rc, Weak}; use std::cell::RefCell; use std::fmt::{Debug, Formatter}; type Link<T> = Rc<RefCell<Node<T>>>; type Wink<T> = Weak<RefCell<Node<T>>>; #[derive(Clone, Default)] pub struct Node<T: Clone + PartialEq + Eq + Default + std::fmt::Debug> { x: T, next: Option<Link<T>...
true
1ded4ccfc04d36f49629e2ccfc1511a383aa9d97
Rust
nikomatsakis/chalk-ndm
/chalk-engine/src/stack.rs
UTF-8
2,283
3.15625
3
[ "BSD-3-Clause", "bzip2-1.0.6", "LicenseRef-scancode-other-permissive", "NCSA", "MIT", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "Unlicense" ]
permissive
use crate::{DepthFirstNumber, TableIndex}; use std::ops::{Index, IndexMut, Range}; /// See `Forest`. #[derive(Default)] pub(crate) struct Stack { /// Stack: as described above, stores the in-progress goals. stack: Vec<StackEntry>, } index_struct! { /// The StackIndex identifies the position of a table's g...
true
0fd3edc8d0bc9edcd3f6b5cc205cac858f52d8ed
Rust
edwardwawrzynek/codekata_old
/src/gomoku.rs
UTF-8
5,686
3.0625
3
[]
no_license
use crate::game::{Game, GameOutcome, GamePlayer}; use serde::{Deserialize, Serialize}; const BOARD_SIZE: usize = 15; const WIN_LEN: usize = 5; #[derive(Clone, Debug, Serialize, Deserialize)] pub struct Gomoku { board: [[i8; BOARD_SIZE]; BOARD_SIZE], turn: i8, } #[derive(FromForm)] pub struct Move { x: i3...
true
bc267ec5ec3cb0ae7deffd1effec5fa794b95d2d
Rust
henrifrancois/portfolio
/src/main.rs
UTF-8
2,625
2.75
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro)] #[macro_use] extern crate rocket; #[macro_use] extern crate error_chain; #[macro_use] extern crate serde_derive; extern crate reqwest; extern crate rocket_contrib; use rocket::response::NamedFile; use rocket::Config; use rocket_contrib::serve::StaticFiles; use rocket_con...
true
d496693aa089943b49af0f7e7a86bddb57c4b99b
Rust
xakep71k/interpretators
/simple/rust/part15/src/lexer.rs
UTF-8
5,383
3.25
3
[ "BSD-2-Clause" ]
permissive
use crate::errors::Error; use crate::token; use crate::var_type::VarType; use std::collections::HashMap; pub struct Lexer { reserved_keywords: HashMap<&'static str, token::Kind>, pos: usize, line: Vec<char>, current_char: Option<char>, lineno: usize, column: usize, } impl Lexer { pub fn ne...
true
6e3cbe744e26482a9cd05682feff3568e2fd1a08
Rust
embs/advent_of_code_2019
/day_1/day_1_2.rs
UTF-8
546
3.28125
3
[]
no_license
use std::fs; fn tally_fuel(mass: i32) -> i32 { let fraction: f32 = mass as f32 / 3.0; let rounded = fraction.floor() as i32; if rounded <= 2 { 0 } else { let result = rounded - 2; result + tally_fuel(result) } } fn main() { let contents = fs::read_to_string("day_1.inp...
true
98dd476f748bfab75fb8b1fc7e5a34ab716a4b87
Rust
solsensor/sol
/src/api/mod.rs
UTF-8
6,798
2.5625
3
[]
no_license
use crate::{ auth, db::SolDbConn, models::{ Energy, Reading, ReadingInsert, ReadingQueryUnix, Sensor, SensorInsert, Token, User, UserQuery, }, result::{Error, Result}, }; use chrono::NaiveDateTime; use git_version::git_version; use rocket::{get, http::RawStr, post, request::FromFormV...
true
c8af7af7eb8a9d3cc7d6c178cb729dcc8f5ba5d5
Rust
arosspope/learn-rust
/testing-examples/adder/src/lib.rs
UTF-8
1,715
3.828125
4
[ "MIT" ]
permissive
#[derive(Debug)] pub struct Rectangle { length: u32, width: u32, } struct Guess { value: u32, } impl Rectangle { pub fn can_hold(&self, other: &Rectangle) -> bool { self.length > other.length && self.width > other.width } } pub fn add_two(a: i32) -> i32 { a + 2 } fn internal_adder(a:...
true
c08f725daeb0800243f926ec7a85e63feeaa698d
Rust
isgasho/zap-1
/lib/zap-bin/src/test.rs
UTF-8
708
3.046875
3
[ "Apache-2.0" ]
permissive
use structopt::StructOpt; #[derive(StructOpt, Debug, Clone)] #[structopt( name = "test", setting = structopt::clap::AppSettings::ColoredHelp, about = "Incrementally run one or many tests" )] pub struct TestGoal { #[structopt( help = r"The test target to run. A path to a directory with a zap fi...
true
12eeaff862c7e39bc73796ea9e94e7dffe02c66c
Rust
igncp/environment
/src/common_provision/vim/nvim/install.rs
UTF-8
3,221
2.546875
3
[ "MIT" ]
permissive
use crate::base::{ config::{Config, Theme}, Context, }; pub fn install_nvim_package(context: &mut Context, repo: &str, extra_cmd: Option<&str>) { let extra = match extra_cmd { Some(cmd) => format!(r#", build = "{}""#, cmd), None => "".to_string(), }; context.files.replace( &...
true
7a7cce8a58204c1e61171fd71affa4656b28da7e
Rust
mitchmindtree/elmesque
/src/transform_2d.rs
UTF-8
2,722
3.671875
4
[]
no_license
//! //! Ported from [elm-lang's Transform2D module] //! (https://github.com/elm-lang/core/blob/62b22218c42fb8ccc996c86bea450a14991ab815/src/Transform2D.elm) //! //! //! A library for performing 2D matrix transformations. It is used primarily with the //! `group_transform` function from the `form` module and allows you ...
true
92854d064c019b6d0f8b65ccd5339dc79f110f45
Rust
repnop/mac_address
/src/iter/linux.rs
UTF-8
916
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{MacAddress, MacAddressError}; use nix::{ifaddrs, sys::socket::SockAddr}; /// An iterator over all available MAC addresses on the system. pub struct MacAddressIterator { iter: std::iter::FilterMap< ifaddrs::InterfaceAddressIterator, fn(ifaddrs::InterfaceAddress) -> Option<MacAddress>, ...
true
d0933845f27d1bbdf5e1ac33475b36a824df91e2
Rust
yaspoon/adventOfCode2020
/day1_1/src/main.rs
UTF-8
901
3.234375
3
[]
no_license
use std::path::Path; use std::fs::File; use std::io::BufReader; use std::io::prelude::*; fn read_input(path: &Path) -> Vec<i32> { let file = match File::open(path) { Ok(f) => f, Err(e) => panic!("Failed to open path:{}", e), }; let mut br = BufReader::new(file); let mut contents = Stri...
true
1ec2b6fc6a1ce2d23f5991e96cb7af3539391279
Rust
Kinrany/hammerpipe
/src/game/grid.rs
UTF-8
1,313
2.828125
3
[]
no_license
use quicksilver::{ geom::{Rectangle, Vector}, graphics::{Background, Color}, lifecycle::Window, }; use super::field::Field; trait ColorExt { const GREY: Color; } impl ColorExt for Color { const GREY: Color = Color {r: 0.5, g: 0.5, b: 0.5, a: 1.0}; } pub const CELL_COUNT: usize = 6; const SPACE_BETWEEN_CEL...
true
207825ed4cf04726b5686a29fdd3cbbabd289522
Rust
kgtkr/procon
/atcoder/rust/abc104_d/src/main.rs
UTF-8
3,409
2.96875
3
[]
no_license
extern crate core; use std::io::{self, Read}; #[macro_use] mod parser { macro_rules! input { ($s:expr=>$($t:tt)*) => { let mut lines=$s.split("\n"); $( line_parse!(lines,$t); )* }; } macro_rules! line_parse { ($lines:expr,($($name:ident:$t:tt)*)) => { ...
true
7d5a3ec131365cfbb8e607ad34295ee5af355431
Rust
you-win/bevy
/crates/bevy_ui/src/widget/text.rs
UTF-8
5,485
2.8125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "Zlib" ]
permissive
use crate::{CalculatedSize, Size, Style, UiScale, Val}; use bevy_asset::Assets; use bevy_ecs::{ entity::Entity, query::{Changed, Or, With}, system::{Commands, Local, ParamSet, Query, Res, ResMut}, }; use bevy_math::Vec2; use bevy_render::texture::Image; use bevy_sprite::TextureAtlas; use bevy_text::{ Fo...
true
37148fa095e61eea24040842c51ba79917d72d80
Rust
Mossop/musicbox-rs
/src/hardware/gpio/led.rs
UTF-8
1,156
2.921875
3
[]
no_license
use rppal::gpio::{Level, OutputPin}; use log::{debug, error}; use serde::Deserialize; use crate::error::MusicResult; use crate::hardware::gpio::{LevelDef, GPIO}; #[derive(Debug, Clone, Deserialize)] #[serde(rename_all = "camelCase")] pub struct LEDConfig { pub pin: u8, #[serde(with = "LevelDef")] pub on...
true
cff8822f090d86d188f6381d3f67297ee5274805
Rust
dhuseby/cclang
/tests/logic.rs
UTF-8
16,581
3.328125
3
[ "Apache-2.0" ]
permissive
use bytes::Bytes; use cclang::{ CCLang::{ self, Binary, Boolean, Equal, GreaterThan, GreaterThanEqual, Index, LessThan, LessThanEqual, NotEqual, Text }, Machine, NullIO, Script }; #[test] pub fn equal_0() { ...
true
5109e50ab81a349c11f3f16edc13254c40f4ecc2
Rust
rcuhljr/aoc2018
/src/day2/mod.rs
UTF-8
2,715
3.25
3
[]
no_license
use super::utility; use std::collections::HashMap; fn find_checksum(samples: Vec<String>) -> i32 { let mut doubles = 0; let mut triples = 0; samples.iter().for_each(|sample| { let mut counts = HashMap::new(); sample.chars().for_each(|single| { let counter = counts.entry(single)....
true
0590248eea9d470192dfa81d40eeb26e100d3dd0
Rust
Anupam-Ashish-Minz/aoc2020_rust
/src/day12.rs
UTF-8
784
2.609375
3
[]
no_license
mod handle_input12; pub fn run() { } fn part1() { } fn part2() { } fn follow_inst1(input: Vec<(char, i32)>) { // direction, east_west_value int, north_south_value int let mut ship_state: (char, i32, i32) = ('E', 0, 0); for (dir, val) in input { if dir == 'F' { if ship_...
true
7ad0965b5f4d3f328a30e8497c6b8edfa08314a5
Rust
hschne/samsonr
/src/configuration.rs
UTF-8
962
2.703125
3
[ "MIT" ]
permissive
use std::path::{Path}; use serde::Deserialize; use log::*; use config::{ConfigError, Config, File}; #[derive(Debug, Deserialize)] pub struct Configuration { pub url: String, pub token: Option<String>, pub project_id: Option<i32>, } impl Configuration { pub fn new() -> Result<Self, ConfigError> { ...
true
94283a55cb7f81248c1af3a9af134a8772f21e25
Rust
Cldfire/overgg-scraper
/src/test_utils.rs
UTF-8
1,443
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::data_structs::MatchBriefInfo; use std::path::Path; use std::fs::File; use std::io::BufReader; use std::io::{Read, Write}; use serde::Serialize; use serde::de::DeserializeOwned; use serde_json; use crate::error::*; #[derive(Debug, PartialEq)] #[derive(Serialize, Deserialize)] pub struct SaveData { pub ma...
true