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
5903b77c5ea23f92527e78c4d0bc660eed00dcc1
Rust
mthvedt/hitchhiker-rust
/src/tree/allocator.rs
UTF-8
1,300
3.078125
3
[]
no_license
/* Allocator design... Pointer source. Persistent pointers, transient pointers, weak pointers. How to do persistent pointers? Transient and weak are easy: just have them allocated from an arena. Arenas are thread unsafe. Recall that our usecase is on-disk, not in-memory; therefore, persistent nodes are not shareable...
true
d1198f9d046fd3d86b5a4e7eb0f70835f9bd0bb4
Rust
azriel91/autexousious
/crate/game_play/src/system/game_play_removal_augment_system.rs
UTF-8
2,323
2.6875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use amethyst::{ ecs::{ReadExpect, System, World, Write, WriteStorage}, shred::{ResourceId, SystemData}, shrev::{EventChannel, ReaderId}, }; use derivative::Derivative; use derive_new::new; use game_play_model::GamePlayEntity; use spawn_model::play::SpawnEvent; use state_registry::StateId; /// Augments spaw...
true
cd0016f16a3369d465565df6258df57d646e3f09
Rust
rostam/Experiments
/rust/rust_gtea/test.rs
UTF-8
4,131
3.453125
3
[ "MIT" ]
permissive
use std::thread; use std::time::{Duration, Instant}; use std::thread::sleep; // This is the `main` thread fn main() { let now = Instant::now(); // This is our data to process. // We will calculate the sum of all digits via a threaded map-reduce algorithm. // Each whitespace separated chunk will be handle...
true
fb6bbd21c40fbe9f316529d19cd841756aa77d4d
Rust
TheBlueMatt/rust-lightning
/lightning/src/util/time.rs
UTF-8
3,652
3.5625
4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
// This file is licensed under the Apache License, Version 2.0 <LICENSE-APACHE // or http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your option. // You may not use this file except in accordance with one or both of these // licenses. //! [`Time...
true
2dcb4122c6c5c21ffb7198aed8e8fb45e428cf90
Rust
bitonic/puzzlescript-rs
/glutin/src/window.rs
UTF-8
2,584
2.703125
3
[]
no_license
use failure::Error; use gleam::gl; use glutin::dpi::LogicalSize; use glutin::{ Api, ContextBuilder, Event, EventsLoop, GlContext, GlRequest, GlWindow, WindowBuilder, WindowEvent, }; use std::rc::Rc; /// We assume that we have at least a 720p space to draw. const MIN_WINDOW_WIDTH: u32 = 1280; const MIN_WINDOW_HEIGH...
true
64048125a42970431b0ac7a7e429cba12e958128
Rust
gpoesia/cretonne
/lib/cretonne/src/verifier.rs
UTF-8
15,741
3.140625
3
[ "Apache-2.0" ]
permissive
//! A verifier for ensuring that functions are well formed. //! It verifies: //! //! EBB integrity //! //! - All instructions reached from the `ebb_insts` iterator must belong to //! the EBB as reported by `inst_ebb()`. //! - Every EBB must end in a terminator instruction, and no other instruction //! ...
true
bf0421c2dc2c4be3ec777c7663ce5ef81246a725
Rust
GaloisInc/mir-verifier
/lib/liballoc/collections/btree/navigate.rs
UTF-8
11,063
2.96875
3
[]
permissive
use core::ptr; use super::node::{marker, ForceResult::*, Handle, NodeRef}; use super::unwrap_unchecked; impl<BorrowType, K, V> Handle<NodeRef<BorrowType, K, V, marker::Leaf>, marker::Edge> { /// Given a leaf edge handle, returns [`Result::Ok`] with a handle to the neighboring KV /// on the right side, which i...
true
82be518807299a6ea1ae5299f343399f77c63e5d
Rust
Azure/azure-sdk-for-rust
/sdk/core/src/request_options/if_sequence_number.rs
UTF-8
1,618
3.34375
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use crate::{headers, Header}; /// Conditional request header based on the value of the object's sequence number /// /// Ref: <https://docs.microsoft.com/en-us/rest/api/storageservices/put-page-from-url> #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum IfSequenceNumber { /// If the object's sequence number is ...
true
f948eef7a71ca46bf35c982d2a2cc622dac8dfc5
Rust
stobias123/rs-etrade
/src/accounts.rs
UTF-8
25,508
2.625
3
[ "MIT" ]
permissive
use super::{session, Session, Store}; use crate::{empty_body, qs_params, MarketSession}; use crate::{Product, SortOrder}; use anyhow::Result; use http::Method; use session::CallbackProvider; use std::sync::Arc; use strum::EnumString; pub struct Api<T: Store> { session: Arc<Session<T>>, } impl<T> Api<T> where T: S...
true
3c810835e4ee719ba3af9ada3feee041030d7c13
Rust
amouat/cabot
/src/dns.rs
UTF-8
898
2.921875
3
[ "BSD-3-Clause" ]
permissive
//! DNS Resolution use std::io::{Write, stderr}; use std::net::{ToSocketAddrs, SocketAddr}; use log::LogLevel::Info; pub struct Resolver { verbose: bool, } impl Resolver { pub fn new(verbose: bool) -> Self { Resolver { verbose: verbose } } pub fn get_addr(&self, authority: &str) -> SocketAddr...
true
0930bad1f19ba1eff55cc580253074d8a64e2462
Rust
JackBmann/scheme_interpreter
/src/interpreter.rs
UTF-8
848
3.015625
3
[]
no_license
use evaluator::*; use parser::*; use lexer::*; use environment::*; use environment_parser::*; use std::collections::HashMap; pub fn interpret_with_environment(s:String, e: Environment) -> f64 { let mut tokens = tokenize(&s); let expression = parse(&mut tokens, &e); let result = evaluate(&expression); ...
true
43b397546f4ebb9452129a582e7bb7b4d5cd3c6e
Rust
ayrat-playground/exercism_rust
/bracket-push/src/lib.rs
UTF-8
951
3.96875
4
[]
no_license
pub struct Brackets<'a> { data: &'a str } impl<'a> From<&'a str> for Brackets<'a> { fn from(string: &'a str) -> Brackets<'a> { Brackets { data: string } } } impl<'a> Brackets<'a> { pub fn are_balanced(&self) -> bool { let mut stack = Vec::<char>::new(); for ch in self.data.cha...
true
9d1b98b26caa966df7f8ee0cdb9096df50ce3f66
Rust
spihill/rust-library
/src/math/numerical.rs
UTF-8
1,984
2.921875
3
[]
no_license
use std::ops::{Add, Sub, Mul, Div, Rem, AddAssign, SubAssign, MulAssign, DivAssign, RemAssign, Shl, ShlAssign, Shr, ShrAssign}; use std::convert::From; pub trait Integer : Add<Output=Self> + Sub<Output=Self> + Mul<Output=Self> + Div<Output=Self> + Rem<Output=Self> + AddAssign + SubAssign + MulAssign + DivAssign ...
true
0882e14846f9a9b2d96e1510db25fc448ad6c2ce
Rust
nyantec/sensorlog
/src/logfile_partition.rs
UTF-8
2,728
2.703125
3
[ "MirOS" ]
permissive
/** * Copyright © 2018 nyantec GmbH <oss@nyantec.com> * Authors: * Paul Asmuth <asm@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 without restriction, including un‐ * lim...
true
a27bc29aa48c4a6f90cb8f318c47ee88a73bfe9a
Rust
ivoelbert/HECTOR
/src/typecheck/mod.rs
UTF-8
10,006
3.0625
3
[]
no_license
#![allow(clippy::pub_enum_variant_names)] use std::collections::HashMap; use serde::{Serialize, Serializer}; extern crate snowflake; pub use std::sync::Arc; use crate::ast::*; use crate::externals::{External, ArgumentType, EXTERNALS}; mod intexp; mod opexp; mod recordexp; mod seqexp; mod assignexp; mod ifexp; mod whi...
true
eb5ad8039d0ec50297d8524f83b62f6ec51b2dcd
Rust
rishflab/parallax-scrolling-shader
/src/time.rs
UTF-8
756
3.0625
3
[]
no_license
use std::time::{Duration, Instant}; pub struct Timer { tick: Instant, elapsed: Duration, } impl Timer { pub fn new() -> Self { Timer { tick: Instant::now(), elapsed: Duration::from_secs(0), } } pub fn tick(&mut self) { let tock = Instant::now(); ...
true
cd36e67b7e1dbba23e3c4dd1601163e6804d4606
Rust
GaloisInc/mir-verifier
/lib/libcore/tests/char.rs
UTF-8
11,467
3.203125
3
[]
permissive
use std::convert::TryFrom; use std::str::FromStr; use std::{char, str}; #[test] fn test_convert() { assert_eq!(u32::from('a'), 0x61); assert_eq!(char::from(b'\0'), '\0'); assert_eq!(char::from(b'a'), 'a'); assert_eq!(char::from(b'\xFF'), '\u{FF}'); assert_eq!(char::try_from(0_u32), Ok('\0')); a...
true
f2cf670bc7b815bfe5bf1b1899ddca3be04f7158
Rust
baszalmstra/adventofcode2018
/src/bin/day6.rs
UTF-8
3,765
3.265625
3
[]
no_license
use aoc::Point; use std::collections::VecDeque; #[derive(Copy, Clone, Debug)] enum VoronoiCell { Uninitialized, ClosestTo(usize, u32), MultipleClosest, } fn main() { // Parse the input let input: Vec<Point> = std::fs::read_to_string("inputs/day6/input") .expect("Could not read input file")...
true
c335f77157e33c8133051b040eb18adf9b409ef3
Rust
dima74/factorio-servers-statistics
/src/state/big_string.rs
UTF-8
5,716
3.03125
3
[]
no_license
use std::num::NonZeroU32; use hashbrown::HashMap; use serde::{Deserialize, Serialize}; // todo documentation #[derive(Eq, PartialEq, Serialize, Deserialize)] pub struct BigString { #[serde(skip)] debug_name: String, // utf8-строка содержащая последовательность подстрок, разделённых символом \x00 // ["...
true
ea9b15431eac4ab3aef82ed099e9d6ef21d5c7ac
Rust
LinAGKar/advent-of-code-2020-rust
/day18b/src/main.rs
UTF-8
4,218
3.421875
3
[ "MIT" ]
permissive
use std::boxed::Box; use std::io; use std::io::Read; #[derive(Debug, Clone, Copy)] enum Op { Add, Mult, } #[derive(Debug)] enum Token { Number(i64), Op(Op), Lbrace, Rbrace, } struct Lexer<'a> { source: Box<dyn Iterator<Item=char> + 'a>, next_char: Option<char>, } impl<'a> Iterator fo...
true
e8b2da324f5de1aa52f317c11760c57817b90092
Rust
ftilde/rust-x86asm
/src/test/instruction_tests/instr_xsave.rs
UTF-8
2,137
2.5625
3
[ "MIT" ]
permissive
use instruction_def::*; use test::run_test; use Operand::*; use Reg::*; use RegScale::*; use RegType::*; use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; #[test] fn xsave_1() { run_test( &Instruction { mnemonic: Mnemonic::XSAVE, operand...
true
2f5e78a63108a55daba050f8c30602ce4e69c7da
Rust
jD91mZM2/chess-minimax
/src/lib.rs
UTF-8
2,988
3.203125
3
[ "MIT" ]
permissive
#[macro_use] extern crate failure; use std::fmt; pub mod board; pub mod minimax; pub mod piece; pub mod serialize; // Not really a part of the library, just need this for sharing interface with // WASM and binary. #[cfg(feature = "terminal")] pub mod terminal; /// A position on the board #[derive(Debug, Default, Cl...
true
593bfce9b1bd6e97b02a27c8dfd2fc6c9c4b7f68
Rust
k-hamada/exercism
/rust/scrabble-score/src/lib.rs
UTF-8
673
2.546875
3
[]
no_license
#[macro_use] extern crate lazy_static; use std::collections::HashMap; lazy_static! { static ref SCORE_MAP: HashMap<char, u32> = { [('A', 1), ('B', 3), ('C', 3), ('D', 2), ('E', 1), ('F', 4), ('G', 2), ('H', 4), ('I', 1), ('J', 8), ('K', 5), ('L', 1), ('M', 3), ('N', 1), ('O', ...
true
58edab8b2e637c8e3d373e9305e9cb5da98978a2
Rust
indefini/dormin
/src/input.rs
UTF-8
469
3.203125
3
[]
no_license
use std::collections::HashSet; pub struct Input { keys : HashSet<u8> } impl Input { pub fn new() -> Input { Input { keys : HashSet::new() } } pub fn is_key_down(&self, k : u8) -> bool { self.keys.contains(&k) } pub fn add_key(&mut self, k : u8) ...
true
a85705723c8505daa27717417c216d72fac4cef0
Rust
Nuwanda/despesas_casa_backend
/src/controllers/expense.rs
UTF-8
2,279
2.515625
3
[]
no_license
use diesel::prelude::*; use rocket_contrib::databases::diesel; use rocket_contrib::json::JsonError; use crate::domain::models::{Expense, JsonResult, NewExpense, NewExpenseUser}; use crate::domain::services::database::schema::{expense_user, expenses}; use crate::domain::services::database::Conn as DbConn; use crate::re...
true
4619f0ffb7da32f41f3671a91d1b279a64a4afc7
Rust
vinnyhoward/til
/rust/rust-sandbox/src/functions.rs
UTF-8
556
3.921875
4
[ "MIT" ]
permissive
pub fn run() { greeting("Hola", "Vincent"); // Bind function values to variables let get_sum = add(10, 5200); println!("{}", get_sum); // Closure let n3: i32 = 1; let add_int = |n1: i32, n2: i32| n1 + n2 + n3; println!("Closure Sum: {}", add_int(9990, 9)); } fn greeting(greet: &str, n...
true
27be47dec40d70c2375efc76772f774e0cccd43a
Rust
shengLin-alex/rust-minigrep
/src/main.rs
UTF-8
1,004
3.125
3
[]
no_license
extern crate minigrep; use std::env; use std::process; use minigrep::Config; /// 主程式 fn main() { let args: Vec<String> = env::args().collect(); // collect() 用來將 iter 轉為集合 // Config 的構造函數改為回傳 Result, 因此此處對 Result 進行處理 // unwarp_or_else() 將自動拆封 Ok(value), 如果出錯, 則呼叫傳入的閉包(callback) let config: Config = ...
true
39122baa1c24d3ba54feac4c469065ca6ea2c78c
Rust
davll/echo-server-rs
/src/main.rs
UTF-8
1,206
2.953125
3
[]
no_license
use async_std::prelude::*; use async_std::net::{TcpListener, TcpStream}; use async_std::task; #[async_std::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let listener = TcpListener::bind("127.0.0.1:8080").await?; println!("Echo server is listening to {}", listener.local_addr()?); let mut...
true
c378e22a7ddfccc29c8402e2fa3618263f6d18b1
Rust
learning-on-chip/planner
/src/lib/format/threed_ice.rs
UTF-8
1,037
2.703125
3
[ "MIT" ]
permissive
use std::io::Write; use Result; use layout::Element; macro_rules! element_template( () => ( r#"{name}: position {x:.0}, {y:.0}; dimension {width:.0}, {height:.0}; power values 0; "# ); ); /// The 3D-ICE format. pub struct ThreeDICE; impl super::Format for ThreeDICE { fn write(&self, elements: &[E...
true
39c1e318ecb0d0be46fb456a294c182f9c609bac
Rust
aedm/stillaxis
/rust/stillaxis/src/stillaxis.rs
UTF-8
6,865
2.703125
3
[]
no_license
use crate::dom::document::Document; use crate::dom::flow_node::{Element, ElementProviderRef, ElementRef}; use crate::dom::mutation::FlowMutation; use stillaxis_core::node::{Node, ProviderRef}; use stillaxis_core::render::render_graph::Message::{GetProviderValue, Mutate}; use stillaxis_core::render::render_graph::{Provi...
true
8f5a5735329c6dff43340a1dce377147758dffd6
Rust
rust-vmm/vm-device
/src/resources.rs
UTF-8
13,563
3.03125
3
[ "Apache-2.0", "BSD-3-Clause" ]
permissive
// Copyright (C) 2019 Alibaba Cloud. All rights reserved. // SPDX-License-Identifier: Apache-2.0 //! Structs to manage device resources. //! //! The high level flow of resource management among the VMM, the device manager, and the device //! is as below: //! 1) the VMM creates a new device object. //! 2) the VMM asks ...
true
7d196773b06f9362decd87f40b4d76fd2c4e9ec3
Rust
ffizer/ffizer
/src/error.rs
UTF-8
4,946
2.671875
3
[ "CC0-1.0" ]
permissive
// see : // - [std::error::Error - Rust](https://doc.rust-lang.org/std/error/trait.Error.html) // - [Error Handling - A Gentle Introduction to Rust](https://stevedonovan.github.io/rust-gentle-intro/6-error-handling.html) // - [snafu::guide::comparison::failure - Rust](https://docs.rs/snafu/0.4.3/snafu/guide/comparison/...
true
2554d0bc149ae4b5d7325aeddafab7bc5badf413
Rust
Miliox/kiwi
/src/emulator/mmu.rs
UTF-8
179
2.5625
3
[]
no_license
pub trait Memory { // Read a single byte from memory fn read(&self, addr: u16) -> u8; // Write a single byte to memory fn write(&mut self, addr: u16, data: u8); }
true
3470463bb154b4412b65ed55ca3b45e57ed10e56
Rust
yukibtc/rrrdb
/src/rrrdb.rs
UTF-8
5,838
2.640625
3
[ "Apache-2.0" ]
permissive
use parser::Parser; use crate::rrrdb::schema::ColumnType; use crate::rrrdb::storage::Storage; use self::{parser::ParserError, sql::executor::Executor, sql::planner::Planner}; mod parser; mod schema; mod sql; mod storage; pub struct RrrDB { pub(crate) underlying: Storage, } impl RrrDB { pub fn new(path: &st...
true
5ff5872420fe81f8b2e518a908d3ebf2d1941f87
Rust
minijackson/INF-4101C
/src/processing.rs
UTF-8
14,669
2.828125
3
[ "MIT" ]
permissive
extern crate image; use self::image::{ ImageBuffer, Luma, Pixel }; pub fn sobel(frame : ImageBuffer<Luma<u8>, Vec<u8>>) -> ImageBuffer<Luma<u8>, Vec<u8>> { let mut result = ImageBuffer::new(640, 480); for i in 1..638 { for j in 1..478 { let north_west = frame[(i-1, j-1)].chann...
true
47ffb5934468b61d10b34d477815b617d1c70589
Rust
tokio-rs/tracing
/tracing-subscriber/tests/event_enabling.rs
UTF-8
2,249
2.75
3
[ "MIT" ]
permissive
#![cfg(feature = "registry")] use std::sync::{Arc, Mutex}; use tracing::{collect::with_default, Collect, Event, Metadata}; use tracing_subscriber::{prelude::*, registry, subscribe::Context, Subscribe}; struct TrackingLayer { enabled: bool, event_enabled_count: Arc<Mutex<usize>>, event_enabled: bool, o...
true
8ea36765f9bd7bbd4673d368a7dfabc1f303f01a
Rust
behzadnouri/rust-lock-bug-detector
/examples/tikv-wrapper/src/util.rs
UTF-8
384
2.765625
3
[ "Apache-2.0" ]
permissive
use std::sync::{RwLock, RwLockWriteGuard, RwLockReadGuard}; pub trait HandyRwLock<T> { fn wl(&self) -> RwLockWriteGuard<'_, T>; fn rl(&self) -> RwLockReadGuard<'_, T>; } impl<T> HandyRwLock<T> for RwLock<T> { fn wl(&self) -> RwLockWriteGuard<'_, T> { self.write().unwrap() } fn rl(&self) -...
true
abf85a57dd7fba20a6baa6a0ce4d08df52c2e4c6
Rust
pantsbuild/pants
/src/rust/engine/hashing/src/fingerprint_tests.rs
UTF-8
2,247
2.796875
3
[ "Apache-2.0" ]
permissive
// Copyright 2022 Pants project contributors (see CONTRIBUTORS.md). // Licensed under the Apache License, Version 2.0 (see LICENSE). use crate::Fingerprint; use serde_test::{assert_ser_tokens, Token}; #[test] fn from_bytes_unsafe() { assert_eq!( Fingerprint::from_bytes_unsafe(&[ 0xab, 0xab, 0xab, 0xab, 0xa...
true
20c5afb4707cb29486e79bcc0090c2a3780063b0
Rust
josh-perry/webserver
/src/request.rs
UTF-8
347
2.59375
3
[]
no_license
use std::fmt; use std::collections::HashMap; use crate::verb; #[derive(Debug)] pub struct Request { pub verb: verb::Verb, pub path: String, pub body: String, pub headers: HashMap<String, String> } impl fmt::Display for Request { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!...
true
1fb6c9a61ad85d68ac3fee20dd2c425a508964fb
Rust
wagao29/hack-assembler
/src/main.rs
UTF-8
2,527
2.6875
3
[]
no_license
use hack_assembler::{code, parser, symbol_table}; use std::io::prelude::*; use std::io::{BufReader, BufWriter}; use std::{env, fs}; fn main() { let args: Vec<String> = env::args().collect(); let input_file_name = &args[1]; let input_file = BufReader::new(fs::File::open(input_file_name).unwrap()); let ...
true
02eaced8715d2add282f79421841a7ce431febf6
Rust
tormol/iterator_markers
/lib.rs
UTF-8
8,710
2.953125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2016 Torbjørn Birch Moltu. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except acc...
true
ea1a5568a8053fb6ffaa91d0bf4cac63d34d7a8d
Rust
Geigerkind/Rust-testing-example
/src/tests/random_testing.rs
UTF-8
781
2.75
3
[]
no_license
use proptest::prelude::*; use crate::tools::parse_date; proptest! { #[test] fn doesnt_crash(s in "\\PC*") { parse_date(&s); } #[test] fn parses_all_valid_dates(s in "[0-9]{4}-[0-9]{2}-[0-9]{2}") { parse_date(&s).unwrap(); } #[test] fn parses_date_back_to_original(y in ...
true
d084fb2970b6fc5bfa3fcd74f5e15656144ae449
Rust
jonasvandervennet/rusty_snake
/src/lib.rs
UTF-8
6,088
3.53125
4
[ "MIT" ]
permissive
use std::process::Command; use std::io::{BufWriter, stdout}; use std::io::Write; use std::{thread, time}; // For sleeping pub struct Game { // dimensions of the map height: usize, width: usize, // all locations containing food pub food_locations: Vec<Location>, // snake snake: Snake } #...
true
c0292786c55101dbded3f8f99422dcd167595299
Rust
baitcenter/cvmath
/src/num/mod.rs
UTF-8
1,221
2.53125
3
[]
no_license
/*! Numeric traits. */ use std::{cmp, fmt, ops}; mod zero; mod one; mod cast; mod extrema; mod abs; mod spatial_ord; mod float_ops; pub use self::zero::Zero; pub use self::one::One; pub use self::cast::{CastFrom, CastTo}; pub use self::extrema::Extrema; pub use self::abs::Abs; pub use self::spatial_ord::SpatialOrd; ...
true
685dd624372d485632b4f1a4aaa9d8a0099a49cb
Rust
snoyberg/actix-website
/examples/responses/src/json_resp.rs
UTF-8
573
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
// <json-resp> use actix_web::{web, HttpResponse, Result}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize)] struct MyObj { name: String, } async fn index(obj: web::Path<MyObj>) -> Result<HttpResponse> { Ok(HttpResponse::Ok().json(MyObj { name: obj.name.to_string(), })) } #[a...
true
def5d086e89e6e1cd86e572f8e840d6d609800a7
Rust
briansmith/ring
/src/polyfill/array_flat_map.rs
UTF-8
3,964
3.5625
4
[ "LicenseRef-scancode-unknown-license-reference", "OpenSSL", "MIT", "ISC", "LicenseRef-scancode-mit-taylor-variant", "LicenseRef-scancode-openssl", "LicenseRef-scancode-ssleay-windows" ]
permissive
use core::iter::FlatMap; /// A specialized version of `core::iter::FlatMap` for mapping over exact-sized /// iterators with a function that returns an array. /// /// `ArrayFlatMap` differs from `FlatMap` in that `ArrayFlatMap` implements /// `ExactSizeIterator`. Since the result of `F` always has `LEN` elements, if //...
true
d6f6520c59a4522977e8a3d6cd505c691502095a
Rust
fbegyn/podder
/src/main.rs
UTF-8
2,228
3.203125
3
[]
no_license
mod episode; mod podcast; use structopt::StructOpt; use threadpool::ThreadPool; #[derive(Debug, StructOpt)] #[structopt(raw(setting = "structopt::clap::AppSettings::ColoredHelp"))] #[structopt( name = "Podder", about = "An app to download your podcasts, fast and easy" )] struct Cli { #[structopt( ...
true
2f00b3cf3ef0f8a94d38820ce4bb2733593902e8
Rust
qeedquan/challenges
/kattis/tais-formula.rs
UTF-8
2,502
3.484375
3
[ "MIT" ]
permissive
/* Have you heard about the mastermind Tai? He found a way to calculate the area under a glucose curve, given discrete measurement points. He even validated his formula against the approximate technique of counting the number of squares below the graph, when printed on graph paper. Can you, just like Tai, reinvent th...
true
1bf7bc052fd94bc71cc1bb8320f3130e2212dc98
Rust
wayeast/visual-levenshtein
/examples/words.rs
UTF-8
901
3.390625
3
[]
no_license
use visual_levenshtein::{levenshtein_words, Edit}; fn main() { let encoder = |e: Edit| match e { Edit::Equality(s) => format!("{}", s), Edit::Deletion(s) => format!("[-{}-]", s), Edit::Insertion(s) => format!("{{+{}+}}", s), Edit::Substitution(o, d) => format!("[-{}-]{{+{}+}}", o, d...
true
42218402bdf34a34a7e326b2a8e57e4ecd36bd6c
Rust
sdleffler/tll-array-rs
/src/array.rs
UTF-8
12,556
3.015625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use std::fmt; use std::mem; use std::ops::{Deref, DerefMut}; use std::ptr; use std::slice; use tll::ternary::{Nat, Pred, NatPred, Triple, NatTriple, Zero, One, Two}; use tll_iterator::{SizedIterator, NonEmpty, FromSizedIterator}; use guillotine::*; use storage::*; /// The `array![]` macro provides a convenient way ...
true
f5709e1ff756e9c3cfcb8fe60b054c20a66d1277
Rust
salsa-rs/salsa
/src/storage.rs
UTF-8
2,033
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::{plumbing::DatabaseStorageTypes, Runtime}; use std::sync::Arc; /// Stores the cached results and dependency information for all the queries /// defined on your salsa database. Also embeds a [`Runtime`] which is used to /// manage query execution. Every database must include a `storage: /// Storage<Self>` fi...
true
86aace17271bb8f95f3a2cc56eb8613326f74cae
Rust
ZefCo/swttrpg_dice
/src/main.rs
UTF-8
1,159
2.921875
3
[]
no_license
// use std::collections::HashMap; use std::fs::File; use std::io::Read; use serde::Deserialize; mod filepath; fn main() { // println!("Hello, world!"); let cwd = filepath::cwd().expect("Incorrect Permissions"); println!("The cwd = {}", cwd.display()); let json_file = filepath::adjecent_file("dice_sid...
true
b21ef29a9a31c6a0adee6431c62870dbf6c926db
Rust
holsee/bloom_spell
/src/util/bloom_filter.rs
UTF-8
2,333
3.046875
3
[]
no_license
use super::bitvec_rs::BitVec; use super::fnv::FnvHasher; use std::hash::{Hash, Hasher}; use std::collections::hash_map::DefaultHasher; #[derive(Debug)] pub struct BloomFilter { bits: BitVec, hash_count: u8 } impl BloomFilter { // pub fn from(expected_inserts: usize, fpr: f64) -> BloomFilter { // l...
true
4870aaaa2f900bfbc25bc07857dccd554aa23329
Rust
LinAGKar/advent-of-code-2017-rust
/day20a/src/main.rs
UTF-8
3,071
3.28125
3
[ "MIT" ]
permissive
extern crate regex; use regex::Regex; use std::cmp::Ordering; use std::io; use std::io::Read; use std::ops::Mul; use std::ops::AddAssign; #[derive(Debug, Eq, Clone, Copy)] struct Vec3 { x: i64, y: i64, z: i64, } impl Vec3 { fn non_negative(&self) -> bool { self.x >= 0 && self.y >= 0 && self.z...
true
e27d1fe757cbdbfb835f8757db23b15e4325ebe9
Rust
rome/tools
/crates/rome_js_analyze/src/semantic_analyzers/suspicious/no_array_index_key.rs
UTF-8
8,734
2.859375
3
[ "MIT" ]
permissive
use crate::react::{is_react_call_api, ReactLibrary}; use crate::semantic_services::Semantic; use rome_analyze::context::RuleContext; use rome_analyze::{declare_rule, Rule, RuleDiagnostic}; use rome_console::markup; use rome_js_syntax::{ AnyJsFunction, AnyJsMemberExpression, JsCallArgumentList, JsCallArguments, JsCa...
true
9128298b70009174e3d94900a941953c6de47253
Rust
xorxornop/oidc-rs
/src/models/identity_resource.rs
UTF-8
2,429
3.265625
3
[ "Apache-2.0" ]
permissive
use std::vec::Vec; use super::resource::Resource; /// Models a user identity resource. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct IdentityResource { /// Indicates if this resource is enabled. Defaults to true. enabled: bool, /// The unique name of the resource. name: St...
true
43ab846803dd84a56f29bb8d9a87729c119938a4
Rust
maxmcc/aoc-2020
/src/bin/day06.rs
UTF-8
1,936
3.21875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use anyhow::ensure; use aoc::{Parse, Result, Solve}; use std::ops::{BitAnd, BitOr}; #[derive(Clone, Debug)] struct CustomsForms { groups: Vec<Vec<u32>>, } impl<'a> Parse<'a> for CustomsForms { fn parse<'b: 'a>(input: &'b str) -> Result<Self> { fn parse_answers(line: &str) -> Result<u32> { ...
true
bb49345020cf30e70cf6fd2be10991a9dbf33510
Rust
magiclen/validators-old
/src/validator_option.rs
UTF-8
785
3
3
[ "MIT" ]
permissive
#[derive(Debug, PartialEq)] pub enum ValidatorOption { Must, Allow, NotAllow, } impl ValidatorOption { #[inline] pub fn allow(&self) -> bool { match self { ValidatorOption::Must => true, ValidatorOption::Allow => true, ValidatorOption::NotAllow => false, ...
true
6dd975f7d91ed1f6add3890bc4bfb75ba093db2f
Rust
FlixCoder/open-forward-NN
/src/lib.rs
UTF-8
17,272
2.9375
3
[ "Apache-2.0" ]
permissive
//! @author = FlixCoder //! //! Architecture influenced by Keras: Sequential models #![allow(clippy::expect_used)] // TODO: get rid of it. mod activations; pub mod losses; use std::{fs::File, io::prelude::*}; use rand::prelude::*; use rand_distr::Normal; use serde::{Deserialize, Serialize}; /// This crate's float v...
true
6ec29b0b4f27f896632e6161aa7c58c2e72562cb
Rust
isavegas/aoc_2019
/src/day/day_06.rs
UTF-8
1,877
2.78125
3
[]
no_license
use aoc_core::{bail, AoCDay, ErrorWrapper}; use std::collections::HashMap; pub struct Day06; fn build_chain(target: &str, map: &HashMap<String, String>, v: &mut Vec<String>) { let mut last = target; while last != "COM" { last = map.get(last).unwrap(); v.push(last.to_string()); } } impl Ao...
true
9afb0242610556d8761bb61659c78101af75cfe1
Rust
akmal-ali-learning/sw-rust
/book/chapter8/hashmap/src/main.rs
UTF-8
1,572
3.53125
4
[ "MIT" ]
permissive
use std::collections::HashMap; fn main() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"), 50); let teams = vec![String::from("Blue"), String::from("Yellow")]; let initial_scores = vec![10, 50]; let scores: HashMap<_, _> = teams.iter().zip(initial...
true
0744c76b4754b9934f79a7777ae0604328fe7220
Rust
bave/kdtree
/src/bin/bench.rs
UTF-8
2,715
2.84375
3
[ "BSD-2-Clause" ]
permissive
extern crate kdtree; #[allow(unused_imports)] use self::kdtree::*; //use kdtree::*; #[allow(unused_imports)] use rand::prelude::*; /* #![feature(asm)] #[allow(dead_code)] fn rdtscp_unsafe() -> u64 { let mut aux : u32 = 0; let aux_ptr : *mut u32 = &mut aux; unsafe { std::arch::x86_64::__rdtscp(aux_ptr) } ...
true
84d1d79d08f098d3c186e0c03f7cd48efdde9f20
Rust
aswaving/yenc
/src/encode.rs
UTF-8
12,458
3.375
3
[ "MIT" ]
permissive
use super::constants::{CR, DEFAULT_LINE_SIZE, DOT, ESCAPE, LF, NUL}; use super::errors::EncodeError; use std::fs::File; use std::io::{BufReader, BufWriter, Read, Seek, SeekFrom, Write}; use std::path::Path; /// Options for encoding. /// The entry point for encoding a file (part) /// to a file or (TCP) stream. #[deriv...
true
164daac122890163d0a0836fe41a4d0879c65c7b
Rust
kubo/rosy
/src/prelude.rs
UTF-8
1,094
3.125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Types and traits that are commonly used within this library. //! //! This module is intended to be glob imported via `use rosy::prelude::*` when //! primarily working with Rosy types. This allows for having access to _almost_ //! everything one may need. //! //! **Note:** These items are all already available at th...
true
8f8012762e6849c355e8f086bcdc25ce97491a2e
Rust
deffen3/discovery
/src/09-clocks-and-timers-tasks/src/main.rs
UTF-8
1,934
2.75
3
[ "CC-BY-4.0", "Apache-2.0", "MIT" ]
permissive
#![no_main] #![no_std] use aux9_tasks::entry; #[entry] fn main() -> ! { let (mut leds, rcc, tim6) = aux9_tasks::init(); // Power on the TIM6 timer rcc.apb1enr.modify(|_, w| w.tim6en().set_bit()); // SR, the status register. // EGR, the event generation register. // CNT, the counter register....
true
bf3a16c22140627d4630f89fbec10eb91d743ffc
Rust
kawmarco/unix-fun
/rustbox/src/ls.rs
UTF-8
2,592
3.734375
4
[]
no_license
use std::fs; use std::io; pub fn main(args: Vec<String>) -> io::Result<()> { // if no arguments are passed, use current working dir let cwd = vec![".".to_string()]; let mut files: &Vec<String> = &args; if files.len() == 0 { files = &cwd; } _ls(files, &mut io::stdout()) } fn _ls(files:...
true
c7217ce1080461f4c7a7f1951a284ec8741617d5
Rust
ivlevAstef/BFS_MoreLanguages
/rust/src/array2d/normal.rs
UTF-8
1,132
3.21875
3
[]
no_license
use super::{point, Point}; pub struct Array2D<T> { inner: Vec<Vec<T>>, } impl<T: Copy> Array2D<T> { pub fn filled_with(value: T, width: usize, height: usize) -> Self { Self { inner: vec![vec![value; height]; width], } } } impl<T> std::ops::Index<Point> for Array2D<T> { typ...
true
791e9d7d8a14ed8ce06a408728e46715019d803a
Rust
nebula-os/ppk
/src/package_reference.rs
UTF-8
592
2.578125
3
[]
no_license
use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(rename_all = "lowercase")] #[serde(untagged)] pub enum PackageReference { Git(GitReference), File(FileReference), } #[derive(Serialize, Deserialize, Builder, Debug, Clone)] #[serde(rename_all = "kebab-case")] pub stru...
true
9e617659fe946c9b662e143d56ad244960bf0919
Rust
Karuturirs/bolts-with-rust
/src/BoxUsage.rs
UTF-8
339
3.390625
3
[]
no_license
enum List { Cons(i32, Box<List>), Nil, } use crate::List::{Cons, Nil}; fn main() { let list = Cons(1, Box::new(Cons(2, Box::new(Cons(3, Box::new(Nil)))))); println!("Welcome to bolts-with-rust"); let x = 5; let y = &x; assert_eq!(5, x); ass...
true
277ec0e3a380776a9e674da9eb394204285a1433
Rust
thomasantony/sudoku-rs
/src/utils.rs
UTF-8
1,536
3.15625
3
[]
no_license
use itertools::iproduct; use std::collections::HashMap; use std::iter::FromIterator; pub type SudokuGrid = HashMap<(usize, usize), Option<usize>>; pub fn grid_9x9_keys() -> impl Iterator<Item=(usize, usize)> { let boxes = iproduct!(0..9, 0..9); boxes } pub fn parse_grid(s: String) -> SudokuGrid { let box...
true
a9d8b1080ef54ec56fd1994f9dd830276afe0c6b
Rust
unmellow/advent-of-code-2019
/src/bin/6.rs
UTF-8
2,628
3.03125
3
[]
no_license
use advent_of_code_2019::example; use advent_of_code_2019::problem::{run, Problem, ProblemState, RunFor}; use env_logger::Env; use std::collections::{HashMap, VecDeque}; struct Six {} impl Problem for Six { type Input = HashMap<String, String>; type Extra = (); fn parse(s: &str, _state: &ProblemState<Sel...
true
b298db6f91238580e3d572a70ade5e1fe2355344
Rust
edomora97/wireguard-manager
/src/web.rs
UTF-8
4,752
2.6875
3
[ "MIT" ]
permissive
use crate::config::ServerConfig; use crate::schema; use crate::wireguard::gen_client_config; use failure::Error; use hyper::{Body, Request, Response, StatusCode}; use serde::Serialize; use tokio::fs::File; use tokio::io::AsyncReadExt; use tokio_postgres::Client; /// Status of a server in the network. This will be seri...
true
a2bf435215818bdf2fbf943c392a1cd50267b296
Rust
ragnarula/advent-of-code
/day5/src/main.rs
UTF-8
2,378
3.296875
3
[]
no_license
fn main() { println!( "Part 1 Result - {}", solve_1(include_str!("../data/input.txt")) ); println!( "Part 2 Result - {}", solve_2(include_str!("../data/input.txt")) ); } fn does_react(a: char, b: char) -> bool { (a.is_ascii_lowercase() && b.is_ascii_uppercase() && a ...
true
e0b1eb4139215b718b01ed805bd2c3cfcfe5a99e
Rust
iCodeIN/secbot-2021-7drl
/src/game/combat.rs
UTF-8
10,685
2.640625
3
[ "MIT" ]
permissive
use crate::components::*; use crate::map::*; use crate::NewState; use bracket_lib::prelude::*; use legion::systems::CommandBuffer; use legion::*; use std::collections::HashSet; pub fn player_open_fire_at_target(ecs: &mut World, map: &mut Map) -> NewState { let mut player_entity = None; let mut target = None; ...
true
ee54fb9846a32ef9a93d554e38dcdc7c4238f8dd
Rust
emahiro/il
/rs_sandbox/rs_grep_handson/src/main.rs
UTF-8
1,023
3.09375
3
[]
no_license
use std::fs::read_to_string; use structopt::StructOpt; #[derive(StructOpt)] // attribute cf. annotation #[structopt(name = "rsgrep")] struct GrepArgs { #[structopt(name="PATTERN")] pattern: String, #[structopt(name="NAME")] path: String, } // impl GrepArgs { // fn new(pattern: String, path: String...
true
564d7fd55d3f4deab3ba7206458f0a9b4514fa4d
Rust
manuels/taikai
/src/parser/mod.rs
UTF-8
6,943
2.546875
3
[]
no_license
use std::collections::HashMap; use std::rc::Rc; use std::cell::RefCell; use proc_macro2::TokenStream; use serde::Deserialize; use quote::quote; use crate::types; use crate::enums; use crate::type_spec::TypeSpec; use crate::attribute; #[derive(Deserialize, Debug)] #[serde(rename_all = "kebab-case")] struct Meta { ...
true
5187b7f002b54a3b4eb0018ba469095c59f306d5
Rust
rustabit/mrvn-bot
/mrvn-front-discord/src/config.rs
UTF-8
1,995
2.921875
3
[ "MIT" ]
permissive
use serde::Deserialize; use std::collections::HashMap; use serde::de::Error; #[derive(Debug, Deserialize, Clone)] pub struct CommandBot { pub token: String, pub application_id: u64, pub guild_id: Option<u64>, } #[derive(Debug, Deserialize, Clone)] pub struct VoiceBot { pub token: String, pub appli...
true
70adadf503b82c695a73acf68bc693b6a32d0852
Rust
CyberFlameGO/abi_stable_crates
/abi_stable/src/nonexhaustive_enum/nonexhaustive.rs
UTF-8
25,463
2.859375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
/*! Contains `NonExhaustive<>` and related items. */ use std::{ cmp::{Ordering,PartialEq,Eq,Ord,PartialOrd}, fmt::{self,Debug,Display}, hash::{Hash,Hasher}, marker::PhantomData, mem::ManuallyDrop, ops::Deref, }; use crate::{ abi_stability::StableAbi, erased_types::{ c_functions...
true
13c22355f06f0a3e7b97bafbd8a1747303a81c72
Rust
Kintaro/wtftw
/core/src/layout.rs
UTF-8
4,742
2.96875
3
[ "BSD-3-Clause" ]
permissive
use crate::config::GeneralConfig; use crate::core::stack::Stack; use std::borrow::ToOwned; use crate::window_manager::ScreenDetail; use crate::window_system::Rectangle; use crate::window_system::Window; use crate::window_system::WindowSystem; #[derive(Clone, Copy)] pub enum LayoutMessage { Increase, Decrease, ...
true
84290625eba6b796275efc062c75568328fbeed2
Rust
super-rust-boy/super-rust-boy
/src/video/renderer_nothreads.rs
UTF-8
1,241
3.25
3
[ "MIT" ]
permissive
// Pixel renderer. Makes a texture of format R8G8B8A8Unorm use super::vram::VRAM; use super::regs::VideoRegs; use std::sync::{ Arc, Mutex }; pub type RenderTarget = Arc<Mutex<[u8]>>; // Messages to send to the render thread. enum RendererMessage { StartFrame(RenderTarget), // Begin frame, and target th...
true
2db97a432379e8cbe31a5c3369bb2fb14ae3054a
Rust
saritseal/naiad
/src/main.rs
UTF-8
1,121
3.265625
3
[]
no_license
#[allow(unused_imports)] use std::mem; fn analyze_slice(slice: &[i32]) { println!("first element of the slice: {}", slice[0]); println!("the slice has {} elements", slice.len()); } extern crate graphx; use graphx::graph_x; fn main() { let str = "SSSSSSS-dddd dfdfd"; println!("Hello, world! {}", str);...
true
e7599dde2534b1864b971124093533414f9a14e3
Rust
BrunoWallner/audiolizer
/src/ui/bars.rs
UTF-8
1,672
2.703125
3
[ "MIT" ]
permissive
use iced::{ canvas::{self, Cache, Canvas, Cursor, Geometry}, Color, Element, Length, Point, Rectangle, Vector, Size, }; use crate::Message; pub struct Bars { pub data: Vec<f32>, pub cache: Cache, pub mirroring: bool, pub width: f32, pub r: u8, pub g: u8, pub b: u8, } impl Bars ...
true
9e964aa63c3c58d507fa369fb58e9f5628ad8222
Rust
suclogger/leetcode-rust
/week/week251/maximum-compatibility-score-sum/src/main.rs
UTF-8
1,178
2.703125
3
[]
no_license
fn main() { println!("Hello, world!"); } /** 暴力求解 **/ pub fn max_compatibility_sum(students: Vec<Vec<i32>>, mentors: Vec<Vec<i32>>) -> i32 { fn backtrack(m_selected: &mut Vec<bool>, s_idx: usize, students: &Vec<Vec<i32>>, mentors: &Vec<Vec<i32>>, cur_score:i32, score: &mut ...
true
24408dc27c6790729340ab8b7658651d539c8522
Rust
kirisaki/twinkle
/src/receiver.rs
UTF-8
4,569
2.78125
3
[ "BSD-3-Clause" ]
permissive
use std::net::SocketAddr; use log::{info}; use tokio::net::udp::RecvHalf; use tokio::sync::mpsc::Sender; use crate::types::*; use crate::store::*; use crate::errors::*; #[derive(Debug, PartialEq)] enum Request { Ping, Get(Bytes), Set(Bytes, Bytes), Unset(Bytes), } pub struct Server { pub sock:...
true
471f0fa4b7718a60298cc6e2593816c844986f44
Rust
igxactly/Toshi
/src/query/aggregate/sum.rs
UTF-8
2,300
2.765625
3
[ "MIT" ]
permissive
use super::super::{Error, Result}; use super::AggregateQuery; use tantivy::collector::{Collector, TopCollector}; use tantivy::schema::{Field, Value}; use tantivy::{Searcher, SegmentReader}; #[derive(Serialize, Debug)] pub struct SummaryDoc { field: Field, value: u64, } pub struct SumCollector<'a> { fiel...
true
d44fc0c67266bd79798aca099b3c91c021411b00
Rust
Phytolizer/silver
/silver-language/src/analysis/silver_value.rs
UTF-8
951
3.4375
3
[]
no_license
use std::fmt::Display; use super::silver_type::SilverType; #[derive(Debug, Clone, PartialEq)] pub enum SilverValue { Integer(i128), Boolean(bool), } impl SilverValue { pub fn as_integer(&self) -> Option<i128> { match self { SilverValue::Integer(i) => Some(*i), _ => None, ...
true
c1377b13995c0db99e6b4c2ed2768208d747ec12
Rust
chromium/chromium
/third_party/rust/itoa/v1/crate/benches/bench.rs
UTF-8
1,344
2.71875
3
[ "GPL-1.0-or-later", "MIT", "LGPL-2.0-or-later", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
#![feature(test)] #![allow(non_snake_case)] #![allow(clippy::cast_lossless)] extern crate test; macro_rules! benches { ($($name:ident($value:expr))*) => { mod bench_itoa_format { use test::{Bencher, black_box}; $( #[bench] fn $name(b: &mut Bencher) ...
true
1bf7f52d264872b2aa4ace964ceab64a293c3aa6
Rust
ml-titans/titan4-codes
/emergent/2_make-cli/src/main.rs
UTF-8
4,879
2.6875
3
[ "Apache-2.0" ]
permissive
use anyhow::{anyhow, ensure, Result}; use image::io::Reader as ImageReader; use std::path::{Path, PathBuf}; use structopt::StructOpt; use tensorflow::{Graph, SavedModelBundle, SessionOptions, SessionRunArgs, Tensor}; const MODEL_DIR: &str = "models"; const TEST_DATA_DIR: &str = "images"; const LABELS: [&str; 10] = [ ...
true
e0c0614b368e16568cbe33ce264e3309cd237ffb
Rust
dylanmckay/avr
/src/mem.rs
UTF-8
1,933
3.5625
4
[ "MIT" ]
permissive
use Error; use std; pub type Address = u16; /// A memory space. pub struct Space { data: Vec<u8>, } impl Space { pub fn new(size: usize) -> Self { let data = std::iter::repeat(0).take(size) .collect(); Space { data: data, } } ...
true
8a19bf31b9ebd641c901ad39877b10aaa0c97d90
Rust
shimmy1996/twixter
/src/follow.rs
UTF-8
591
2.78125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use clap::ArgMatches; use std::fs::OpenOptions; use std::io::prelude::*; use std::path::Path; use crate::config::Config; /// Follow new source by writing to the config file. pub fn follow(_config: &Config, subcommand: &ArgMatches, config_path: &Path) { let nick = subcommand.value_of("nick").unwrap(); let url...
true
a62b7a094f3d8a1865401276d734dda5213cb093
Rust
jbelmont/rust_book
/state_machine/src/lib.rs
UTF-8
654
3.015625
3
[ "Apache-2.0" ]
permissive
#![allow(unused_variables)] fn main() { pub struct Post { state: Option<Box<dyn State>>, content: String, } impl Post { // --snip-- pub fn request_review(&mut self) { if let Some(s) = self.state.take() { self.state = Some(s.request_review()) } } } trait State { fn ...
true
de5144bea4f8d8291f30e68c08586fbdbd248724
Rust
crhino/typed
/benches/mod.rs
UTF-8
4,545
2.765625
3
[]
no_license
#![feature(test)] extern crate test; #[macro_use] extern crate typed; extern crate void; use test::Bencher; pub trait Increment { fn increment(&mut self, amt: usize) -> usize; } typed_stack!(Increment); // TODO: Figure out an easy way to not have to manually impl trait here. // This exposes a lot of the inner ...
true
dbbf7e400110072eccb8938484594ea0f51f9e63
Rust
jxs/keg
/keg-functions/src/lib.rs
UTF-8
3,087
2.6875
3
[]
no_license
mod error; mod traits; use regex::Regex; use std::cmp::Ordering; use std::collections::hash_map::DefaultHasher; use std::fmt; use std::hash::{Hash, Hasher}; use chrono::{DateTime, Local}; pub use error::{Error, WrapMigrationError}; pub use traits::{Transaction, DefaultQueries, CommitTransaction, ExecuteMultiple, Quer...
true
590e92678145d9ad9f1be10cb4279f91a6da44a8
Rust
rustlang-top/crate-galaxy-graph
/src/main.rs
UTF-8
2,990
2.6875
3
[ "MIT", "Apache-2.0" ]
permissive
use serde::Deserialize; use std::collections::HashMap; use std::io::prelude::*; use std::io::BufReader; use std::fs::{self, File}; use std::process::{Command, Stdio}; use std::error::Error; #[derive(Deserialize)] #[allow(dead_code)] struct CrateInfo { name: String, vers: String, deps: Vec<DepInfo>, ck...
true
1f3648fa3fe9838a01c6f33f74f4253c3aed8ece
Rust
TWinsnes/rusty-euler
/problem002/problem2.rs
UTF-8
760
3.578125
4
[ "BSD-3-Clause" ]
permissive
use std; ////////////////////////////////////////////////////////// // // Problem: // By considering the terms in the Fibonacci sequence // whose values do not exceed four million, find the sum // of the even-valued terms // ////////////////////////////////////////////////////////// fn main() { std::io::println(#fm...
true
cc4ee366e7ebf437cfad78fb66f28b1b470bfbec
Rust
dmarcuse/dynamic_ocl
/src/safe/buffer/flags.rs
UTF-8
3,318
2.671875
3
[ "Apache-2.0" ]
permissive
//! Buffer access and use flags, to allow validity checks to be performed at //! compile time by the type system. use crate::raw::{ cl_mem_flags, CL_MEM_ALLOC_HOST_PTR, CL_MEM_HOST_NO_ACCESS, CL_MEM_HOST_READ_ONLY, CL_MEM_HOST_WRITE_ONLY, CL_MEM_READ_ONLY, CL_MEM_READ_WRITE, CL_MEM_WRITE_ONLY, }; mod sealed {...
true
b806708cfdbf332bd921d54c74cab1ec13bb3dc0
Rust
cgwalters/qubes-rpm-oxide
/rpm-crypto/src/lib.rs
UTF-8
2,304
2.609375
3
[]
no_license
//! FFI bindings to RPM’s cryptographic API //! //! `librpmio`, which is part of RPM, exposes some cryptographic routines for //! use by third party applications. This crate provides Rust bindings to that //! code. #![forbid(improper_ctypes)] use openpgp_parser::{AllowWeakHashes, Error}; extern crate openpgp_parser;...
true
1186ba7723e223ce088f668bfd12297b9e76b108
Rust
silverweed/ecsde
/inle/inle_input/src/bindings.rs
UTF-8
8,715
2.90625
3
[]
no_license
use super::joystick::{self, Joystick_Button}; use super::keyboard::Key; use super::mouse::{self, Mouse_Button}; use inle_common::stringid::String_Id; use std::collections::HashMap; use std::path::Path; use std::vec::Vec; mod parsing; use self::modifiers::*; #[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord...
true
48a4bf083cc9ce335702324f52bb94c61cb220af
Rust
grogers0/advent_of_code
/2020/day13/src/main.rs
UTF-8
2,316
3.421875
3
[ "MIT" ]
permissive
use std::io::{self, Read}; type Bus = u16; fn parse(puzzle_input: &str) -> (u64, Vec<(Bus, usize)>) { let mut lines = puzzle_input.lines(); let earliest_departure = lines.next().unwrap().parse().unwrap(); let buses = lines.next().unwrap().split(',') .enumerate() .filter(|&(_, bus_str)| bus...
true
0d1d29f2cd9fd161f54e8a63d08117a47b9d1cd9
Rust
josecm/exercism-rust
/sublist/src/lib.rs
UTF-8
575
3.421875
3
[]
no_license
#[derive(Debug, PartialEq)] pub enum Comparison { Equal, Sublist, Superlist, Unequal, } fn is_sublist<T: PartialEq>(f: &[T], s: &[T]) -> bool { if s.len() <= f.len() { return false } s.windows(f.len()).any(|w| w == f) } pub fn sublist<T: PartialEq>(first_list: &[T], second_list: &[T]) -> Compa...
true