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
241f3840106722b4696c9507251f430725becfe7
Rust
xiuxiu62/hackerrank
/jumping-on-the-clouds/src/main.rs
UTF-8
1,463
3.515625
4
[]
no_license
use std::io; use std::io::prelude::*; const SAFE: bool = false; fn main() { let stdin = io::stdin(); let mut lines = stdin.lock().lines(); while let Some(_) = lines.next() { let stream = lines.next().expect("invalid stream").unwrap(); let input = stream .chars() .f...
true
762e120972949a550e5b21f0b457e81f2b28884f
Rust
Gobi03/Rust_mylibrary
/基本操作/データ構造/Iterator.rs
UTF-8
301
2.515625
3
[]
no_license
// https://qiita.com/lo48576/items/34887794c146042aebf1 let iter: Iterator<usize> = [0; 100].iter(); iter.sum::<T>; iter.filter iter.count() iter.next() iter.enumerate() // <(usize, T)> iter.for_each iter.fold(init: B, f: F) // F := B -> T -> B iter.reduce // Iterator<T> -> (T -> T) -> Option<T> ?
true
9d6cc9fb0941608914d2def79e513e43c361f4e5
Rust
EFanZh/LeetCode
/src/problem_0937_reorder_data_in_log_files/mod.rs
UTF-8
1,170
2.703125
3
[]
no_license
pub mod partition_and_sort; pub trait Solution { fn reorder_log_files(logs: Vec<String>) -> Vec<String>; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ( &[ "dig1 8 1 5 1", "let1 ar...
true
5c259ef664df35ccc3f31b41f0c2da053e9f8b9f
Rust
tyrchen/cellar
/cellar/src/commands/mod.rs
UTF-8
4,190
2.96875
3
[]
no_license
use anyhow::{anyhow, Result}; use base64::{engine::general_purpose::URL_SAFE_NO_PAD, Engine}; use cellar_core::{AuxiliaryData, KeyType}; use dialoguer::{theme::ColorfulTheme, Password}; use std::path::PathBuf; use structopt::StructOpt; use tokio::fs; fn parse_dir(src: &str) -> PathBuf { if src.starts_with("~/") { ...
true
b2026e68b331c44fb7b8a70737525dccce5816c6
Rust
jrhy/sandbox
/mast-rs/src/lib.rs
UTF-8
15,118
2.953125
3
[]
no_license
// use std::borrow::Cow; use std::cmp::Ordering; use std::rc::Rc; use std::result::Result; use std::vec::Vec; #[derive(Debug)] enum MastError { InvalidNode, StoreError(std::io::Error), } #[derive(Debug,Clone)] struct Node { key: Vec<i32>, value: Vec<i32>, link: Vec<Option<Link>>, dirty: bool, ...
true
edfaa77c03ae59785c3b7112a524dcf952bf9c55
Rust
dimforge/nalgebra
/src/base/storage.rs
UTF-8
10,549
3.1875
3
[ "Apache-2.0" ]
permissive
//! Abstract definition of a matrix data storage. use std::ptr; use crate::base::allocator::{Allocator, SameShapeC, SameShapeR}; use crate::base::default_allocator::DefaultAllocator; use crate::base::dimension::{Dim, U1}; use crate::base::Scalar; /* * Aliases for allocation results. */ /// The data storage for the...
true
77c51d1294c0c5c58862dc9e9be52c0c0c843a2e
Rust
Ruin0x11/sabi
/src/logic/command.rs
UTF-8
13,097
2.71875
3
[]
no_license
use std::fmt::Display; use GameContext; use data::Walkability; use engine::keys::{Key, KeyCode}; use ecs::traits::*; use graphics::cell::{CellFeature, StairDest, StairDir}; use logic::Action; use logic::entity::EntityQuery; use point::{Direction, Point}; use world::traits::*; use world::{self, World}; use super::debu...
true
90197e0b4ae40f6ad707214a0e1994adc754ef0a
Rust
adventofjuan/AdventOfCode2018-Day03
/src/main.rs
UTF-8
1,885
3.234375
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{BufReader, BufRead}; fn parse_file(file: BufReader<&File>) -> HashMap<(i32, i32), (i32, Vec<i32>)> { let mut res = HashMap::new(); for line in file.lines() { let l = line.unwrap(); let tokens:Vec<&str> = l.split(" ").collect(); ...
true
4ecb05c932c65c98289e252dbe18ce86c5716222
Rust
CementTheBlock/Mazes
/src/maze.rs
UTF-8
7,123
3.25
3
[]
no_license
use std::fmt; use direction::*; use node::*; #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct Cursor { index: usize, } impl Cursor { pub fn unsafe_new(index: usize) -> Cursor { Cursor { index: index } } pub fn index(&self) -> usize { self.index } } impl fmt::Display for Cu...
true
d8655b58823d750a1ee11c1cf76218b395293848
Rust
humb1t/cucumber-rust
/src/hashable_regex.rs
UTF-8
538
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::hash::{Hash, Hasher}; use std::ops::Deref; use regex::Regex; #[derive(Debug, Clone)] pub struct HashableRegex(pub Regex); impl Hash for HashableRegex { fn hash<H: Hasher>(&self, state: &mut H) { self.0.as_str().hash(state); } } impl PartialEq for HashableRegex { fn eq(&self, other: &Has...
true
0a94c948c1a954a131f5428a82bf781618e48a13
Rust
ma2bd/gad
/gad/tests/analytic.rs
UTF-8
10,160
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates // SPDX-License-Identifier: MIT OR Apache-2.0 use gad::prelude::*; #[inline] fn assert_near(x: f32, y: f32) { assert!((x - y).abs() < 0.001); } #[test] fn test_exp() -> Result<()> { let mut g = Graph1::new(); let a = g.variable(1f32); let b = { ...
true
98b7db3cf2fcc356c5d452a3c8a57a1cde54373c
Rust
sugyan/leetcode
/others/september-leetcoding-challenge/week-3/3462/lib.rs
UTF-8
1,878
3.546875
4
[]
no_license
#[derive(Default)] struct Trie { children: [Option<Box<Trie>>; 2], } pub struct Solution {} impl Solution { pub fn find_maximum_xor(nums: Vec<i32>) -> i32 { let mut trie: Trie = Default::default(); for &num in nums.iter() { let mut node = &mut trie; for i in (0..31).rev...
true
0e72a2b89ddda4c31d0a9753ab476d9f8411e8b7
Rust
justinrubek/reform
/server/src/routes/entries.rs
UTF-8
2,277
2.703125
3
[]
no_license
use crate::auth::Auth; use crate::config::AppState; use crate::db::{self}; use crate::errors::{Errors, FieldValidator}; use core::ops::Deref; use std::convert::{From, Into}; use rocket::State; use rocket_contrib::json::{Json, JsonValue}; use serde::{Serialize, Deserialize}; use serde_json::Value; use validator::Valida...
true
acba0c36be5edb9fffa7a6ff68e00a4c1bf92bab
Rust
twe4ked/nushell
/src/commands/ls.rs
UTF-8
556
2.765625
3
[]
no_license
use crate::errors::ShellError; use crate::object::{dir_entry_dict, Value}; use crate::prelude::*; pub fn ls(args: CommandArgs) -> Result<OutputStream, ShellError> { let cwd = args.env.lock().unwrap().cwd().to_path_buf(); let entries = std::fs::read_dir(&cwd).map_err(|e| ShellError::string(format!("{:?}", e)))...
true
e8c5ec968563e34498298d07073af502e5383a13
Rust
ben2x4/cw20-extension-base
/src/msg.rs
UTF-8
3,021
2.703125
3
[ "Apache-2.0" ]
permissive
use cosmwasm_std::{Binary, Uint128}; use cw20::{Expiration, Logo}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; pub use cw20_base::msg::InstantiateMsg; #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)] #[serde(rename_all = "snake_case")] pub enum ExecuteMsg { Transfer { ...
true
12d6ae824a9e54fdc535d2d6be63e7c84758eec3
Rust
rajin-s/specs
/src/compiler/_old/validate/specs_source.rs
UTF-8
5,723
2.90625
3
[]
no_license
use crate::compiler::internal::*; // Compiler pass instance pub struct Pass {} impl Pass { pub fn new() -> Self { Self {} } } /* -------------------------------------------------------------------------- */ /* Pass */ /* -------...
true
629d7958340f258208929713ab8f2d709360b0a2
Rust
erkpht/tower
/tower/src/buffer/mod.rs
UTF-8
501
2.59375
3
[ "MIT" ]
permissive
//! Buffer requests when the inner service is out of capacity. //! //! Buffering works by spawning a new task that is dedicated to pulling requests //! out of the buffer and dispatching them to the inner service. By adding a //! buffer and a dedicated task, the `Buffer` layer in front of the service can //! be `Clone` ...
true
a0e0aca504d8ff4660a1a8328845fbc4553910fd
Rust
mbnuqw/pasd-core
/src/handlers/add_key.rs
UTF-8
1,643
2.828125
3
[]
no_license
use con::server::SharedState; use con::Msg; use db::DB; use errors::Error; use key::{Key, AddKeyArgs}; use std::sync::{Arc, Mutex}; #[derive(Serialize)] pub struct AddKeyAns { error: Option<String>, } impl AddKeyAns { pub fn json(err: Option<Error>) -> Option<Vec<u8>> { let mut ans = AddKeyAns { error...
true
e5866e26c78296055da3be09b43a93c3d88fa942
Rust
nk-designz/kyward.rs
/kyward-api/src/auth/user.rs
UTF-8
1,178
2.59375
3
[]
no_license
use rocket::http::Status; use rocket::request::{self, FromRequest, Request}; use super::error::{AuthenticationError, NewAuthenticationError}; use super::token::ApiToken; /// Microsoft Azure JWT Claims representing user-data #[derive(Debug)] pub struct User(pub azure_jwt::AzureJwtClaims); /// Returns User from a Reque...
true
dd260867b31a55f1189937cb8481a754c7028890
Rust
JoNil/strfmt
/example/src/lib.rs
UTF-8
423
3.125
3
[ "MIT" ]
permissive
extern crate strfmt; use strfmt::strfmt; use std::collections::HashMap; #[test] fn it_works() { let mut vars = HashMap::new(); vars.insert("name".to_string(), "bob".to_string()); vars.insert("job".to_string(), "python developer".to_string()); let fmt = "hi, my name is {name} and I am a {job}!".to_stri...
true
48f111e306dbebd8bd4daa1e975a214037fa5ed9
Rust
nyantec/sensorlog
/src/time.rs
UTF-8
1,288
2.515625
3
[ "MirOS" ]
permissive
/** * Copyright © 2018 nyantec GmbH <oss@nyantec.com> * Authors: * Paul Asmuth <asm@nyantec.com> * Karl Engelhardt <ken@nyantec.com> * * Provided that these terms and disclaimer and all copyright notices * are retained or reproduced in an accompanying document, permission * is granted to deal in this work w...
true
e2b4c660c0df576c1c632c87f73a814fedbbd76b
Rust
arden/rustless
/src/backend/simple_request.rs
UTF-8
2,514
2.8125
3
[ "MIT" ]
permissive
use std::io::{File, Reader, IoResult}; use std::fmt::{Show, Formatter, Error}; use std::io::net::ip::SocketAddr; use typemap::TypeMap; use {Extensible}; use server::method::Method; use server::header::Headers; use backend::{Request, Url, AsUrl, WrapUrl}; #[deriving(Send)] #[allow(dead_code)] pub struct SimpleRequest...
true
d5ae519c6924bfb8e2c51d7cad1586c8f2ae0bbe
Rust
aptend/rlox
/src/ast/stmt.rs
UTF-8
3,123
3.5
4
[]
no_license
use super::Expr; use crate::scanner::Token; use std::ops::Deref; use std::rc::Rc; pub enum Stmt { Expression(Expr), Print(Expr), Var(VariableStmt), Block(BlockStmt), If(IfStmt), While(WhileStmt), Function(FunctionStmt), Return(ReturnStmt), Class(ClassStmt), Break, } impl std::de...
true
a0b340d8ba9d236f6d2c8ad6603bd68b6d5ea697
Rust
cLazyZombie/raytrace-rs
/src/tuple.rs
UTF-8
7,948
3.328125
3
[]
no_license
use std::ops::{Add, Div, Index, IndexMut, Mul, Neg, Sub}; #[derive(Debug, Copy, Clone, PartialEq)] pub struct Tuple<const N: usize> { values: [f32; N], } pub type Vec4 = Tuple<4>; pub type Vec3 = Tuple<3>; impl<const N: usize> Tuple<N> { pub fn new(values: [f32; N]) -> Self { Self { values } } ...
true
7c38b611c375352479878c42f612631510be02e1
Rust
IThawk/rust-project
/rust-master/src/test/ui/associated-types/associated-types-binding-in-trait.rs
UTF-8
681
3.234375
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass // Test a case where the associated type binding (to `bool`, in this // case) is derived from the trait definition. Issue #21636. use std::vec; pub trait BitIter { type Iter: Iterator<Item=bool>; fn bit_iter(self) -> <Self as BitIter>::Iter; } impl BitIter for Vec<bool> { type Iter = vec::In...
true
830ca8398b45f94eabaaaeb5006230114e6901e4
Rust
ThijsRay/AdventOfCode
/2019/original/src/day5.rs
UTF-8
6,458
3.03125
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day5)] pub fn generator(input: &str) -> Vec<isize> { input .lines() .flat_map(|x| x.split(',')) .map(|x| x.parse::<isize>().unwrap()) .collect() } #[derive(Debug)] enum AddressingMode { Position, Immediate, } imp...
true
a717ac80bbacc0c6b78ab2baba332e24c72ea859
Rust
kitlith/typemap_core
/src/get.rs
UTF-8
6,089
3.5
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use super::{Sealed, Ty, TyEnd}; use core::any::Any; /// The Contains trait marks a map as containing at least one instance of a given type that can be accessed /// /// ``` /// use typemap_core::{typemap, Contains}; /// fn requires_u32<Opts: Contains<u32>>(opts: &Opts) { /// println!("{}", opts.get::<u32>()); /// ...
true
b27c03c00b2024517e04d1aef3a7cda008412578
Rust
danielschemmel/drsat
/src/util/typeinfo.rs
UTF-8
685
3.0625
3
[]
no_license
use std::fmt; use std::marker::PhantomData; use std::mem::{align_of, size_of}; #[derive(Debug, Clone)] pub struct Typeinfo<T> { phantom: PhantomData<T>, } impl<T> Typeinfo<T> { pub fn new() -> Self { Self::default() } pub fn size() -> usize { size_of::<T>() } pub fn alignment() -> usize { align_of::<T>(...
true
4a6844f789a20f3bfa68402e00e138ad123178fb
Rust
tuxmark5/north
/north_parser/src/grammar.rs
UTF-8
3,214
2.703125
3
[]
no_license
use { crate::{ parse::{Parse, ParseDyn, ParseDynAdapter}, }, north_core::Node, std::{ any::TypeId, collections::HashMap, marker::{PhantomData, Unsize}, rc::Rc, } }; //////////////////////////////////////////////////////////////////////////////////////////////// #[derive(Default)] pub str...
true
9470f6899ea641369db7af70208366fc5adc5470
Rust
snd/onmf
/src/helpers/normalize.rs
UTF-8
1,030
3.1875
3
[ "MIT", "Apache-2.0" ]
permissive
use std::ops::Div; use nalgebra::DMat; use num::{Zero}; use helpers::PartialMaxIteratorExt; pub trait Normalize { /// divide all values in `self` by max value in `self` fn normalize(self) -> Self; } impl<T> Normalize for DMat<T> where T: PartialOrd + Clone + Copy + Zero, DMat<T>: Div<T, Output...
true
54bf1f1e5a88320bb3a3b108490d053810189ad9
Rust
jrheard/advent_2018
/src/eight.rs
UTF-8
3,204
3.734375
4
[]
no_license
use std::fs; #[derive(Debug)] struct Node { metadata: Vec<u32>, children: Vec<Node>, } fn parse_license_text() -> Vec<u32> { let contents = fs::read_to_string("src/inputs/8.txt").unwrap(); let mut license_data_buffer: Vec<u32> = contents.trim().split(' ').map(|x| x.parse::<u32>().unwrap()).collect(); ...
true
2267e7b8adf9ad0ea7af316b474ace5e3e61232c
Rust
bitcoinmw/rust-tor
/tor-proto/src/circuit/celltypes.rs
UTF-8
3,231
3.046875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Wrapper types for subsets of ChanMsg and RelayMsg types. //! //! These wrappers define types that are valid in response to particular //! request, or when received in particular circumstances. They're used //! so that Rust's typesafety can help enforce protocol properties. use crate::{Error, Result}; use tor_cell...
true
a70e5de4ae0a23f208b6b98ebc87b741cf03c7b1
Rust
LarsHachmeister/plantex
/client/src/game.rs
UTF-8
4,992
2.625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use base::world::ChunkProvider; use ghost::Ghost; use event_manager::{CloseHandler, EventManager, EventResponse}; use glium::backend::glutin_backend::GlutinFacade; use glium::{self, DisplayBuild, glutin}; use super::Renderer; use super::{Config, GameContext, WorldManager}; use base::gen::WorldGenerator; use std::time::...
true
a0aa872655a97bfc98263f78ccc8fa6fb55c1379
Rust
rylev/wasmtime
/winch/codegen/src/codegen/context.rs
UTF-8
7,230
3.21875
3
[ "Apache-2.0", "LLVM-exception" ]
permissive
use crate::{ frame::Frame, masm::{MacroAssembler, OperandSize, RegImm}, reg::Reg, regalloc::RegAlloc, stack::{Stack, Val}, }; /// The code generation context. /// The code generation context is made up of three /// essential data structures: /// /// * The register allocator, in charge of keeping th...
true
af0807126df5879b9b247db6fe424013d4d8d287
Rust
mijalk0/glium-physics
/src/mesh.rs
UTF-8
959
2.6875
3
[ "MIT" ]
permissive
use crate::primitive::Primitive; use na::{Isometry3, Vector3}; pub struct Mesh { pub primitives: Vec<Primitive>, pub base_isometry: Isometry3<f32>, pub updated_isometry: Isometry3<f32>, pub scaling: Vector3<f32>, } impl Mesh { pub fn new( primitives: Vec<Primitive>, base_isometry: ...
true
75e28e5252d2947c7a2fbdb206acdf69c5b8e312
Rust
katyo/gear
/src/diagnostic.rs
UTF-8
3,752
2.8125
3
[]
no_license
use crate::qjs; use std::{ fmt, fmt::{Display, Formatter, Result as FmtResult}, result::Result as StdResult, str::FromStr, }; #[derive(Default, Debug, Clone, PartialEq, Eq, Hash, qjs::FromJs, qjs::IntoJs)] pub struct Diagnostics(pub Vec<Diagnostic>); impl Diagnostics { pub fn severity(&self) -> Se...
true
d476ff7e239462267b526148d6355e354cebbeb4
Rust
blinklad/hadlock
/src/models/screen.rs
UTF-8
1,044
2.625
3
[ "MIT" ]
permissive
use x11_dl::xlib::{Window, XWindowAttributes}; use x11_dl::xinerama::XineramaScreenInfo as XSInfo; use std::convert::From; #[derive(Debug, Clone)] pub struct Screen { pub root: Window, pub height: i32, pub width: i32, pub x: i32, pub y: i32 } impl Screen { pub fn new(root: Window, width: i32,...
true
507bce370870a928ee0a330f5ece9b45e202c581
Rust
aaly/open-rust
/src/libs/x/xcb.rs
UTF-8
4,193
2.734375
3
[ "BSD-2-Clause-Views", "BSD-2-Clause" ]
permissive
use crate::libs::x::XBackend; use crate::libs::x::XEventType; use crate::libs::x::XEvent; use crate::libs::x::ButtonPressXEvent; use std::sync::mpsc::*; use std::boxed::Box; pub struct XCBBackend { default_screen_num: i32, conn: Option<xcb::base::Connection>, sender: std::sync::mpsc::Sender<Box<dyn XEvent...
true
0248957f8acf6d18d21024255503be4f4bd92199
Rust
MindFlavor/azure-sdk-for-rust
/sdk/core/src/request_options/content_language.rs
UTF-8
732
2.796875
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use crate::AddAsHeader; use http::request::Builder; #[derive(Debug, Clone, Copy)] pub struct ContentLanguage<'a>(&'a str); impl<'a, S> From<S> for ContentLanguage<'a> where S: Into<&'a str>, { fn from(s: S) -> Self { Self(s.into()) } } impl<'a> AddAsHeader for ContentLanguage<'a> { fn add_as_...
true
e42fb8a342557d1906d0481ed31453d3c97cdec9
Rust
bazk/gatewasm
/core/src/admin.rs
UTF-8
4,985
2.703125
3
[]
no_license
use arc_swap::ArcSwap; use hyper::{body, Body, Method, Request, Response, StatusCode}; use serde::{Deserialize, Serialize}; use serde_json::json; use std::sync::Arc; use crate::router::{Route, RouteHandler, RouteMethod, Router, RouterError}; use crate::utils::GenericResult; #[derive(Debug, Serialize, Deserialize)] st...
true
460c95a48955b51f32cf509141de4d6f673f30cc
Rust
JeeZeh/advent-of-code
/2021/src/day20.rs
UTF-8
2,233
3.015625
3
[]
no_license
use itertools::Itertools; use crate::aocutil::Grid; pub fn solve(lines: String) -> (usize, usize) { let (lookup, mut image) = parse_input(lines); for iter in 0..2 { image = convolve(&lookup, &image, iter); } let part_one = image.iter().flatten().filter(|b| **b).count(); for iter in 2..5...
true
05d9a8f61270f6b78c310b038f08cc77bf4171d3
Rust
saf/terminal-size
/src/windows.rs
UTF-8
1,243
2.671875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate winapi; extern crate kernel32; use super::{Width, Height}; /// Returns the size of the terminal, if available. /// /// Note that this returns the size of the actual command window, and /// not the overall size of the command window buffer pub fn terminal_size() -> Option<(Width, Height)> { use self:...
true
a91a497bf68f3a66547d7127ad22783d76e301ea
Rust
copperinc/usbg.rs
/src/state.rs
UTF-8
1,997
2.921875
3
[ "MIT" ]
permissive
use std::fs; use std::io; use std::path::PathBuf; use UsbGadget; use util::write_data; pub struct UsbGadgetState { configfs_path: PathBuf, udc_name: String, } impl UsbGadgetState { pub fn new() -> UsbGadgetState { let mut state = UsbGadgetState { configfs_path: PathBuf::from("/sys/ker...
true
9487cf6d86c5c4711df6b44a77d01304069ff0d8
Rust
EnronEvolved/notcurses
/rust/examples/direct-cursor.rs
UTF-8
1,569
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Example 'direct-cursor' //! //! Explore cursor functions in direct mode //! // utility macro: sleep for $ms milliseconds macro_rules! sleep { ($ms:expr) => { std::thread::sleep(std::time::Duration::from_millis($ms)); }; } // utility macro: convert the String $s to *mut CString macro_rules! cstring...
true
d6ca6008949f8e96ca2cad3f3c122a6f3aab7118
Rust
hone/jvm-function-invoker-buildpack
/src/data/runtime.rs
UTF-8
1,797
3.328125
3
[ "MIT" ]
permissive
use serde::Deserialize; use toml::value::Table; #[derive(Debug, Deserialize)] pub struct Runtime { pub url: String, pub sha256: String, } impl Runtime { pub fn from_runtime_layer(metadata: &Table) -> Self { let empty_string = toml::Value::String("".to_string()); let sha256 = metadata ...
true
2963b27e2053e6aff35f9fc2babeb5b5681ad01d
Rust
hbina/applejack
/src/lib.rs
UTF-8
7,757
3.25
3
[]
no_license
type Key = Vec<u8>; type Branches<T> = Vec<RaxNode<T>>; #[derive(PartialEq, Debug)] enum Cut { Parent(usize), Child(usize), BothBegin, BothMiddle(usize), BothEnd, } #[derive(Default, Debug)] pub struct Rax<T> { first: Option<T>, branches: Branches<T>, } impl<T> Rax<T> { pub fn insert(...
true
e9e4fc7d9b2f5d55538c6b5cd8cd1a041128b36f
Rust
wezm/cc2650
/src/uart0/ecr.rs
UTF-8
3,900
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
#[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::ECR { #[doc = r" Writes to the register"] #[inline] pub fn write<F>(&self, f: F) where F: FnOnce(&mut W) -> &mut W, { let mut w = W::reset_value(); f(&mut w); self.register.set(w.b...
true
e074ae55d00d71e3f79ca6e808bac2b5ea522172
Rust
LEA0317/rust-test
/ex3_from_shinobu-x_1/src/main.rs
UTF-8
167
2.90625
3
[]
no_license
fn do_it(a :i32, b :i32, c :&mut i32) -> i32 { *c = a + b; *c } fn main() { let mut c = 0; let p = &mut c; println!("{}", do_it(4, 5, p)); }
true
3481a679b9b4f2eaa2ac70ffa878ce58ee1bf60c
Rust
pythias/leetcode
/algorithms/rust/src/s0201_range_bitwise_and.rs
UTF-8
1,148
3.671875
4
[]
no_license
/** * 201. Bitwise AND of Numbers Range * https://leetcode.com/problems/bitwise-and-of-numbers-range/ */ impl Solution { pub fn range_bitwise_and(m: i32, n: i32) -> i32 { if n < m { return 0; } if m < 0 { return 0; } if m == n { return...
true
1009fa7614d6fa74356543e8f29a41c7c8ff880e
Rust
BurntSushi/imdb-rename
/imdb-index/src/index/episode.rs
UTF-8
11,188
2.859375
3
[ "Unlicense", "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
use std::cmp; use std::path::Path; use std::u32; use byteorder::{ByteOrder, BE}; use fst::{self, IntoStreamer, Streamer}; use crate::error::{Error, Result}; use crate::index::csv_file; use crate::record::Episode; use crate::util::{IMDB_EPISODE, fst_set_builder_file, fst_set_file}; /// The name of the episode index f...
true
d71cee7c8de929e7d62a84d0cee2a0d4dd0e41ed
Rust
ibutra/AoC_2019
/src/input.rs
UTF-8
829
3.171875
3
[]
no_license
#![allow(dead_code)] use std::fs::File; use std::io::{BufRead, BufReader, Read}; pub struct Input { filename: String, } impl Input { pub fn new(filename: &str) -> Self { Input { filename: filename.to_string(), } } fn open(&self) -> BufReader<File> { let file = Fil...
true
eb77d0f9ed444215b556dc7937381c194cfd9a40
Rust
dgreid/crosvm
/common/base/src/mmap.rs
UTF-8
7,684
2.625
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2020 The Chromium OS 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::{wrap_descriptor, AsRawDescriptor, MappedRegion, MmapError, Protection, SharedMemory}; use data_model::volatile_memory::*; use data_model::D...
true
1bfa697205e984931ff501e3421174d78f354897
Rust
rogisolorzano/cache-service-rust
/src/common/errors/service_error.rs
UTF-8
872
2.75
3
[]
no_license
use actix_web::{error::ResponseError, http::StatusCode, HttpResponse}; use thiserror::Error; use crate::common::errors::error_response::{ErrorResponse, ErrorBody}; #[derive(Error, Debug)] pub enum ServiceError { #[error("Invalid field: {field}. Expected: {expected}.")] Validation { field: String, expected: Str...
true
a6a4f80a70cbe7262ef5018de459e28b4f246432
Rust
mjochimsen/echoip
/src/client.rs
UTF-8
4,877
3.0625
3
[ "MIT" ]
permissive
use std::net::*; use std::time::Duration; use std::process::exit; use super::error::Error; use super::error::Error::*; const RECV_TIMEOUT: u64 = 5; pub fn client(server_addr: Ipv4Addr, port: u16) { // Bind client socket. let socket = match bind_socket() { Ok(socket) => socket, Err(e) => { ...
true
6e3aec576dbb609fbff52a25b7945e89511b5c31
Rust
thorhs/mk66f18
/src/uart4/s1.rs
UTF-8
10,459
2.578125
3
[ "MIT" ]
permissive
#[doc = "Reader of register S1"] pub type R = crate::R<u8, super::S1>; #[doc = "Parity Error Flag\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] pub enum PF_A { #[doc = "0: No parity error detected since the last time this flag was cleared. If the receive buffer has a depth greater than 1, then the...
true
54507a9652cec391f8244c03de5b2b3fb45732a6
Rust
baitcenter/movieapp
/src/model.rs
UTF-8
1,563
2.515625
3
[]
no_license
use mongodb::coll::results::InsertOneResult; use mongodb::db::{Database, ThreadedDatabase}; use mongodb::oid::ObjectId; use mongodb::Error; use r2d2::{Pool, PooledConnection}; use r2d2_mongodb::MongodbConnectionManager; pub type APIKey = String; pub type MongoPool = Pool<MongodbConnectionManager>; type MongoPooledCon...
true
81abbfe942a6783b126d525c25880e8467bf1556
Rust
christopherferreira19/multitap
/multitap-daemon/src/daemon/ports.rs
UTF-8
1,844
2.90625
3
[]
no_license
use crate::prelude::*; use slab::Slab; use port::Port; pub struct Ports { ports: Slab<Port>, } impl Ports { pub fn new(config: &config::Config) -> Self { let mut ports = Slab::with_capacity(64); for config_port in &config.ports { for slot in &config_port.slots { l...
true
2dc501d19238bc47dc63f653ed0dde5b856ad505
Rust
eatonphil/jx
/src/class/mod.rs
UTF-8
11,730
2.875
3
[]
no_license
fn consume_u8(b: &Vec<u8>, cursor: usize) -> (u8, usize) { (b[cursor], cursor + 1) } fn consume_u16(b: &Vec<u8>, cursor: usize) -> (u16, usize) { let (left, cursor) = consume_u8(b, cursor); let (right, cursor) = consume_u8(b, cursor); (((left as u16) << 8) | (right as u16), cursor) } fn consume_u32(b:...
true
1d874244a5041dc4080e37d7ffb1468042d9fdb1
Rust
dodiameer/dodiplate
/src/utils.rs
UTF-8
454
3.078125
3
[]
no_license
use std::error::Error; use std::io::{stdin, stdout, Write}; // This is so overenginnered but I could only get it to work this way pub fn input(msg: &str) -> Result<String, Box<dyn Error>> { let output = stdout(); let mut handle = output.lock(); handle.write(msg.as_bytes())?; handle.write(b": ")?; h...
true
ad017085868b825a65e5ec121ed7cf77f281efff
Rust
StoriqaTeam/gateway
/src/graphql/models/company_package.rs
UTF-8
3,306
2.65625
3
[]
no_license
use stq_types::{CompanyId, CompanyPackageId, PackageId}; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct CompaniesPackages { pub id: CompanyPackageId, pub company_id: CompanyId, pub package_id: PackageId, } #[derive(GraphQLInputObject, Serialize, Debug, Clone, PartialEq)] #[graphql(description ...
true
b6b5c106fff7fe51fa0c55803d89a08c2369210e
Rust
IThawk/rust-project
/rust-master/src/test/ui/macros/macro-pat-neg-lit.rs
UTF-8
497
2.765625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// run-pass macro_rules! enum_number { ($name:ident { $($variant:ident = $value:expr, )* }) => { enum $name { $($variant = $value,)* } fn foo(value: i32) -> Option<$name> { match value { $( $value => Some($name::$variant), )* _ => None...
true
cca543a6e2db7bc7ae394d627f7f9d79a0506df6
Rust
zargony/advent-of-code-2015
/src/day08.rs
UTF-8
2,376
3.21875
3
[]
no_license
extern crate onig; use onig::Regex; pub fn raw_and_unescaped_len(s: &str) -> (usize, usize) { if s.chars().nth(0) != Some('"') || s.chars().last() != Some('"') { panic!("invalid format (not quoted)"); } let raw_len = s.len(); let re = Regex::new(r#"\\(\\|"|x[0-9a-f]{2})"#).unwrap(); let ss...
true
4570fe23ef790cf7c16c55c1101db28145251946
Rust
redsnapper2006/leetcode-cn
/M/2363-merge-similar-items/main.rs
UTF-8
782
3.234375
3
[]
no_license
struct Solution {} use std::collections::HashMap; impl Solution { pub fn merge_similar_items(items1: Vec<Vec<i32>>, items2: Vec<Vec<i32>>) -> Vec<Vec<i32>> { let mut m: HashMap<i32, i32> = HashMap::new(); for item in items1 { m.insert(item[0], item[1]); } for item in items2 { if m.contai...
true
7d8b2a193d47f70aa13a96398eb0d19f62d7b90e
Rust
balena-io-modules/balena-temen
/src/context.rs
UTF-8
1,479
3.203125
3
[ "Apache-2.0" ]
permissive
#[cfg(target_arch = "wasm32")] use chrono::NaiveDateTime; use chrono::{DateTime, Utc}; #[cfg(not(target_arch = "wasm32"))] fn utc_now() -> DateTime<Utc> { Utc::now() } // chrono crate doesn't support wasm32 arch yet, workaround #[cfg(target_arch = "wasm32")] fn utc_now() -> DateTime<Utc> { let now = js_sys::D...
true
011736375f99f5e4cc4dd21ac03ea0074780ac71
Rust
hargoniX/at42qt1070
/src/lib.rs
UTF-8
2,238
2.796875
3
[]
no_license
#![no_std] use bitfield::bitfield; use embedded_hal::blocking::i2c::{Write, WriteRead}; #[derive(Clone, Copy, Debug)] pub enum Error<I2cError> { I2cError(I2cError), IdMismatch(u8), } impl<E> From<E> for Error<E> { fn from(error: E) -> Self { Error::I2cError(error) } } bitfield! { pub stru...
true
df162d4d4f1cdda4e27052c1f14edde3b027fee7
Rust
pavel-mukhanov/noise
/src/noise_codec.rs
UTF-8
2,275
2.734375
3
[]
no_license
use byteorder::{BigEndian,LittleEndian, ByteOrder}; use bytes::BytesMut; use snow::Session; use std::io; use tokio_io::codec::{Decoder, Encoder}; use wrapper::NoiseWrapper; #[allow(dead_code)] pub struct MessagesCodec { max_message_len: u32, session: NoiseWrapper, } impl MessagesCodec { pub fn new(session...
true
b0f3df94ea15ad5d21d34476cd4ac2981c7d4b2b
Rust
yenicelik/wolfofcrypto
/src/coinmarketcap/coinmarketcap.rs
UTF-8
1,837
2.796875
3
[]
no_license
use std::{thread, time}; use tokio_core::reactor::Core; use hyper::Client; use hyper_tls::HttpsConnector; use serde_json; use serde_json::Value; use failure::Error; use futures::{Future, Stream}; const RATE_LIMIT_CENTISECONDS: u64 = 20; pub fn send_request(currency: &str, start: i64, offset: i64) -> Result<Value, Err...
true
75cfe9947504d7b72867fbb80831c422cde3d543
Rust
azriel91/cli_async
/src/reporter.rs
UTF-8
8,852
2.828125
3
[]
no_license
use std::{fmt, fmt::Write as _, io, io::Write as _}; use indicatif::{ProgressBar, ProgressStyle}; use tokio::sync::mpsc::{Receiver, UnboundedReceiver}; use crate::{Colours, PropertyInfoResult, Report}; #[derive(Debug)] pub struct Reporter { /// `ProgressBar` for the overall progress. progress_overall: Progre...
true
e9dd9662fdc74df8926704f78c1870e5f08b8bb3
Rust
boa-dev/boa
/boa_ast/src/statement_list.rs
UTF-8
5,584
3.578125
4
[ "MIT", "Unlicense" ]
permissive
//! Statement list node. use super::Declaration; use crate::{ statement::Statement, try_break, visitor::{VisitWith, Visitor, VisitorMut}, }; use boa_interner::{Interner, ToIndentedString}; use core::ops::ControlFlow; use std::ops::Deref; /// An item inside a [`StatementList`] Parse Node, as defined by the...
true
f45b91a25d2d51762386a9a431aecb93ce9345e3
Rust
Ninjani/rosalind
/s_fib/src/lib.rs
UTF-8
1,263
3.359375
3
[ "MIT" ]
permissive
use anyhow::Error; use std::path::Path; use utility::io::Parseable; /// Rabbits and Recurrence Relations /// /// Given: Positive integers n≤40 and k≤5. /// /// Return: The total number of rabbit pairs that will be present after n months, if we begin with 1 pair and in each generation, every pair of reproduction-age r...
true
c86a9ab1ebfbd8f9d8e37ea2c47722daccbd85c2
Rust
smith-win/rust-learning
/queues/tests/integration_tests.rs
UTF-8
914
3.359375
3
[]
no_license
extern crate queue; use std::thread; use std::time::Duration; use queue::threadq::ThreadQueue; // integration tests /// Create a q and push / pop from if #[test] pub fn check_single_thread_iteration() { // create a queue and then try iteration from it let mut q: ThreadQueue<u8> = ThreadQueue::new(100 as us...
true
71d4b56c650a2af45118cce080ff433663e04ed2
Rust
SINHASantos/billing
/src/repos/invoice.rs
UTF-8
5,812
2.515625
3
[]
no_license
//! Invoices repo, presents CRUD operations with db for invoice use diesel; use diesel::connection::AnsiTransactionManager; use diesel::pg::Pg; use diesel::prelude::*; use diesel::query_dsl::RunQueryDsl; use diesel::Connection; use failure::Error as FailureError; use failure::Fail; use stq_types::{InvoiceId, SagaId, U...
true
a89143ad1b2ad7cb37f1120d95705cad32c9ee2a
Rust
ysaito1001/pna-rust
/project-3/src/server.rs
UTF-8
2,348
2.953125
3
[]
no_license
use crate::error::Result; use crate::request::Request; use crate::response::{GetResponse, RemoveResponse, SetResponse}; use crate::KvsEngine; use log::{debug, error}; use serde_json::Deserializer; use std::io::{BufReader, BufWriter, Write}; use std::net::{TcpListener, TcpStream, ToSocketAddrs}; pub struct KvsServer<...
true
e4cbc3c477ca905acd0103d024b38db68eed4550
Rust
coolreader18/rsspire
/src/cstr.rs
UTF-8
1,361
3.078125
3
[]
no_license
use crate::prelude::*; pub struct CString { string: String, } impl CString { pub fn new(mut string: String) -> CString { string.push('\0'); CString { string } } pub unsafe fn from_ptr(ptr: *const u8) -> CString { let mut string = String::new(); let mut i = 0; l...
true
84dc7e4095953ce7eb521417753466467867420c
Rust
zhangmingkai4315/histogram
/src/lib.rs
UTF-8
11,469
3.453125
3
[ "MIT" ]
permissive
extern crate rand; use linked_list::LinkedList; use std::ops::Add; #[derive(Debug)] struct Bin { value: f64, count: usize, } /// A Histogram struct include a double linklist and some attributes for manage data. /// using linkedList for fast insert and merge items in a sorted data structure #[derive(Debug)] p...
true
2215f0cc63321ec7afb380c897b63b6ea49918ad
Rust
redstrike/paddlers-browser-game
/paddlers-frontend/src/game/town/nests.rs
UTF-8
1,774
2.546875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::game::components::NetObj; use crate::game::town::*; use crate::net::game_master_api::RestApiState; use crate::net::state::current_village; use paddlers_shared_lib::api::attacks::InvitationDescriptor; use specs::prelude::*; #[derive(Component, Debug, Clone)] #[storage(VecStorage)] /// A nest can provide spac...
true
43ad11913f6f873e990032b77fd89aa0a450e10d
Rust
timotheosh/exercism-exercises
/rust/raindrops/src/lib.rs
UTF-8
476
3.3125
3
[ "MIT" ]
permissive
pub fn raindrops(number: u32) -> String { let mut response = String::from(""); let is_divisible_by = |y: u32| -> bool { number % y == 0 }; if is_divisible_by(3) { response.push_str("Pling"); } if is_divisible_by(5) { response.push_str("Plang"); } if is_divisible_b...
true
4415a005ad159d43e92cb7ef0988761ea241c61f
Rust
zaeleus/noodles
/noodles-cram/src/data_container/compression_header.rs
UTF-8
1,567
2.765625
3
[ "MIT" ]
permissive
//! CRAM data container compress header. mod builder; pub mod data_series_encoding_map; pub(crate) mod encoding; pub mod preservation_map; mod tag_encoding_map; pub(crate) use self::{ builder::Builder, data_series_encoding_map::DataSeriesEncodingMap, encoding::Encoding, preservation_map::{Preservation...
true
b2820fa9867a7083f1654ea6abd24bdb8a893c83
Rust
Blockchain-Laboratories-LLC/xrpl-hook-template
/examples/doubler/main.rs
UTF-8
2,623
2.59375
3
[]
no_license
//! A joke hook that doubles incoming XRP payments //! and sends it back #![no_std] #![no_main] use core::ops::Range; use xrpl_hooks::*; const GUARD_ID_1: u32 = line!(); #[no_mangle] pub extern "C" fn cbak(_: i64) -> i64 { 0 } #[no_mangle] pub extern "C" fn hook(_: i64) -> i64 { let mut hook_acc_id: Acco...
true
b46e18c349a44adc46836b7506d8f1ccbcde10aa
Rust
Nanica0/Nonica
/src/main.rs
UTF-8
3,156
2.515625
3
[]
no_license
use inkwell::{ context::Context, module::Linkage, AddressSpace }; fn main() { let context = Context::create(); let module = context.create_module("main"); let builder = context.create_builder(); let i32_type = context.i32_type(); let i32_ptr_type = i32_type.ptr_type(AddressSpace::Generi...
true
c96547384141405505d36a9ec0a38328a25f41f0
Rust
Rantanen/protoc-gen-constructors
/src/context.rs
UTF-8
8,734
2.859375
3
[]
no_license
use crate::protos; use crate::spec; use crate::internal_utils::DescriptorProtoExt; /// Holds context information for the whole plugin invocation. #[derive(Clone, Copy)] pub struct PluginContext<'a> { /// Code generator request passed in by protoc. pub request : &'a protos::plugin::CodeGeneratorRequest, /...
true
a1c6babd7ff7b43c58678d9cc2f9a12cc761e8ec
Rust
pierrechevalier83/rwm
/src/cmd.rs
UTF-8
457
2.890625
3
[]
no_license
use std; pub struct Cmd { pub name: std::string::String, pub args: std::vec::Vec<std::string::String>, } impl Cmd { pub fn new(slice: &[&str]) -> Cmd { if let Some((name, args)) = slice.split_first() { return Cmd { name: name.to_string(), args: args.iter(...
true
bc0faacf319ffde4e25d8c8e966783a4ac7e01eb
Rust
lapce/lapce
/lapce-core/src/soft_tab.rs
UTF-8
7,324
3.78125
4
[ "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
use lapce_xi_rope::Rope; /// The direction to snap. Left is used when moving left, Right when moving right. /// Nearest is used for mouse selection. pub enum SnapDirection { Left, Right, Nearest, } /// If the cursor is inside a soft tab at the start of the line, snap it to the /// nearest, left or right e...
true
e9a9b4456a243cf5cb0318937d2510debf4cd3d0
Rust
rebo/kalk
/kalk/src/symbol_table.rs
UTF-8
1,067
3.046875
3
[ "MIT" ]
permissive
use crate::{ast::Stmt, prelude}; use std::collections::HashMap; pub struct SymbolTable { hashmap: HashMap<String, Stmt>, } impl SymbolTable { pub fn new() -> Self { SymbolTable { hashmap: HashMap::new(), } } pub fn insert(&mut self, key: &str, value: Stmt) { self.h...
true
294a7f873de94bda39c8da6d588fdeb3dbdf28f6
Rust
adventofcode/2015solutions
/day10/p2b.rs
UTF-8
855
2.90625
3
[]
no_license
//! This file is in the [cargo-script][1] format. //! //! [1]: https://github.com/DanielKeep/cargo-script //! //! ```cargo //! [dependencies] //! itertools = "^0.4" //! ``` #![feature(io)] #[macro_use] extern crate itertools; use itertools::Itertools; use std::io::{self, Read}; fn rle(inp: Vec<u8>) -> Vec<u8> { ...
true
d48196c98e2fffeae083b83fb66eec47ca2e37ea
Rust
shadow/shadow
/src/main/core/logger/shadow_logger.rs
UTF-8
17,077
2.671875
3
[ "LicenseRef-scancode-public-domain" ]
permissive
use std::cell::RefCell; use std::sync::mpsc::{Receiver, Sender}; use std::sync::Arc; use std::sync::{Mutex, RwLock}; use std::time::Duration; use crossbeam::queue::ArrayQueue; use log::{Level, LevelFilter, Log, Metadata, Record, SetLoggerError}; use logger as c_log; use once_cell::sync::{Lazy, OnceCell}; use shadow_sh...
true
b278db7eec33a32521753490496711124ab09a54
Rust
PistonDevelopers/meta
/examples/neg_match.rs
UTF-8
953
3.140625
3
[ "MIT" ]
permissive
/* This example shows how to use negative matching on tokens. For example: !"hi":"hi_did_not_occured" This rule generates: "hi_did_not_occured":true when "hi" was *not* parsed. One can also use double negative for simplicity: !"hi":!"hi" This will generate: "hi":false */ extern crate piston_...
true
67c95c10d4be23471f73cbbcdc494796e56105a0
Rust
dancrossnyc/rxv64
/kernel/src/console.rs
UTF-8
7,525
2.859375
3
[ "MIT" ]
permissive
use crate::cga::Cga; use crate::file::{self, File}; use crate::proc; use crate::spinlock::SpinMutex as Mutex; use crate::uart::Uart; use crate::Result; use core::fmt; use syslib::stat::{FileType, Stat}; const fn ctrl(b: u8) -> u8 { b - b'@' } const BACKSPACE: u8 = ctrl(b'H'); const DELETE: u8 = 0x7F; const CTLD: ...
true
95c664c493e9934fc46f6901c6ed1e7abc5eef5d
Rust
martell/tokio
/tokio/src/runtime/blocking.rs
UTF-8
1,089
2.921875
3
[ "MIT" ]
permissive
//! Abstracts out the APIs necessary to `Runtime` for integrating the blocking //! pool. When the `blocking` feature flag is **not** enabled. These APIs are //! shells. This isolates the complexity of dealing with conditional //! compilation. cfg_blocking_impl! { pub(crate) use crate::blocking::BlockingPool; p...
true
8d24af2be7f69419a3307907a71e6ed1f9fb69de
Rust
andrei-papou/polars
/polars/src/lazy/frame.rs
UTF-8
2,930
3.046875
3
[ "MIT" ]
permissive
use crate::{lazy::prelude::*, prelude::*}; impl DataFrame { /// Convert the `DataFrame` into a lazy `DataFrame` pub fn lazy(self) -> LazyFrame { LogicalPlanBuilder::from_existing_df(self).build().into() } } /// abstraction over a logical plan pub struct LazyFrame { logical_plan: LogicalPlan, }...
true
2073742f682dccc4555547054915dd47173a608b
Rust
quantumscraps/scraps
/src/driver_interfaces.rs
UTF-8
1,728
3.1875
3
[]
no_license
use core::fmt::{Debug, Write}; use crate::drivers::ns16550a::NS16550A; /// A UART that can be written to. pub trait Uart: Write { /// Initializes the UART. /// This function must be safe to call multiple times. fn init(&mut self); /// Gets an input byte, if any. fn get(&mut self) -> Option<u8>; ...
true
369a60b75042154b65fd2c13fbf5a8c8a6bfef98
Rust
doomline/two_week_rust
/projects/structs/src/reference.rs
UTF-8
2,387
3.984375
4
[]
no_license
// Structs are similar to tuples, you can use multiple data types // structs require you to name each piece of data with values // Naming convention as follows -> struct <Name> {Data: Datatype} //defined the parameters of the struct named "User" struct User { username: String, email: String, sign_in_coun...
true
96f36d108eded8086e972e18b7375b52e9da342a
Rust
asyade/glola
/artnet/src/command/output.rs
UTF-8
2,911
3
3
[]
no_license
use crate::command::ARTNET_PROTOCOL_VERSION; data_structure! { #[derive(Debug)] #[doc = "ArtDmx is the data packet used to transfer DMX512 data. The format is identical for Node to Controller, Node to Node and Controller to Node."] #[doc = ""] #[doc = "The Data is output through the DMX O/P port corres...
true
d9c584e1fec950a81f5c294b8909b990894602f7
Rust
Orlha/bright-red
/src/ext.rs
UTF-8
2,113
2.96875
3
[]
no_license
use std::fmt; use std::fs::File; use std::io::Read; use std::io; use std::error; pub type Result<T> = std::result::Result<T, Box<dyn error::Error>>; pub const ENERGY_TOP: i64 = 10; pub const ENERGY_DROP: i64 = 1; pub const CMD_SIZE: usize = 4; pub const DIR_SIZE: usize = 4; #[derive(Copy, Clone)] pub enum State { Cr...
true
e5540f6a2be91c4295bfbd7cdd7fd21b4377b07f
Rust
itdaniher/ratpak
/stage2.rs
UTF-8
8,379
2.671875
3
[]
no_license
#![feature(globs)] extern crate serialize; extern crate syntax; extern crate abstrast; extern crate graphviz; use graphviz::maybe_owned_vec::IntoMaybeOwnedVector; use std::string::String; use std::io::File; use std::path::Path; use abstrast::*; use syntax::ast; use syntax::ptr; use serialize::{json, Encodable, Decoda...
true
72060b998989a1e8aaf0ef5ba61ab505b7a62cf2
Rust
daniel-goldstein/advent-of-code-2020
/src/day7.rs
UTF-8
1,742
3.09375
3
[]
no_license
use crate::utils::read_input_to_string; use regex::Regex; use std::collections::{HashMap, HashSet}; type BagGraph<'a> = HashMap<&'a str, HashSet<(String, u32)>>; pub fn day7() { println!("DAY 7"); let input = read_input_to_string(String::from("day7")); let graph = read_input(&input); println!("{:#?}",...
true
48f8a43a8d6465258ed1daa3482c27997b061923
Rust
relick/aoc18
/aoc18/src/day1.rs
UTF-8
1,488
2.84375
3
[]
no_license
use std::collections::HashSet; use itertools::Itertools; pub fn solve1(input_text: &str) -> Result<String, &'static str> { let mut total: i64 = 0; for freq_str in input_text.lines() { total += freq_str.parse::<i64>().unwrap(); } Ok(total.to_string()) } pub fn solve2(input_text: &str) -> Result<String, &'static ...
true
3b276ab3684df1313b33033e6cc8af1ffb2bcdf1
Rust
fimbaz/rshrub
/shash/src/ui/worldview.rs
UTF-8
4,067
2.75
3
[]
no_license
use rect::{Pos,HasPos,Region,BucketPos}; use grid::GridCell; use tile::Tile; use boring_game::game::BoringGame; use rustty::Cell; use rustty::{Size,HasSize,Attr}; use rustty::ui::core::{Widget,Frame,HorizontalAlign,VerticalAlign,Painter,Alignable}; use rustty::{CellAccessor}; pub struct WorldView { pub origin: Pos,...
true
2b65ef30cb4b87041895a674a0c33bb502bb1e2b
Rust
IThawk/rust-project
/rust-master/src/test/ui/no_share-enum.rs
UTF-8
276
2.828125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![feature(optin_builtin_traits)] use std::marker::Sync; struct NoSync; impl !Sync for NoSync {} enum Foo { A(NoSync) } fn bar<T: Sync>(_: T) {} fn main() { let x = Foo::A(NoSync); bar(x); //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] }
true
a969b1f52a3c8b6c845300890f880598350ced85
Rust
phlip9/aoc20
/src/day9.rs
UTF-8
2,341
3.203125
3
[]
no_license
use anyhow::{Context, Result}; use std::{ collections::{HashSet, VecDeque}, fs, iter::FromIterator, }; const PREAMBLE_LEN: usize = 25; fn has_two_sum(inputs: &HashSet<u64>, sum: u64) -> bool { for x in inputs.iter().copied() { if x >= sum { continue; } let y = sum -...
true