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
29362ea9c37e72e1d817ffa5667c9839ac65598b
Rust
astrberg/d7050e
/compiler/src/type_checker.rs
UTF-8
8,022
3.15625
3
[]
no_license
use std::collections::HashMap; use crate::ast::*; use crate::types::Type; use crate::error::Error; #[derive(Debug, Default, Clone)] pub struct Scope { pub scope: HashMap<String, Type>, } impl Scope { fn new() -> Self { Scope { scope: HashMap::new() } } } #[derive(Debug...
true
0901a3e4a7f421da9431c07c35ee24553d66fb8c
Rust
zyla/dbstuff
/conc/src/lib.rs
UTF-8
1,816
3.21875
3
[]
no_license
use loom::sync::atomic::{AtomicUsize, Ordering::*}; use std::hash::Hash; use std::sync::Arc; pub struct Entry { key: AtomicUsize, value: AtomicUsize, } #[test] fn test_outcomes_should_be_the_same() { assert_eq!(run_example(false), run_example(true)); } fn run_example(with_extra_load: bool) -> Vec<(usize,...
true
1e383caaff0b32f995f7fc3a526f66293a01d410
Rust
p0lunin/compile_type_eq
/src/lib.rs
UTF-8
1,494
3.5625
4
[]
no_license
//! This crate help you check type equality at compile time. //! //! Usage: //! //! ```rust //! use compile_type_eq::*; //! //! assert_types_eq::<i32, i32>(); //! assert_types_not_eq::<i32, u32, _>(); //! ``` //! //! ```compile_fail //! use compile_type_eq::*; //! //! assert_types_eq::<i32, u32>(); //! assert_types_not...
true
c2af0dfad1e9df07c66207864aca1d307f1acc4c
Rust
believer/advent-of-code
/rust/2015/src/day_03.rs
UTF-8
3,609
3.8125
4
[ "Unlicense" ]
permissive
// Day 3 - Perfectly Spherical Houses in a Vacuum // // Pretty simple movements in a grid. Then just count the number of // coordinates visited. // // Updates: // // I was using a HashMap to store coordinates AND presents. Turns out // that I don't need the presents. So I changed it to a HashSet. // I also used with_ca...
true
98e9ece311c5ae98e05b9a5f3cc9b59c0026571b
Rust
rust-lang/rust
/src/tools/clippy/tests/ui/fn_to_numeric_cast_any.rs
UTF-8
2,592
2.8125
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
#![warn(clippy::fn_to_numeric_cast_any)] #![allow(clippy::fn_to_numeric_cast, clippy::fn_to_numeric_cast_with_truncation)] //@no-rustfix fn foo() -> u8 { 0 } fn generic_foo<T>(x: T) -> T { x } trait Trait { fn static_method() -> u32 { 2 } } struct Struct; impl Trait for Struct {} fn fn_poin...
true
10fbcd25cd780f45807d93c80ee255128bb4f6ad
Rust
astral-sh/ruff
/crates/ruff/src/rules/flake8_pytest_style/types.rs
UTF-8
1,967
2.515625
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use std::fmt::{Display, Formatter}; use serde::{Deserialize, Serialize}; use ruff_macros::CacheKey; #[derive(Clone, Copy, Debug, CacheKey, PartialEq, Eq, Serialize, Deserialize)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] pub enum ParametrizeNameType { #[serde(rename = "csv")] Csv, #...
true
4e3e057373bef4d48055ac68905a5344a9d7f528
Rust
andyyu2004/mp
/mp-client/src/ui/components/sidebar.rs
UTF-8
1,493
2.625
3
[]
no_license
use crate::ui::render::Render; use tui::layout::{Constraint, Corner, Direction, Layout}; use tui::style::{Color, Modifier, Style}; use tui::widgets::*; pub(crate) struct Sidebar; impl Render for Sidebar { fn render<B>(&mut self, f: &mut tui::Frame<B>, rect: tui::layout::Rect, state: &crate::ClientState) where...
true
296d4bbc6f9a27a2713b4a58d0044bffb50e2b56
Rust
SuperiorJT/twilight
/http/src/request/channel/webhook/get_webhook_message.rs
UTF-8
1,320
2.90625
3
[ "ISC" ]
permissive
use crate::{client::Client, request::Request, response::ResponseFuture, routing::Route}; use twilight_model::{ channel::Message, id::{MessageId, WebhookId}, }; /// Get a webhook message by [`WebhookId`], token, and [`MessageId`]. /// /// [`WebhookId`]: twilight_model::id::WebhookId /// [`MessageId`]: twilight_...
true
693025c30fc25a85b9aa814a0092003d78b366e5
Rust
nushell/nushell
/crates/nu-command/src/math/round.rs
UTF-8
4,360
3
3
[ "MIT" ]
permissive
use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, }; #[derive(Clone)] pub struct SubCommand; impl Command for SubCommand { fn name(&self) -> &str...
true
34793e077dfd17fd9687339bad9c61f49d99d434
Rust
dnsl48/yamlette
/tests/examples/face.rs
UTF-8
5,426
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
#[cfg (all (test, not (feature = "dev")))] mod stable { extern crate yamlette; #[test] fn example_extra_yaml_rust () { let should_be = Some (r#"foo: - list1 - list2 bar: - 1 - 2.0"#); yamlette! ( read ; should_be.as_ref ().unwrap ().clone () ; [[ { "foo" => ...
true
40e16d8c93cdd24f1b4fa0633f46ee0048c0e539
Rust
sagudev/AOC_2020
/src/bin/day14.rs
UTF-8
5,783
3.125
3
[]
no_license
use aoc::read_data; use std::collections::HashMap; use std::error::Error; #[derive(Debug)] // loc, binary struct Mem(String, String); #[derive(Debug)] struct Section { mask: String, mem: Vec<Mem>, } impl Section { fn from_v(v: Vec<String>) -> Self { let mut mem = Vec::new(); for d in v.it...
true
297cb3f4e9a0391958017c95a54da6b1e1c5b708
Rust
danleechina/Leetcode
/Rust_Sol/src/archive0/s274.rs
UTF-8
628
2.859375
3
[]
no_license
struct Solution {} impl Solution { pub fn h_index(citations: Vec<i32>) -> i32 { let mut res = 0; let mut citations = citations; citations.sort(); let len = citations.len(); for (index, item) in citations.iter().enumerate() { let item = *item as usize; if item == 0 { continue; ...
true
4614858ff5df997c7688af6000a0ef05a41060f4
Rust
katakanan/td4-emu
/src/opecode.rs
UTF-8
317
2.6875
3
[]
no_license
use num_derive::FromPrimitive; #[derive(Debug, FromPrimitive, PartialEq)] pub enum Opecode { ADD2A = 0b0000, ADD2B = 0b0101, MOV2A = 0b0011, MOV2B = 0b0111, MOVA2B = 0b0001, JMP = 0b1111, JNC = 0b1110, INA = 0b0010, INB = 0b0110, OUTB = 0b1001, OUTIM = 0b1011, NOP, }
true
6275f5ffe3a45e191f256d79ef9c817b3b9f6402
Rust
chinagxwei/learn-rust-by-leetcode
/src/problems_31_to_40/problems_31_next_permutation.rs
UTF-8
1,863
3.78125
4
[]
no_license
/// 31. /// /// 实现获取下一个排列的函数,算法需要将给定数字序列重新排列成字典序中下一个更大的排列。 /// /// 如果不存在下一个更大的排列,则将数字重新排列成最小的排列(即升序排列)。 /// /// 必须原地修改,只允许使用额外常数空间。 /// /// 以下是一些例子,输入位于左侧列,其相应输出位于右侧列。 /// 1,2,3 → 1,3,2 /// 3,2,1 → 1,2,3 /// 1,1,5 → 1,5,1 /// /// 来源:力扣(LeetCode) /// 链接:https://leetcode-cn.com/problems/next-permutation /// 著作权归领扣网络所有。商业...
true
d9dd3a573c6d1a8fc82c72d923595dfe0de313cc
Rust
cjgu/rust_cryptopals
/src/utils/mod.rs
UTF-8
10,996
3.28125
3
[]
no_license
use std::collections::HashSet; use std::fs::File; use std::io::BufRead; use std::io::BufReader; pub fn decode_hex(hex_str: &str) -> Option<Vec<u8>> { let len = hex_str.len(); assert_eq!(len % 2, 0); let mut v: Vec<u8> = Vec::with_capacity(len / 2); let mut prev: u8 = 0; for (i, c) in hex_str.cha...
true
f3a15251f14cd772159b0bad4bbe95cc842ffd5c
Rust
isgasho/klickhouse
/klickhouse/src/types/deserialize/nullable.rs
UTF-8
1,911
2.734375
3
[]
no_license
use anyhow::*; use tokio::io::AsyncReadExt; use crate::{io::ClickhouseRead, values::Value}; use super::{Deserializer, DeserializerState, Type}; pub struct NullableDeserializer; #[async_trait::async_trait] impl Deserializer for NullableDeserializer { async fn read_prefix<R: ClickhouseRead>( type_: &Type,...
true
fd7c2344fe4b3e10296e236d9e564c952fd01d1e
Rust
chromium/chromium
/third_party/rust/regex_syntax/v0_6/crate/src/either.rs
UTF-8
194
3.296875
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "BSD-3-Clause" ]
permissive
/// A simple binary sum type. /// /// This is occasionally useful in an ad hoc fashion. #[derive(Clone, Debug, Eq, PartialEq)] pub enum Either<Left, Right> { Left(Left), Right(Right), }
true
aaa61beda854aa6be96f3ed939e717de2786b0cd
Rust
MrrRaph/Nadnap
/src/validators/fs/mod.rs
UTF-8
212
2.9375
3
[]
permissive
use std::path::Path; pub fn is_file(v: String) -> Result<(), String> { match Path::new(v.as_str()).is_file() { true => { Ok(()) } false => { Err(format!("{} isn't a valid file", v)) } } }
true
1b3fe18869bfdcf2291d784b98525a618fa0d420
Rust
HectorIGH/Competitive-Programming
/Leetcode Challenge/09_September_2020/Rust/Week 1/2_Contains Duplicate III.rs
UTF-8
1,589
3.390625
3
[]
no_license
//Given an array of integers, find out whether there are two distinct indices i and j in the array such that the absolute difference between nums[i] and nums[j] is at most t and the absolute difference between i and j is at most k. // //Example 1: // //Input: nums = [1,2,3,1], k = 3, t = 0 //Output: true //Example 2: /...
true
0e8c8bf3ad20b6d62a2cd0a1cf25dca1629d2dde
Rust
sapsan4eg/rust-websocket
/src/sender.rs
UTF-8
2,272
3.234375
3
[ "MIT" ]
permissive
//! The default implementation of a WebSocket Sender. use std::io::Write; use std::io::Result as IoResult; use result::WebSocketResult; use ws::dataframe::DataFrame; use stream::AsTcpStream; use ws; use ws::sender::Sender as SenderTrait; pub use stream::Shutdown; /// A writer that bundles a stream with a serializer t...
true
9bb4cb32ef5c3a0d82f47c8ed567a411e0fc578e
Rust
robjtede/actix-web
/actix-http/src/body/message_body.rs
UTF-8
4,974
2.90625
3
[ "Apache-2.0", "MIT" ]
permissive
//! [`MessageBody`] trait and foreign implementations. use std::{ convert::Infallible, mem, pin::Pin, task::{Context, Poll}, }; use bytes::{Bytes, BytesMut}; use futures_core::ready; use pin_project_lite::pin_project; use super::BodySize; /// An interface for response bodies. pub trait MessageBody {...
true
d1c55d99397fc087a907a1a7e033473102c0c902
Rust
Bunogi/c8asm
/src/preprocessor.rs
UTF-8
3,603
3.46875
3
[ "MIT" ]
permissive
use std::vec::Vec; use std::string::String; use std::collections::HashMap; //Returns a string with comments removed, with everything in lowercase pub fn sanitize_line(input: &mut String) { while let Some(i) = input.find(',') { input.remove(i); } match input.find(';') { Some(i) => *input = ...
true
e82e93836eed312eb3af361ddb5433150fea3717
Rust
munckymagik/redis-clone
/src/commands.rs
UTF-8
5,771
2.671875
3
[]
no_license
use crate::{ db::Database, errors::Result, request::Request, response::Response, response_ext::ResponseExt, }; use byte_string::ByteStr; mod hash_type; mod keyspace; mod list_type; mod server; mod string_type; type RedisCommandProc = fn(db: &mut Database, req: &Request, resp: &mut Response) -> Result<()>; pub st...
true
790d2052d12b7bb349f6b27078097493288509e8
Rust
wangchao0502/rust-leetcode
/src/p514_find_rotate_steps.rs
UTF-8
2,856
3.25
3
[]
no_license
#![allow(dead_code)] // use mods pub struct Solution {} // add structs // answers impl Solution { pub fn p514_find_rotate_steps(ring: String, key: String) -> i32 { let (ring, key) = (ring.into_bytes(), key.into_bytes()); let n = ring.len(); let m = key.len(); // 解释m为什么要+1,因为m表示ke...
true
0f36e1fa78ba963f11765f43d249d5d0b518bdc9
Rust
Disasm/zissou
/stm32-rs/stm32l4/src/stm32l4x5/rcc/cr.rs
UTF-8
30,714
2.78125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CR { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W)...
true
6bc90f431eb2a26bce7b37319796db7bca9f9bee
Rust
keram88/smack
/test/rust/incr_test_rust.rs
UTF-8
501
2.78125
3
[ "MIT" ]
permissive
/*extern {fn __VERIFIER_assert(x: i32);} #[macro_export] macro_rules! assert { ( $cond:expr ) => ( unsafe {__VERIFIER_assert($cond as i32);} ) } #[macro_export] macro_rules! assert_eq { ( $lhs:expr, $rhs:expr ) => ( assert!($lhs == $rhs); ) }*/ extern { fn incr(i: *mut u32) -> (); } fn main() { let...
true
143815a93e56fda7ba402bc49a1e6e030cc0a7ae
Rust
cderwin/hack-tools
/src/assembler/tokenizer.rs
UTF-8
1,186
2.703125
3
[ "MIT" ]
permissive
// // Assembler grammmar // // program := { line, "\n" } // line := instruction | lebel | comment | "" // // label := "(", identifier, ")" // identifier := sequence of letters, number, and underscores s.t. the first character is a letter // // instruction := a-instruction | c-instruction // a-instruction := "@...
true
458354b0dfb66aafa24f983cd225b030d0e4f9e3
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/gpu-alloc-types/src/device.rs
UTF-8
2,263
2.640625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use { crate::types::{MemoryHeap, MemoryType}, alloc::borrow::Cow, core::ptr::NonNull, }; #[derive(Debug)] pub enum OutOfMemory { OutOfDeviceMemory, OutOfHostMemory, } #[derive(Debug)] pub enum DeviceMapError { OutOfDeviceMemory, OutOfHostMemory, ...
true
6a422b42b5ba9f1c85c3f6d3c9a8e1f3c95653ba
Rust
CattleProdigy/advent-of-code-2020
/src/bin/aoc_04.rs
UTF-8
6,380
3.21875
3
[]
no_license
use std::env; use std::fs; #[derive(Debug)] struct RawPassport { birth_year: Option<String>, issue_year: Option<String>, expiration_year: Option<String>, height: Option<String>, hair_color: Option<String>, eye_color: Option<String>, passport_id: Option<String>, country_id: Option<String...
true
7f124ff2f58e494246ef0a84151afb3ba567931a
Rust
smashedtoatoms/aoc2020
/lib/input-file/src/lib.rs
UTF-8
1,271
3.546875
4
[ "MIT" ]
permissive
use anyhow::Result; use std::env; use std::fs; use std::path::Path; static DEFAULT_FILE: &str = "./inputs/input.txt"; pub struct Input { contents: String, } impl Input { /// Creates a new Input containing the contents of the file at the /// specified path. pub fn new(path: &Path) -> Result<Self> { ...
true
741cb8ef1e5df218d515bba66cac099c6fbd2521
Rust
simd-lite/simd-json
/src/lib.rs
UTF-8
70,547
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
#![deny(warnings)] #![cfg_attr(feature = "hints", feature(core_intrinsics))] #![warn(unused_extern_crates)] #![deny( clippy::all, clippy::unwrap_used, clippy::unnecessary_unwrap, clippy::pedantic, missing_docs )] // We might want to revisit inline_always #![allow( clippy::module_name_repetitions...
true
8d6b491eb82d1a9378da68d26bbc4423d4044f42
Rust
pusateri/check3
/src/main.rs
UTF-8
727
2.578125
3
[ "MIT" ]
permissive
use check3::Check3; use std::fs::File; use std::io::BufWriter; fn main() { let c = Check3 { bill_references: vec!["Some Ref#".to_string()], bill_dates: vec!["03/16/2020".to_string()], bill_amounts: vec![47.10], payable_date: "03/19/2020".to_string(), payable_to: "Some Person...
true
6814e6f2a3e2f721234458906396583ff0d18857
Rust
maximveligan/nes_emu
/nes_emulator/src/mmu.rs
UTF-8
4,819
2.796875
3
[]
no_license
use crate::apu::Apu; use crate::controller::Controller; use crate::mapper::Mapper; use crate::ppu::Ppu; use cpu_6502::Memory; use serde::Deserialize; use serde::Serialize; use std::cell::RefCell; use std::rc::Rc; const WRAM_START: u16 = 0x0000; const WRAM_END: u16 = 0x1FFF; const PPU_START: u16 = 0x2000; const PPU_END...
true
98cc73a1a1a9ef35a31150ca35dc0db01decbea2
Rust
tomaka/eui
/src/shape.rs
UTF-8
5,277
3.328125
3
[]
no_license
use Matrix; /// A shape that can be drawn by any of the UI's components. /// /// The meaning of the matrix depends on the context in which the shape is manipulated. When /// returned by `build_layout`, the matrix is relative to the widget. When returned by `draw`, /// the matrix is absolute (ie. relative to the viewpo...
true
9c44082b85cb65f8af54314d5769b9adb01006b3
Rust
newAM/r3
/src/r3_port_arm/src/sp804/imp.rs
UTF-8
6,265
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
//! The implementation of the SP804 Dual Timer driver. use r3::kernel::{cfg::CfgBuilder, InterruptHandler, InterruptLine, Kernel, PortToKernel, UTicks}; use r3_portkit::tickless::{TicklessCfg, TicklessStateTrait}; use crate::sp804::{cfg::Sp804Options, sp804_regs}; /// Implemented on a system type by [`use_sp804!`]. /...
true
782086c10a33d033a3b76616c03c68b79fb989de
Rust
tahuy/rust-learning
/lifetime/src/main.rs
UTF-8
961
3.28125
3
[]
no_license
#[allow(dead_code)] #[allow(unused_imports)] #[allow(unused_must_use)] #[allow(unused_variables)] #[allow(unused_assignments)] struct Person { name: String } struct Company<'l> { name: String, ceo : &'l Person } // impl Person { // fn get_ref_name(&self) -> &String { // &self.name // } //...
true
04407d04124064f320c58883f9f4e9a577b732e0
Rust
sria91-rlox/lox-rs-1
/src/environment.rs
UTF-8
1,678
3.25
3
[]
no_license
use crate::object::Object; use crate::{ interpreter::{Result, RuntimeError}, token::Token, }; use std::{cell::RefCell, collections::HashMap, rc::Rc}; pub struct Environment { enclosing: Option<Rc<RefCell<Environment>>>, values: HashMap<String, Object>, } impl Environment { pub fn new() -> Self { ...
true
4b96ecbfc23a294c39cd770e88ca39bcc59b748a
Rust
bvssvni/colonize
/src/game.rs
UTF-8
1,154
2.53125
3
[ "BSD-3-Clause" ]
permissive
use backend::Renderer; use event::{ Events, MaxFps, Ups }; use quack::Set; use tcod_window::TcodWindow; use window::WindowSettings; use gamestate::GameState; use menuscene::MenuScene; use scene::{ BoxedScene, Scene }; pub struct Game<'a> { window: TcodWindow, gamestate: GameState, current_scene: BoxedScen...
true
c4d53a3d4a4ee6ea5e1924e742e0b6d20cf8a1d9
Rust
ebina4yaka/github-user-languages-api
/src/lib/languages.rs
UTF-8
6,072
2.75
3
[ "MIT" ]
permissive
use crate::lib::client::get_github_repositories; use crate::lib::client::repositories_languages_view; use crate::lib::models::*; use crate::Params; use rocket::request::Form; use std::panic; fn get_languages_size( response_data: repositories_languages_view::ResponseData, ) -> Vec<LanguageSize> { let mut langua...
true
633b8b73fa616e8a19f767ec9e09d90b639bb871
Rust
chiplet/kapine-packet
/src/lib.rs
UTF-8
4,875
3.265625
3
[]
no_license
#![no_std] use crc16::{State, MODBUS}; #[derive(Debug, Clone, Copy)] pub struct Packet { pub sync: u16, pub command: u8, pub length: u8, pub payload: Option<[u8; 255]>, pub checksum: u16 } impl Packet { // TODO: come up with a better implementation pub fn write_bytes(&self, buffer: &mut [...
true
8626ec4c528bdb4c10a10783a70ffe8e8bcb5f43
Rust
itsrainingmani/rust-learning
/ch10_generics/src/main.rs
UTF-8
4,242
3.609375
4
[]
no_license
use mylib::Summary; use std::cmp::PartialOrd; use std::fmt::Display; struct Point<T> { x: T, y: T, } impl<T> Point<T> { fn x(&self) -> &T { &self.x } } // the distance_from_origin function will only exist on Points with f32 type impl Point<f32> { fn distance_from_origin(&self) -> f32 { ...
true
b8d638ea403338a1d548a17631b7cf33bdaff34c
Rust
alevy/signpost
/software/kernel/signpost_drivers/src/gpio_async.rs
UTF-8
6,121
2.8125
3
[]
no_license
use core::cell::Cell; use kernel::hil; use kernel::{AppId, Callback, Driver}; use kernel::returncode::ReturnCode; use signpost_hil; pub struct GPIOAsync<'a, Port: signpost_hil::gpio_async::GPIOAsyncPort + 'a> { ports: &'a [&'a Port], callback: Cell<Option<Callback>>, } impl<'a, Port: signpost_hil::gpio_asyn...
true
1d33ae435a2f0c21e946a9317888af23102dc5c4
Rust
indefini/dormin
/src/fbo.rs
UTF-8
1,551
2.609375
3
[]
no_license
use libc::{c_uint, c_int}; use std::fmt; #[repr(C)] pub struct CglFbo; unsafe impl Send for CglFbo {} unsafe impl Sync for CglFbo {} #[link(name = "cypher")] extern { pub fn cgl_create_fbo() -> *const CglFbo; pub fn cgl_fbo_use(fbo : *const CglFbo); pub fn cgl_fbo_use_end(); pub fn cgl_fbo_resize(fbo...
true
07ec4327542d61a170946bd1811861a0340463e0
Rust
elitecodegroovy/thinking-in-rust
/app11/src/store.rs
UTF-8
7,092
2.875
3
[]
no_license
use sqlx::{ postgres::{PgPool, PgPoolOptions, PgRow}, Row, }; use handle_errors::Error; use crate::types::{ account::{Account, AccountId}, answer::Answer, question::{NewQuestion, Question, QuestionId}, }; #[derive(Debug, Clone)] pub struct Store { pub connection: PgPool, } impl Store { p...
true
88fd720f0f4432763e7dc1bcc9e5b96b4bab82b9
Rust
QPC-github/tock-sensortag
/chips/cc26x0/src/tmp.rs
UTF-8
1,155
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
use i2c::I2cInterface; use core::cell::Cell; use sensor::Sensor; use peripheral_manager::PowerClient; use chip::SleepMode; const TMP_INTERFACE: I2cInterface = I2cInterface::Interface0; const TMP_ADDRESS: u8 = 0x44; const TMP_CONF_REG: u8 = 0x02; pub static mut TMP007_SENSOR: TMP = TMP::new(); pub struct TMP { s...
true
7a5edef77700282b4cd1f8bc5184aa99bea7e383
Rust
chenbobby/bongodb
/src/message.rs
UTF-8
3,045
3.453125
3
[]
no_license
use std::{fmt, io, mem, slice}; /// Error codes pub enum Error { InvalidBytes, NotEnoughHeaderBytes(usize), NotEnoughPayloadBytes(usize), ReadFailure(io::Error), } impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { Error::InvalidBy...
true
45b35bbeb5ab1b73e025ef91e15faec59d4beba6
Rust
jssgen/ik-rust
/ifelse/src/main.rs
UTF-8
957
3.453125
3
[]
no_license
fn resultado(nota1: f32, nota2: f32, nota3: f32, nota4: f32) { let media_nota: f32 = nota1 + nota2 + nota3 + nota4; const MAX: f32 = 100.0; const MIN: f32 = 60.0; if media_nota >= MIN && media_nota < MAX { println!( "Parabéns! aprovado com a média de notas: {} pontos.", m...
true
73b82646e6f6f85f2ea17607dcd62552e68c704d
Rust
kenkoooo/nes-rs
/src/nes/cartridge.rs
UTF-8
1,724
2.796875
3
[]
no_license
use std::fs::File; use std::io; use std::io::prelude::*; use crate::nes::ines::NesFileHeader; pub struct Cartridge { pub prg: Vec<u8>, chr: Vec<u8>, sram: [u8; 0x2000], pub mapper: u8, mirror: u8, pub battery: u8, } pub fn load_nes_file(path: &str) -> io::Result<Cartridge> { let mut f = F...
true
10f6360ecfbcffeecf58217527d8df0ec5c48c7a
Rust
bokuweb/docx-rs
/docx-core/src/documents/elements/underline.rs
UTF-8
949
2.953125
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize, Serializer}; use crate::documents::BuildXML; use crate::xml_builder::*; #[derive(Debug, Clone, Deserialize, PartialEq)] pub struct Underline { val: String, } impl Underline { pub fn new(val: impl Into<String>) -> Underline { Underline { val: val.into() } } } i...
true
df4d731d396aa6ee7be6734a9caf0a9233c2a230
Rust
dsolartec/portfoliov2
/src/main.rs
UTF-8
2,257
2.609375
3
[]
no_license
mod data; mod languages; mod templates; mod utils; use actix_web::{get, web, App, HttpRequest, HttpResponse, HttpServer}; use dotenv::dotenv; use std::env; #[get("/")] async fn home(page_url: web::Data<String>, req: HttpRequest) -> actix_web::Result<HttpResponse> { templates::render("home", page_url, req) } #[ge...
true
3dc9ac36ae78757bb028ee21fed136e5614d905a
Rust
mofanv/veracruz
/sdk/data-generators/private-set-intersection-sum-generator/src/main.rs
UTF-8
4,970
3.015625
3
[ "MIT", "CC-BY-SA-2.0" ]
permissive
//! Data generator sdk/examples/private-set-intersection-sum //! //! # Authors //! //! The Veracruz Development Team. //! //! # Copyright //! //! See the file `LICENSE_MIT.markdown` in the Veracruz root directory for licensing //! and copyright information. use clap::{App, Arg}; use rand::{rngs::StdRng, seq::SliceRand...
true
2f6488f7524c397d299345c07df141968df977d4
Rust
bobwanglong/learn-rust
/base_rust/src/my_match/match_guard.rs
UTF-8
2,129
3.90625
4
[ "Apache-2.0" ]
permissive
/** 这个例子会打印出 less than five: 4 当 num 与模式中第一个分支匹配时,Some(4) 可以与 Some(x) 匹配,接着匹配守卫检查 x 值是否小于 5,因为 4 小于 5,所以第一个分支被选择。 相反如果 num 为 Some(10),因为 10 不小于 5 ,所以第一个分支的匹配守卫为假。接着 Rust 会前往第二个分支,因为这里没有匹配守卫所以会匹配任何 Some 成员。 */ pub fn guard() { let num = Some(4); match num { Some(x) if x < 5 => println!("less than five:{}...
true
02069b614e74d559eeefffd7365e9dfc6343a4df
Rust
hackingmath/puzzles
/yohaku_Sept_20_19_backtracking.rs
UTF-8
4,641
3.015625
3
[]
no_license
// Rust program to solve a Yohaku Puzzle // https://twitter.com/YohakuPuzzle/status/1169939266283220992 // 4x4 Consecutive, sums rows/cols //Center squares have to be triangle number // Sept. 20, 2019 extern crate rand; extern crate time; use time::PreciseTime; const ROWS :[i8;4] = [7,32,46,35]; const COL...
true
7e7e174210e6d20f6a6cec9b31ddc94489d5542d
Rust
bug00r/math-rust
/src/statistics/average.rs
UTF-8
1,632
3.21875
3
[ "MIT" ]
permissive
use std::cmp::Ordering::Equal; pub fn middle_arithmetic(x1: f32, x2: f32, x3: f32, x4: f32) ->f32 { (x1 + x2 + x3 + x4)*0.25 } pub fn middle_arithmetic2(x1: f32, x2: f32) ->f32 { (x1 + x2)*0.5 } pub fn middle_harmonic(x1: f32, x2: f32, x3: f32, x4: f32) -> f32{ 4./(1./x1 + 1./x2 + 1./x3 + 1./x4) } pub fn mid...
true
867213237dd605e75fdec43554d31875f5af4565
Rust
Heliozoa/obs-websocket-rs
/src/requests.rs
UTF-8
77,927
3
3
[]
no_license
//! Request types. Sent to the server using the Obs struct. //! //! The request types will generate a running message-id by default, but they also support defining custom message-ids. //! When using custom message-ids, avoid reusing them and if also using default message-ids, avoid using custom ones in the form `_{inte...
true
4eac2318b991f64a62879bcfa8e2fd5080f038cf
Rust
kaffarell/gcoin
/server/src/payload/data.rs
UTF-8
717
2.828125
3
[]
no_license
use serde::{Serialize, Deserialize}; #[derive(Hash)] #[derive(Serialize, Deserialize)] pub struct Transaction { pub sender: String, pub receiver: String, pub amount: String, pub signature: Vec<u8>, } impl std::fmt::Display for Transaction { fn fmt(&self, f: &mut std::fmt::Formatter...
true
9fc9c80dbf288272aa3a59dc8b11714a22ec6c58
Rust
jonls/terranames-contracts
/packages/terranames/src/utils.rs
UTF-8
2,432
2.984375
3
[ "Apache-2.0" ]
permissive
use std::ops::Add; use cosmwasm_std::{Timestamp as CWTimestamp, OverflowError, Uint64}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; /// Timestamp (in seconds) #[derive( Serialize, Deserialize, Copy, Clone, Default, Debug, PartialEq, Eq, PartialOrd, Ord, JsonSchema, )] pub struct Timestamp(U...
true
9645980d89a59b43c513858a548321f2f3ceb588
Rust
theWatchmen/rust_minifb
/examples/menu.rs
UTF-8
3,434
3
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate minifb; use minifb::{Window, Key, Scale, WindowOptions, Menu}; use minifb::{MENU_KEY_CTRL, MENU_KEY_COMMAND}; const WIDTH: usize = 640; const HEIGHT: usize = 360; const MENU_TEST_ID: usize = 1; const OTHER_MENU_ID: usize = 2; const COLOR_0_ID: usize = 3; const COLOR_1_ID: usize = 4; const COLOR_2_ID: us...
true
64e382c07a267751d3ca3083647c979d15ebfd03
Rust
joeri/wk-predictions-rs
/src/models.rs
UTF-8
7,356
2.703125
3
[]
no_license
use super::schema::*; use bcrypt::{hash, DEFAULT_COST}; use chrono::prelude::*; use diesel::prelude::*; #[derive(Queryable, Identifiable, Clone, Debug, Serialize, Deserialize)] #[primary_key(user_id)] pub struct User { pub user_id: i32, pub display_name: Option<String>, pub login: String, pub email: St...
true
772692d07b40a2c86bcd30da843df5d029a446ab
Rust
jkarns275/CSC-365
/src/log.rs
UTF-8
928
2.671875
3
[]
no_license
/// Contains macros for logging. The macros are essentially wrappers around /// the println macro. #[macro_export] macro_rules! log { ($s:expr) => ({ print!("\x1b[32;1m[Log] \x1b[0m"); println!($s) }); ($fmt:expr, $($arg:tt)*) => ({ print!("\x1b[32;1m[Log] \x1b[0m"); print!(c...
true
15128202ae7bf924cb4c0bceceedb0944c6a21d1
Rust
qeedquan/challenges
/leetcode/running-sum-of-1d-array.rs
UTF-8
977
3.53125
4
[ "MIT" ]
permissive
/* Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). Return the running sum of nums. Example 1: Input: nums = [1,2,3,4] Output: [1,3,6,10] Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. Example 2: Input: nums = [1,1,1,1,1] Output: [1,2,3,...
true
4aabe044301ef67b4474b7008d06b1d2517374d8
Rust
Nemo157/serde_cbor-diag-rs
/tests/misc.rs
UTF-8
1,489
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] mod utils; #[derive(Serialize)] struct Unit; #[derive(Serialize)] struct Newtype<T>(T); #[derive(Serialize)] struct Tuple<T>(T, T); #[derive(Serialize)] struct Struct<T> { left: T, right: T, } #[derive(Serialize)] enum Enum<T> { ...
true
17db5df75faa4d8c0209ffbce819d2349d5af1f7
Rust
pzmarzly/Rocket
/core/lib/src/unix.rs
UTF-8
2,095
2.671875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use crate::error::{LaunchError, LaunchErrorKind}; use std::path::Path; use std::fs::{self, File}; crate fn lock_socket<P: AsRef<Path>>(path: P) -> Result<File, LaunchError> { use fs2::FileExt; let path = path.as_ref(); let lock_path = path.with_extension("lock"); let lock_file = fs::OpenOptions::new(...
true
52a15ad110058b702544c46a590a34a961a56d97
Rust
ens-ds23/ensembl-client
/src/assets/browser/app/src/tácode/commands/geometry.rs
UTF-8
7,280
2.625
3
[]
no_license
use std::sync::{ Arc, Mutex }; use tánaiste::{ Argument, Command, DataState, Instruction, ProcState, Signature, Value }; use tácode::core::{ TáContext, TáTask }; // TODO check ranges // TODO &mut-able registers // TODO clever copying fn abutt(starts: &Vec<f64>) -> (Vec<f64>, Vec<f64>) { let mut starts_ou...
true
2fb43d9fcd6a3b8803bf1d83b9200e3c00a60fa7
Rust
dtynn/algo-rs
/src/codewars/robo_script_2.rs
UTF-8
3,234
3.21875
3
[]
no_license
use std::cmp::{max, min}; pub fn execute(code: &str) -> String { if code.is_empty() { return "*".to_string(); } const DIRECTIONS: [[i64; 2]; 4] = [[0, 1], [1, -1], [0, -1], [1, 1]]; let mut coordinates: Vec<[i64; 2]> = vec![[0, 0]]; let mut cur: [i64; 2] = [0, 0]; let mut chars = co...
true
fd09626f7646078434db684c99982f796c1853f0
Rust
webern/exile
/src/xdoc/chars.rs
UTF-8
193
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
/// is the char one of `(#x20 | #x9 | #xD | #xA)`, i.e. space, tab, carriage return, or line feed. pub fn is_whitespace(c: char) -> bool { c == ' ' || c == '\t' || c == '\r' || c == '\n' }
true
c0d775ac880bf60f10cde28cccb0c0d1561d5b65
Rust
Swoorup/offregisters-ctl
/src/main.rs
UTF-8
578
2.5625
3
[]
no_license
use std::io; extern crate structopt; use std::path::PathBuf; use structopt::StructOpt; use offregisters_lib::run_from_path; #[derive(Debug, StructOpt)] struct Opt { /// Activate debug mode #[structopt(short = "d", long = "debug")] debug: bool, /// Config file #[structopt(short = "c", long = "co...
true
534f9a23d07115b6035525e35f498939dbea08b3
Rust
k2bd/intro_rust_02
/default_01.rs
UTF-8
992
3.375
3
[]
no_license
// This example was taken from "The Rust Programming Languauge" // https://doc.rust-lang.org/book/ch10-02-traits.html?highlight=default#default-implementations trait Summary { fn summarize_author(&self) -> String; fn summarize(&self) -> String { format!("(Read more from {}...)", self.summarize_author(...
true
883fc7cc779e432a22f3a7a80f446b09eabb9206
Rust
dannypsnl/elz
/src/codegen/formatter/tests.rs
UTF-8
4,100
3.359375
3
[ "MIT" ]
permissive
use super::*; #[test] fn simple_variable() { let formatted_code = format_elz("x:int=1;".to_string()); assert_eq!(formatted_code, "x: int = 1;\n"); } #[test] fn simple_function() { let formatted_code = format_elz("add(x:int,y:int):int=x+y;".to_string()); assert_eq!(formatted_code, "add(x: int, y: int):...
true
43bb586098ab8e12243e965e0b59894b8787dd8b
Rust
Ekleog/erlust
/erlust/src/theater.rs
UTF-8
6,862
3.421875
3
[ "MIT" ]
permissive
//! Protocol for sending messages to remote actors use erased_serde::{Deserializer, Serializer}; use futures::future::FutureObj; use serde::de::Error as SerdeDeError; use std::cell::RefCell; use crate::types::{ActorId, Message, MessageBox}; /// A bunch of actors and functions used for theaters to communicate between...
true
0a485286a31a0833530f4128937e90c09061bed0
Rust
gobanos/cryptopals
/src/bin/challenge3.rs
UTF-8
403
2.734375
3
[]
no_license
extern crate cryptopals; use cryptopals::bit::XorIter; use cryptopals::conversion::char::CharWrite; use cryptopals::conversion::hex::HexRead; use std::iter; fn main() { let input = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736"; for i in 0u8..=255 { let res = input ...
true
c5ca8c57b49587393828399ed99d759e3b5bda9e
Rust
Tarv3/collada-parser
/src/collada/skin/mod.rs
UTF-8
5,019
2.78125
3
[]
no_license
use math::Matrix4; use super::{util::*, error::*, source::DataSource}; use self::vertex_weights::VertexWeights; use xml_tree::*; use std::error::Error; pub mod vertex_weights; #[derive(Copy, Clone, Debug)] pub struct JointWeight { pub joint: usize, pub weight: f32, } #[derive(Debug)] pub struct SkinParser { ...
true
3ea53c32222780ba1e3fc582d6677b1d9d7b8623
Rust
Ameobea/advent-of-code-2018
/src/day25.rs
UTF-8
3,210
2.828125
3
[]
no_license
use std::collections::VecDeque; use regex::Regex; lazy_static! { static ref RGX: Regex = Regex::new("\\w*(-?\\d+),(-?\\d+),(-?\\d+),(-?\\d+)").unwrap(); } const INPUT: &str = include_str!("../input/day25.txt"); fn manhattan_distance( (x1, y1, z1, t1): (isize, isize, isize, isize), (x2, y2, z2, t2): (isi...
true
ab962b2750c8dec19225cdc03c6b10759414ba61
Rust
danshiovitz/adventofcode
/2021/day13/src/main.rs
UTF-8
3,275
3.09375
3
[ "LicenseRef-scancode-public-domain" ]
permissive
use std::collections::HashSet; use lazy_regex::regex; extern crate common; use common::framework::{parse_lines, run_day, BaseDay, InputReader}; use common::grid::{print_grid, Coord, Grid}; #[derive(Copy, Clone)] enum Fold { X(i32), Y(i32), } struct Day13 { points: HashSet<Coord>, folds: Vec<Fold>, ...
true
493f3bac5dafc03de89670cfac9c08145aae55b4
Rust
xCrypt0r/Baekjoon
/src/2/2985.rs
UTF-8
1,056
3.09375
3
[ "MIT" ]
permissive
/** * 2985. 세 수 * * 작성자: xCrypt0r * 언어: Rust 2018 * 사용 메모리: 13,028 KB * 소요 시간: 4 ms * 해결 날짜: 2020년 10월 7일 */ macro_rules! get_line { ( $( $t: ty ),+ ) => { { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.spli...
true
da26d53860f477a5c4e8567c929ac5e56db1df4e
Rust
ftsujikawa/rust-sample
/ch19/code19-14/src/main.rs
UTF-8
598
3.65625
4
[]
no_license
fn main() { println!("Hello, Rust world!"); let mut a = Person { id: 100, name: "masuda".to_string(), age: 50 }; let b = Person { id: 100, name: "masuda".to_string(), age: 50 }; let c = Person { id: 200, name: "kato".to_string(), age: 40 }; assert_eq!("masuda", a.name); assert_eq!("kato", c.name...
true
920917abc2075d76cbcc021c7680852b7660c8ad
Rust
allen-marshall/lv2-se-bundle
/src/bundle_model/unknowns/mod.rs
UTF-8
6,728
2.765625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Representation of LV2 bundle data that isn't understood by this crate, but is deemed important //! enough to represent. // TODO: Maybe disallow construction of UnknownX when the IRI *is* understood by the crate? use crate::bundle_model::{IdentifiedBy, OptionallyIdentifiedBy, HasRelatedSet, LabelRelation}; use cra...
true
968e574c5218e0a1f87f94de8aea4675c7019ea4
Rust
yeochinyi/codetest
/exercism/rust/anagram/src/lib.rs
UTF-8
675
3.1875
3
[]
no_license
use std::collections::{HashMap, HashSet}; pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str> { let mut h = HashSet::new(); let word = &word.to_lowercase()[..]; let m1 = char_count(word); for p in possible_anagrams { let p1 = &p.to_lowercase()[..]; let...
true
a1d615f9b500fc1b98c7b3b38440bdc336f00120
Rust
neektza/blogdb
/src/main.rs
UTF-8
2,135
3.125
3
[]
no_license
use std::fs; use std::path::{Path, PathBuf}; use std::collections::HashMap; use std::io; // use std::io::{Read, Write}; use std::env; // use std::thread; // use std::sync::mpsc; // use std::sync::{Arc, RwLock, RwLockWriteGuard}; use std::result; extern crate byteorder; #[derive(Debug)] pub enum Error { IoError(io...
true
b62d661270d3a345b83b80948fa41cb08d07e4bb
Rust
capturetheflag/rust-bubble-sort
/src/main.rs
UTF-8
1,160
3.125
3
[]
no_license
mod book; mod sort; fn main() { let books = get_books(); let sorted_books = sort::bubble_sort(books, &compare_books); for i in 0..sorted_books.len() { println!("{title} {pages}", title = sorted_books[i].get_title(), pages = sorted_books[i].get_number_of_pages()); } } fn compare_books(a: &book::Book...
true
bb12a9d018b9d8d70988bae579e6153e9b3de1f6
Rust
aragorndev0912/amaia-vm
/src/operation.rs
UTF-8
409
3.25
3
[]
no_license
#[allow(dead_code)] #[derive(Debug, Clone, Copy)] pub enum Operation { ///Operation I/O. Read = 0x0A, Write = 0x0B, ///Operation load & store of data. Load = 0x14, Store = 0x15, ///Operation arithmetic. Add = 0x1E, Sub = 0x1F, Div = 0x20, Mul = 0x21, ///Operation of contr...
true
90dbd83df382274ad40cf0e807e2c9aa7177b7ac
Rust
l-maia/openmls
/openmls/src/group/managed_group/callbacks.rs
UTF-8
3,067
3.3125
3
[ "MIT" ]
permissive
//! Collection of callback functions that are passed to a `ManagedGroup` as part //! of the configurations. All callback functions are optional. //! //! ## Validators //! //! Validator callback functions are called when Proposals are processed through //! [process_message()](`ManagedGroup::process_message()`). If no //...
true
3575002511d5529b83a57914f57160bcdce97319
Rust
isgasho/lll
/src/ui/tab.rs
UTF-8
2,094
3.203125
3
[ "MIT" ]
permissive
use crate::error::*; use std::collections::HashMap; use std::path::PathBuf; #[allow(dead_code)] #[derive(Debug)] pub struct Tab { pub title: u32, // Views // TODO: get rid of parent_view, just calculate on navigation pub parent_view: PathBuf, pub current_view: PathBuf, // Selected // TODO...
true
6052e8d95ba6d2c331ad263129e3b899da7ef985
Rust
emilywoods/nature-of-corrode
/src/nature_of_code/chapter1/example1_2.rs
UTF-8
1,652
2.84375
3
[]
no_license
// The Nature of Code, by Daniel Shiffman [1] // // Example 1.2: Bouncing ball with PVectors // // With reference to Nannou example code [2] // // [1] https://natureofcode.com/book/ // [2] https://github.com/nannou-org/nannou/blob/master/examples/nature_of_code/chp_01_vectors/1_2_bouncingball_vectors.rs use nannou::pr...
true
fcfdaa5189ce224ed181f0268b3b4b28f776f86e
Rust
anuj-apdev/rust-learn
/src/rio/o_direct.rs
UTF-8
1,901
2.71875
3
[]
no_license
use std::{ fs::OpenOptions, io::Result, os::unix::fs::OpenOptionsExt, }; const CHUNK_SIZE: u64 = 4096 * 256; // `O_DIRECT` requires all reads and writes // to be aligned to the block device's block // size. 4096 might not be the best, or even // a valid one, for yours! #[repr(align(4096))] struct Aligned([u8;...
true
f12e1524557101233c5455daf94950b16a0f9356
Rust
landaire/rust-proc-macro-without-dependencies
/default_derive/src/lib.rs
UTF-8
7,231
3.421875
3
[]
no_license
extern crate proc_macro; use proc_macro::{Delimiter, Group, Ident, Punct, TokenStream, TokenTree}; use std::iter::Peekable; #[derive(Debug)] enum VisibilityModifier { Pub, PubCrate, } #[derive(Debug)] enum DataType { Enum, Struct(Struct), } #[derive(Debug)] struct Struct { pub name: Ident, p...
true
afd62d2a618af5c72b886a52686f4dac3c7942c1
Rust
sidvishnoi/leetcode-rust
/1429-first-unique-number.rs
UTF-8
4,241
3.609375
4
[]
no_license
use std::collections::HashMap; use std::ptr; pub struct ListNode { value: i32, prev: *mut ListNode, next: *mut ListNode, } impl ListNode { pub fn new(value: i32) -> Self { Self { value, prev: ptr::null_mut(), next: ptr::null_mut(), } } } struct ...
true
bca3833850d9c8e83503a62240aad22d35532471
Rust
Buissonix/some-tank-game-rs
/src/console/mod.rs
UTF-8
2,411
2.875
3
[]
no_license
use std::collections::VecDeque; use bevy::prelude::*; mod console_command; pub use console_command::*; use crate::{MapLoader, Persister, PersisterCommand}; #[derive(Default)] pub struct Console { pub(in self) command_queue:VecDeque<ConsoleCommand>, pub log:String } impl Console { pub (in self) fn pop_c...
true
279af1580d09e216586b3c633e5d770d5c676ab6
Rust
proximax-storage/rust-xpx-chain-sdk
/src/api/dtos/secret_lock_dto.rs
UTF-8
1,060
2.5625
3
[ "Apache-2.0" ]
permissive
/* * Copyright 2018 ProximaX Limited. All rights reserved. * Use of this source code is governed by the Apache 2.0 * license that can be found in the LICENSE file. */ use super::{AbstractTransactionDto, HashAlgorithm, Uint64Dto}; /// SecretLockTransactionDto : Transaction that sends mosaics to a recipient if the ...
true
82ad81cf02fb457ec6285fa71fd315b6ff4de5f1
Rust
mcobzarenco/zentui
/src/app/pipeline.rs
UTF-8
4,597
2.625
3
[ "MIT" ]
permissive
use im::hashmap::HashMap; use std::rc::Rc; use zi::{ components::{ select::{Select, SelectProperties}, text::{Text, TextAlign, TextProperties}, }, layout, Callback, Component, ComponentLink, Layout, Rect, ShouldRender, Style, }; use super::{ issue_card::{self, IssueCard}, Base16Them...
true
9e8a477dc2598bcb89d7133a11da7a5d6af58ef0
Rust
WhoSoup/aoc2020
/day24/src/tile.rs
UTF-8
3,608
3.578125
4
[ "MIT" ]
permissive
use std::collections::HashSet; #[derive(Debug, Clone, Copy)] pub enum Direction { E, SE, SW, W, NW, NE, } impl Direction { pub fn parse_line(line: &str) -> Vec<Direction> { line.replace("se", "a") .replace("sw", "b") .replace("nw", "c") .replace(...
true
77c87674dcd584499a44c007ba51fe6d9f753b87
Rust
Standard-Cognition/nalgebra
/src/base/dimension.rs
UTF-8
11,821
2.9375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
#![allow(missing_docs)] //! Traits and tags for identifying the dimension of all algebraic entities. use std::fmt::Debug; use std::any::{Any, TypeId}; use std::cmp; use std::ops::{Add, Div, Mul, Sub}; use typenum::{self, B1, Bit, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, UInt, UTerm, Unsigned};...
true
6e0f5953e7c813c383c2f17b6e9780e9ca39c038
Rust
stjordanis/jortestkit
/src/console/progress_bar.rs
UTF-8
609
3.296875
3
[]
no_license
use std::fmt; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum ProgressBarMode { Monitor, Standard, None, } pub fn parse_progress_bar_mode_from_str(progress_bar_mode: &str) -> ProgressBarMode { let progress_bar_mode_lowercase: &str = &progress_bar_mode.to_lowercase(); match progress_bar_mode_...
true
65ea825abab4271626ed5384f0011f513d485326
Rust
catnipan/regexp
/src/nfa_regexp.rs
UTF-8
8,727
2.875
3
[]
no_license
use super::nfa::*; use std::collections::HashMap; use super::automaton::Automaton; use super::regop::RegOp; use super::escape_chars::{EscapeChars, MaybeEsc}; struct NFABasic { start: usize, accept: usize, } type TransitionMapType = HashMap<(usize, Option<char>), Vec<usize>>; struct NFAConstructor { state_idx: ...
true
3142f1c053d5e54b968d9bdaec4b57918a9a38ba
Rust
luliyucoordinate/Leetcode
/src/0492-Construct-the-Rectangle/0492.rs
UTF-8
214
2.71875
3
[]
no_license
impl Solution { pub fn construct_rectangle(area: i32) -> Vec<i32> { let mut w = (area as f32).sqrt() as i32; while area % w != 0 { w -= 1; } vec![area / w, w] } }
true
e66a13f60284dd949ed70b2214d392899cb686bc
Rust
SaadDAHMANI/rgalgo
/src/rga.rs
UTF-8
10,450
2.90625
3
[ "MIT" ]
permissive
use rand::distributions::Distribution; use rand::distributions::Uniform; use rand::Rng; //use std::collections::HashMap; pub fn rga(popsize: usize, searchdimension: usize, kmax : usize, min : f64, max : f64, mutation_probability : usize)-> (Vec<f64>, Vec<f64>){ let mut n: usize = 2; let mut d: usize = 1;...
true
4dc368189b4a08f8ff763a3e54261c32f7251dd4
Rust
linde12/advent-of-code-2020
/4/src/part2.rs
UTF-8
5,458
3.296875
3
[]
no_license
use std::collections::HashMap; struct Passport<'a> { entries: HashMap<&'a str, &'a str>, } impl<'a> Passport<'a> { fn new(raw: &'a str) -> Passport<'a> { let entries = raw .split_whitespace() .filter_map(|kv| { let kv: Vec<&str> = kv.split(":").collect(); ...
true
e3c0fc99417d2d1c86b6d954355e20830373a4cc
Rust
jimmyhmiller/PlayGround
/rust/compiler/src/main.rs
UTF-8
31,901
3.203125
3
[]
no_license
use std::collections::HashMap; use std::collections::VecDeque; use std::process::Command; use std::fs::File; use std::io::prelude::{Write}; // Can I do a "stack" machine where the first n values of the stack are registers? // So if I output stack(0), that really means r12 or something? // https://en.wikipedia.org...
true
ea7cefea345abd6b40b7a7d53d8f7fd52d7554c8
Rust
wjlewis/taste-of-lambda
/src/syntax/parser/raw.rs
UTF-8
29,548
3.171875
3
[]
no_license
//! A parser that produces untyped, full-fidelity trees. use super::untyped_tree::{SyntaxKind as Sk, UntypedTree}; use super::ParseResult; use crate::errors::SimpleError; use crate::source::Span; use crate::syntax::lexer::Lexer; use crate::syntax::tokens::{CommandLeader as Cl, Token, TokenKind as Tk}; /// Parse input...
true
43ecd5f58180eee878b14e974400821854a034a3
Rust
jaredpalmer/next.js
/packages/next-swc/crates/core/src/auto_cjs/mod.rs
UTF-8
1,005
2.671875
3
[ "MIT" ]
permissive
use next_binding::swc::core::{ ecma::ast::*, ecma::visit::{Visit, VisitWith}, }; pub(crate) fn contains_cjs(m: &Module) -> bool { let mut v = CjsFinder::default(); m.visit_with(&mut v); v.found } #[derive(Copy, Clone, Default)] struct CjsFinder { found: bool, } /// This visitor implementation...
true