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
6fbcfd3cef167b3e92a9d236dc83cce1eb327fb6
Rust
highpear/rust-tutorial-yt
/25_pattern-matching/main.rs
UTF-8
247
3.90625
4
[]
no_license
fn main() { let num = 20; match num { 1 => println!("It is one!"), 2..=20 => println!("It is greater than one!"), // 10 | 11 => println!("It is either 10 or 11"), _ => println!("It doesn't match!") } }
true
3505c4951299ac82f49ed9ee5525d3e6cabef685
Rust
tessereth/kalaha-rust
/src/ai/tests.rs
UTF-8
774
2.875
3
[]
no_license
use super::*; fn assert_depth_eq(depth: u32) { let game = Kalaha::new(); // Do comparison based on score rather than pond to allow the algorithms to choose different // ponds with the same score assert_eq!( MinMax { depth }.choose_depth(&game,game.current_player(), depth).score, AlphaBe...
true
96567fa58730195818f372d338dc4193c69df49b
Rust
remexre/extlint
/get-gitgrade-repos/src/main.rs
UTF-8
4,289
2.625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
//! A command-line tool to clone and/or pull all the CSCI2041 student //! repositories. //! //! This may also work for other classes that use the current (as of //! Spring 2018) GitGrade system, but no guarantees. Try the `--github-url` //! flag if you're trying to do this. //! //! Due to the nature of the current (as ...
true
176dadc9f18a377398ebfcae1f5b3f3373bdc682
Rust
zmanian/miscreant
/rust/src/internals/cmac.rs
UTF-8
3,279
3.09375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
//! `internals/cmac.rs`: Cipher-based Message Authentication Code use super::{Block, BlockCipher, BLOCK_SIZE}; use super::xor; type Tag = Block; /// Cipher-based Message Authentication Code pub struct Cmac<C: BlockCipher> { cipher: C, subkey1: Block, subkey2: Block, state: Block, state_pos: usize...
true
4c65b72a694eb1d95b2fe51fba0a86d18b046604
Rust
caitlingao/leetcode_rust
/src/cd0714_best_time_to_buy_and_sell_stock_with_transaction_fee/mod.rs
UTF-8
3,597
3.90625
4
[]
no_license
//! Best Time to Buy and Sell Stock with Transaction Fee [leetcode: best_time_to_buy_and_sell_stock_with_transaction_fee](https://leetcode.com/problems/best-time-to-buy-and-sell-stock-with-transaction-fee/) //! //! Your are given an array of integers `prices`, for which the `i`-th element is the price of a given stock ...
true
e91c358cb92112a01d5afc5e82d4cc44a16714f3
Rust
ajorgensen/exercism
/rust/hello-world/src/lib.rs
UTF-8
119
2.640625
3
[]
no_license
pub fn hello(maybe_name: Option<&'static str>) -> String { format!("Hello, {0}!", maybe_name.unwrap_or("World")) }
true
d9ff2bd952a2759b480eaac69b01c5fae7712db6
Rust
sdkdevs/pastebin-server
/src/mem_store/handler/save_record.rs
UTF-8
1,415
2.65625
3
[ "MIT" ]
permissive
use super::super::state::State; use crate::data::dto::{ErrRes, SaveRecordReq, SaveRecordRes}; use crate::data::key::nano_to_key; use crate::data::record::Record; use crate::env::MAX_EXPIRATION; use crate::shared::error::HandlerError; use crate::time::{nano_to_sec, now_nano, sec_to_nano}; use actix_web::{web, HttpRespo...
true
5161722bf2caa482cf38b1fb535936582a4d62c0
Rust
royalmustard/breadx
/src/display/connection/dummy/mod.rs
UTF-8
4,545
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
// MIT/Apache2 License #![cfg(test)] //! Provides a dummy connection to be used for doctests. See the `DummyConnection` object for more information. mod setup; use super::Connection; use crate::{ auto::{ xproto::{Setup, SetupRequest}, AsByteSequence, }, display::{BasicDisplay, StaticSetup...
true
ebb0aae80bd5fe24cae58adb8f830733b0b0c368
Rust
luojia65/huaji-lang
/src/main.rs
UTF-8
967
2.84375
3
[]
no_license
// use cranelift; pub mod parser { include!(concat!(env!("OUT_DIR"), "/huaji.rs")); } #[derive(Debug)] pub enum Expr { Assign(String, Box<Expr>), Literal(String), } fn main() { loop { let mut code = String::new(); std::io::stdin().read_line(&mut code).unwrap(); let code = code...
true
2bfc386b98f5d24ab6c59a9dfb8e9b4826fae959
Rust
zhifengle/monkey-rs
/src/parser/node/expression_stmt.rs
UTF-8
308
2.859375
3
[]
no_license
use std::fmt; use super::Expression; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct ExpressionStatement { pub expression: Expression, } impl fmt::Display for ExpressionStatement { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.expression) } }
true
3ff534e444c0f414c8a36fd9b48d56bb3154b182
Rust
pkafma-aon/LeetCode-Rust
/src/longest_substring_without_repeating_characters.rs
UTF-8
758
3.5
4
[ "WTFPL" ]
permissive
use std::collections::HashMap; impl Solution { pub fn length_of_longest_substring(s: String) -> i32 { let mut map: HashMap<char, usize> = HashMap::new(); let (mut i, mut ans) = (0, 0); for (j, c) in s.chars().enumerate() { i = i.max(*map.get(&c).unwrap_or(&0)); ans =...
true
97f765db2361da89b607b00448e8e6d1c1c15300
Rust
isgasho/voltz
/crates/utils/src/bitset.rs
UTF-8
6,431
3.390625
3
[]
no_license
use std::{ alloc::{Allocator, Global}, iter, }; /// A set of integers represented as a bitset. /// /// Capacity is rounded up to the next multiple of 64. #[derive(Debug, Clone)] pub struct BitSet<A: Allocator = Global> { values: Vec<u64, A>, } impl BitSet<Global> { /// Creates a new bitset with the gi...
true
4e604ee7569848b6c6bec12fe23432d56ddb05fe
Rust
aureentuluvacal/learn-rust
/src/chapter08/strings.rs
UTF-8
782
3.71875
4
[]
no_license
fn main() { // Strings are not arrays of characters. They are a vector wrapper with each element in a vector // an integer value of a character. h would be 104 (encoded as one byte) and З (ze) would be 208 and 151 (encoded as two). let mut s = String::from("crab"); let s2 = " rangoon"; let s3 = Stri...
true
cbf19562ae30b94a788df85d29a9db9b46c973d8
Rust
tikv/grpc-rs
/src/channelz.rs
UTF-8
3,605
2.59375
3
[ "Apache-2.0" ]
permissive
// Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. //! Channelz provides channel level debug information. In short, There are four types of //! top level entities: channel, subchannel, socket and server. All entities are //! identified by an positive unique integer, which is allocated in order. For mor...
true
3c06f7f615bf5163435d54812a7bf2b3e5382019
Rust
JohnWall2016/xlsx-rs
/old/src/file.rs
UTF-8
5,157
2.6875
3
[]
no_license
//extern crate zip; use std::fs; use std::io::{Read, Seek}; use std::collections::BTreeMap as Map; use xml; use refer; use xlsx; use result::{XlsxResult, Error}; use zip; #[derive(Debug)] pub struct File { rels: Map<String, String>, strs: refer::Strings, clrs: refer::Colors, nfts: refer::NumFmts, ...
true
3bf42877749bbbbecf4c1820bf33cb8d3fd62b6a
Rust
marco-c/gecko-dev-wordified
/third_party/rust/wast/src/component/types.rs
UTF-8
28,470
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "Apache-2.0" ]
permissive
use crate : : component : : * ; use crate : : core ; use crate : : kw ; use crate : : parser : : Lookahead1 ; use crate : : parser : : Peek ; use crate : : parser : : { Parse Parser Result } ; use crate : : token : : Index ; use crate : : token : : LParen ; use crate : : token : : { Id NameAnnotation Span } ; / / / A c...
true
b75a709706623bc793acd1c7fa1e6c292fd41089
Rust
lubosmudrak/piston_window
/src/self_time.rs
UTF-8
1,149
2.671875
3
[ "MIT" ]
permissive
// selfishly copied from: https://github.com/ZainlessBrombie/glutin_window/blob/master/src/self_time.rs //temporary solution until glutin_window gets stable use std::any::Any; use std::marker::PhantomData; use std::ops::{Deref, DerefMut}; pub struct SelfTime<'a> { alive: LinkList<'a>, } impl<'a> Default for Self...
true
75c9411e739f044c0978e605bc98202087bdde31
Rust
qatix/RustBase
/src/mybase.rs
UTF-8
306
3.078125
3
[]
no_license
pub fn base_test(){ let a = 123; println!("a = {}", a); let x = 5; let x = x * 2; println!("The value of x is:{}", x); let mut y = 456; println!("first y= {}", y); y = 678; println!("second y = {}", y); let s = "1234"; println!("x = {} len:{}", s, s.len()); }
true
36a9ad746bafe410616aa2767b7e784a58f409a6
Rust
justinpettit/differential-datalog
/rust/template/differential_datalog/record.rs
UTF-8
25,651
3.40625
3
[ "MIT" ]
permissive
//! An untyped representation of DDlog values and database update commands. use num::{ToPrimitive, BigInt, BigUint}; use std::vec; use std::collections::{BTreeMap, BTreeSet}; use std::iter::FromIterator; use std::borrow::Cow; #[cfg(test)] use std::borrow; #[cfg(test)] use num::bigint::{ToBigInt, ToBigUint}; pub type...
true
f162b9f2c29d28338ad652e45b499582a52986f7
Rust
lemonrock/magic-ring-buffer
/src/Size.rs
UTF-8
1,953
2.75
3
[ "MIT" ]
permissive
// This file is part of linux-support. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/linux-support/master/COPYRIGHT. No part of linux-support, including this file, may be copied, modified, propagated, or ...
true
acf574675ccfacd16792067b645f400f7d6cb1f6
Rust
Dentosal/rust_os
/src/memory/allocators/stack_allocator.rs
UTF-8
1,715
2.78125
3
[ "MIT" ]
permissive
use core::alloc::Layout; use x86_64::structures::paging as pg; use x86_64::structures::paging::page_table::PageTableFlags as Flags; use crate::memory::{paging::PAGE_MAP, phys, prelude::*, virt}; #[derive(Debug)] pub struct Stack { pub top: VirtAddr, pub bottom: VirtAddr, } impl Stack { fn new(top: VirtAd...
true
835f83bc20d561b36e205649c2c6b1a8ba997f6b
Rust
cundd/rest-adapter-rust
/rest_adapter/src/uri_builder.rs
UTF-8
1,445
2.75
3
[]
no_license
use crate::Url; use crate::prelude_internal::*; use crate::http_client::HttpClientTrait; pub struct UriBuilder { base_uri: Url, } impl UriBuilder { pub fn new<C: HttpClientTrait + Clone>(config: &AdapterConfiguration<C>) -> Self { Self { base_uri: config.base_uri().clone() } } pub fn build_ur...
true
2a0a249c9f1640984c661f956da4219e0c9dd5a6
Rust
skillzaa/util
/tests/counter01.rs
UTF-8
3,150
2.890625
3
[]
no_license
use bilzaa2dutil::AttributesEnum; use bilzaa2dutil::BaseCounter as Animation; use bilzaa2dutil::Animatable; use bilzaa2dutil::AnimateResponses; //use #[should_panic] with the test --if to check errors fn test_a(a:Animation,time_ms:u128,answer:AnimateResponses){ match a.animate(time_ms) { Some(x)=> assert_...
true
8532b811a23ec7f7d4c8696ce8be755de6b0bb7a
Rust
dchammond/aoc2020
/prob_01/src/main.rs
UTF-8
1,020
3.140625
3
[]
no_license
use std::env; use std::path::*; use std::ffi::OsStr; use std::fs; fn main() { let file_path = PathBuf::from(env::args().last().unwrap()); let data = fs::read_to_string(file_path).unwrap(); let mut lines = data.lines(); let mut nums: Vec<u32> = lines.map(|l| l.parse::<u32>().unwrap()).collect(); num...
true
2e6777a72694345326d6a5e90106383f9d8219bb
Rust
theptrk/rust-by-example
/src/example.rs
UTF-8
1,178
2.96875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use file::read; use markdown::Markdown; use serialize::{Decodable,json}; #[deriving(Decodable)] pub struct Example { id: String, title: String, } impl Example { pub fn get_list() -> Vec<Example> { match read(&Path::new("examples/order.json")) { Err(why) => fail!("{}", why), ...
true
8b7919f25da783dde993052d2583c5c65ee47d89
Rust
zhyu/vim-clap
/crates/stdio_server/src/env.rs
UTF-8
1,230
2.640625
3
[ "MIT" ]
permissive
use super::types::{GlobalEnv, Message}; use log::debug; use once_cell::sync::OnceCell; use std::ops::Deref; static GLOBAL_ENV: OnceCell<GlobalEnv> = OnceCell::new(); /// Ensure GLOBAL_ENV has been instalized before using it. pub fn global() -> impl Deref<Target = GlobalEnv> { if let Some(x) = GLOBAL_ENV.get() { ...
true
2b561ebb9dd844c986a45d139804bd0a8ad000b8
Rust
KilianVounckx/truster
/src/shape/sphere.rs
UTF-8
6,349
3.59375
4
[]
no_license
//! Holds the [Sphere] struct; use std::rc::Rc; use crate::intersection::Intersection; use crate::material::Material; use crate::matrix::Matrix; use crate::ray::Ray; use crate::tuple::Tuple; use super::Shape; /// A 3D ellipsoid (spheroid). #[derive(Default, Clone)] pub struct Sphere { transform: Matrix, tra...
true
76149cf32669938e43cea593f9af98ffca1c3314
Rust
sigmaris/Toshi
/toshi-client/src/hyper_client.rs
UTF-8
3,552
2.671875
3
[ "MIT" ]
permissive
use std::fmt::Display; use bytes::Buf; use http::Response; use hyper::client::connect::Connect; use hyper::{Body, Client, Request, Uri}; use serde::{de::DeserializeOwned, Serialize}; use tantivy::schema::Schema; use async_trait::async_trait; use toshi_types::*; use crate::Result; #[derive(Debug, Clone)] pub struct ...
true
9e65c6b132ba37d9c25faf41955dd47581de771a
Rust
jeffomatic/nes
/src/cpu/execute/arithmetic.rs
UTF-8
9,805
3.078125
3
[]
no_license
use crate::cpu::operand::Operand; use crate::cpu::state::Cpu; use crate::cpu::status::Status; use crate::math; pub fn adc(cpu: &mut Cpu, operand: Operand) { let prev = cpu.regs.a; let opval = operand.read(cpu); let res16 = prev as u16 + opval as u16 + if cpu.regs.status_check(Status::Carry)...
true
565d8f6f97084d5f1a066ce8b25e4c20df89428a
Rust
clauswilke/sinab
/src/sinab/src/markdown.rs
UTF-8
855
2.5625
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate pulldown_cmark; use super::utils::c_helper::*; use pulldown_cmark::{html, Options, Parser}; /// External C interface to `md_to_html()`. #[no_mangle] pub extern "C" fn sinab_md_to_html(text: *const c_char) -> *mut c_char { let html_output = match cstring_to_str(text) { Ok(s) => md_to_html(s), ...
true
45a02a029b56ea6ba1ca3c2b15c2cf5e3a805ddc
Rust
ChangeCaps/robots-or-smth
/src/size.rs
UTF-8
2,724
2.59375
3
[]
no_license
use crate::*; use bevy::prelude::*; pub fn unit_collision_system( units: Res<Assets<Unit>>, entities: Query<Entity, (With<Position>, With<Handle<Unit>>)>, mut query: Query<(&mut Position, &Behaviour, &Handle<Unit>)>, ) { for a_entity in entities.iter() { let (a_position, a_priority, a_unit) = {...
true
b9b064659aaf02461b87d2eb07388d72c8eb25eb
Rust
jzarnett/ece459
/lectures/live-coding/L28/alloc/src/main.rs
UTF-8
300
2.765625
3
[]
no_license
fn g() { let a = Vec::<u32>::with_capacity(4000); std::mem::forget(a) } fn f() { let a = Vec::<u32>::with_capacity(2000); std::mem::forget(a); g() } fn main() { let mut a = Vec::with_capacity(10); for _i in 0..10 { a.push(Box::new([0;1000])) } f(); g(); }
true
bc6beeebcf3bc6fb796885034c65edc8878843d0
Rust
AprliRainkun/copra
/copra/src/protocol/mod.rs
UTF-8
7,471
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
//! Message protocols use bytes::{Bytes, BytesMut}; use smallvec::SmallVec; use std::fmt; use std::io; use tokio_io::codec::{Decoder, Encoder}; use tokio_proto::multiplex::RequestId; use controller::Controller; use message::{RpcMeta, RpcRequestMeta, RpcResponseMeta}; use message::{RequestPackage, ResponsePackage}; p...
true
a8f585f1dcfe1886dd606637b9b360d9ff59699f
Rust
sdraeger/rust-knuth-morris-pratt
/src/main.rs
UTF-8
1,270
3.40625
3
[]
no_license
fn next_arr(pat: &String) -> Vec::<i32> { let m = pat.len() as i32; let mut narr = vec![0; m as usize]; let mut i: i32 = 0; let mut j: i32 = -1; narr[0] = -1; while i < m - 1 { if j == -1 || pat.chars().nth(i as usize).unwrap() == pat.chars().nth(j as usize).unwrap() { i += 1; j += 1; if pa...
true
0deada02652b4893c7d8916a60b581b7c0c38585
Rust
i-e-b/RustExperiments
/multiprocessing/simple_thread.rs
UTF-8
466
3.890625
4
[]
no_license
//! A very simple example of spawning and ending threads use std::thread; fn spawn_func() { println!("Hello threads"); } fn main() { // here's a plain function being split into a thread let child = thread::spawn(spawn_func); // here's a closure being spawned let cchild = thread::s...
true
3f0081145989eda415f1bf27aa0d3b6e11c64fe3
Rust
hegza/vcn-inference-rs
/src/math/gemm/gemm_10/params.rs
UTF-8
5,282
2.578125
3
[]
no_license
use crate::cl_util; use crate::flags::DeviceType; use crate::layers::Coeff; use ocl; use ocl::{flags, Buffer, Context, Device, Kernel, OclPrm, Platform, Program, Queue, SpatialDims}; use std::cmp::min; use std::mem::size_of; #[derive(Copy, Clone)] pub struct Gemm10CompileParameters { // The vector-width (in number...
true
97f35e34d1a8c5afaf80fd83b67172cc4536d2b9
Rust
bazaah/raffle-rest
/src/routes.rs
UTF-8
8,195
2.84375
3
[ "MIT" ]
permissive
use { crate::models::Raffle, rocket::{ http::{ContentType, Status}, request::Request, response::{self, Responder, Response as rResponse}, Rocket, State, }, serde_json::{json, value::Value as jVal}, std::{io::Cursor, sync::RwLock}, }; pub fn rocket() -> Rocket { /...
true
d4fe33df1712d2adc97c9d863a01e2de82000cc6
Rust
sria91-rlox/lox-vm-1
/src/vm.rs
UTF-8
3,454
3.484375
3
[]
no_license
use crate::chunk::{Chunk, OpCode}; use crate::value::{print_value, Value}; use std::fmt; const STACK_MAX: usize = 256; #[derive(Debug)] pub enum InterpretError { CompileError, RuntimeError, } struct OperandStack { stack: [Value; STACK_MAX], stack_top: usize, } impl OperandStack { pub fn new() ->...
true
99e56b1edd479ee2b09f6e9ea63cebff279c043f
Rust
erichulburd/compilerbook-interpreter-rust
/src/object/bool.rs
UTF-8
653
3.484375
3
[]
no_license
use super::{object_trait::ObjectTrait, truthiness_trait::Truthiness}; #[derive(Clone, Copy, Debug, Eq)] pub struct Bool { pub value: bool, } impl ObjectTrait for Bool { fn string(&self) -> String { format!("{}", self.value) } } impl Truthiness for Bool { fn is_truthy(&self) -> bool { ...
true
974d3928a7ec08870b204d6bb8326099bd65200d
Rust
chom-parser/ir
/src/pretty_print/function.rs
UTF-8
1,980
2.71875
3
[]
no_license
use std::fmt; use crate::{ Namespace, Function, function }; use super::{ PrettyPrint, PrettyPrinter }; impl<T: Namespace> PrettyPrint<T> for Function<T> { fn fmt(&self, ppf: &mut PrettyPrinter<T>) -> fmt::Result { match self.owner() { function::Owner::Type(ty_ref) => { ppf.write("method ")?; if...
true
04f7733911776e0838605ec1d4a8dac1004d0d1a
Rust
SirCipher/tungstenite-rs
/src/server.rs
UTF-8
2,898
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
//! Methods to accept an incoming WebSocket connection on a server. pub use crate::handshake::server::ServerHandshake; use crate::handshake::server::{Callback, NoCallback}; use crate::handshake::HandshakeError; use crate::protocol::{WebSocket, WebSocketConfig}; use crate::extensions::uncompressed::UncompressedExt; ...
true
b19bead662c67d44837cdc8c8a4a6620e95025f1
Rust
kulinsky/leetcode-problems
/array/best-time-to-buy-and-sell-stock-II/main.rs
UTF-8
1,995
3.515625
4
[]
no_license
// https://leetcode.com/explore/interview/card/top-interview-questions-easy/92/array/564/ // You are given an array prices where prices[i] is the price of a given stock on the ith day. // Find the maximum profit you can achieve. You may complete as many transactions as you like (i.e., buy one and sell one share of the...
true
459e5ed6c808f8628a75a982c78a7968372c465c
Rust
carols10cents/sxd-xpath
/src/node_test.rs
UTF-8
1,959
2.515625
3
[]
no_license
use super::XPathEvaluationContext; use super::nodeset::Nodeset; use super::nodeset::Node::{AttributeNode,ElementNode,TextNode}; pub trait XPathNodeTest { fn test<'a, 'd>(&self, context: &XPathEvaluationContext<'a, 'd>, result: &mut Nodeset<'d>); } pub type SubNodeTest = Box<XPathNodeTest + 'static>; pub struct N...
true
ea43f49b59fbbe3756f7ff52226452bd4588d9b8
Rust
guillaume-be/rust-bert
/tests/bert.rs
UTF-8
16,773
2.578125
3
[ "Apache-2.0" ]
permissive
extern crate anyhow; extern crate dirs; use rust_bert::bert::{ BertConfig, BertConfigResources, BertForMaskedLM, BertForMultipleChoice, BertForQuestionAnswering, BertForSequenceClassification, BertForTokenClassification, BertModelResources, BertVocabResources, }; use rust_bert::pipelines::common::{ModelRes...
true
0726a31dc6bd4b4fbb1a24696e86576cdc4540c5
Rust
weijiuqiao/algorithm_exercise
/src/balanced_search_tree.rs
UTF-8
4,780
3.34375
3
[ "MIT" ]
permissive
use std::cell::RefCell; use std::rc::Rc; static RED: bool = true; static BLACK: bool = false; struct Node<K: PartialOrd + Copy, V: Clone> { key: K, value: V, left: Rc<RefCell<Option<Node<K,V>>>>, right: Rc<RefCell<Option<Node<K,V>>>>, n: usize, color: bool, } pub struct BalancedSearchTree<K: P...
true
160e8fc54ee690e604a41cb296e63e2670462135
Rust
FreddyWordingham/dia
/src/sci/phys/opt/crossing.rs
UTF-8
2,591
3.171875
3
[]
no_license
//! Crossing implementation. use crate::{access, clone, Dir3}; /// Crossing structure implementation. /// Optical interface Crossing information structure. pub struct Crossing { /// Probability of reflection. ref_prob: f64, /// Reflection direction. ref_dir: Dir3, /// Transmission (refraction) dir...
true
b4d0836b7c21c6b47617b3d952248ec121fa60b3
Rust
vietvudanh/really-large-file
/src/rust/v2/src/lib.rs
UTF-8
5,232
3.046875
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; use std::sync::{Arc, Mutex}; use std::thread; use std::time::SystemTime; // constants const BATCH_SIZE: usize = 512 * 1024; // process in each thread pub struct Config { filename: String } struct Entry { index: i64, firs...
true
71bb45c98f4324254c3dddbda31d22cd77db26ab
Rust
rphmeier/serde_derive_issues
/src/main.rs
UTF-8
555
2.546875
3
[]
no_license
#[macro_use] extern crate test_macro as the_macro; #[macro_use] extern crate serde_derive; // Issue one: not referring to the type alias through the correct path. trait Trait { } decl_issue_one! { #[derive(Deserialize)] pub enum TheEnum<T: Trait>; } // Issue two: not referring to the trait through the corr...
true
4b2cedd59f9c20ff0facc2f1c9e3ab60897e47f5
Rust
philipdexter/milk
/src/where.rs
UTF-8
672
2.578125
3
[ "MIT" ]
permissive
use colored::*; use exitfailure::ExitFailure; use failure::ResultExt; use git2::Repository; use structopt::StructOpt; #[derive(StructOpt)] struct Cli { #[structopt(long = "repo", short = "p", default_value = ".")] repo_path: std::path::PathBuf, } fn main() -> Result<(), ExitFailure> { let args = Cli::from_args(...
true
7c595adba345a2ce8c748331afbe0f409c09ffb7
Rust
ByteHeathen/libsip
/src/client/messaging.rs
UTF-8
4,877
3.015625
3
[ "MIT" ]
permissive
use std::io::{Error as IoError, ErrorKind as IoErrorKind, Result as IoResult}; use crate::*; macro_rules! impl_simple_header_method { ($name:ident, $variant:ident, $ty:ident) => { /// Retrieve value of the $variant header. pub fn $name(&self) -> IoResult<$ty> { if let Some(Header::$var...
true
b42ada1110531e10e4afb6aafc34029c636ef45f
Rust
stuvusIT/entman
/src/identity/json.rs
UTF-8
1,983
2.828125
3
[ "MIT" ]
permissive
use std::error::Error; use std::fs::OpenOptions; use std::io::{BufRead, BufReader}; use crate::identity::{AccessResponse, IdentityStore, Outcome}; use serde_derive::Deserialize; #[derive(Deserialize)] pub struct JsonIdentitySettings { pub filename: String, } #[derive(Deserialize)] struct User { username: Str...
true
cc781b63e4c3832e31e8ed12501b290eb7f9f416
Rust
FreeMasen/meh
/src/poll.rs
UTF-8
702
2.71875
3
[ "MIT" ]
permissive
use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Poll { /// All the current answers pub answers: Vec<Answer>, /// Unique id for this poll pub id: String, /// When did this poll start? pub star...
true
2f759e7ddfd42ca94c6ff3b80f934e03e549ffaf
Rust
PoiScript/sqlx
/tests/postgres-derives.rs
UTF-8
2,129
3.3125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use sqlx::Postgres; use sqlx_test::test_type; use std::fmt::Debug; // Transparent types are rust-side wrappers over DB types #[derive(PartialEq, Debug, sqlx::Type)] #[sqlx(transparent)] struct Transparent(i32); // "Weak" enums map to an integer type indicated by #[repr] #[derive(PartialEq, Copy, Clone, Debug, sqlx::T...
true
d77de2486bc8c16fc62650cbbbf45f58796c2c90
Rust
prestontw/advent-2017
/src/day4.rs
UTF-8
1,660
3.34375
3
[]
no_license
use std::collections::HashSet; fn str_to_passphrase(i: &str) -> Vec<&str> { i.split_whitespace().collect() } pub fn str_to_passphrases(i: &str) -> Vec<Vec<&str>> { i.lines().map(|l| str_to_passphrase(l)).collect() } fn to_hashset<'a, I, S>(i: I) -> HashSet<S> where I: IntoIterator<Item = S>, S: Into<...
true
d93df6959f95f7d23556bf54a6c1056c6b827eb1
Rust
apparentorder/aoc
/2017/src/day03.rs
UTF-8
3,489
3.265625
3
[]
no_license
use crate::aoc; use std::collections::HashMap; fn solve(input: String) -> String { let mut layer = 0; let mut sidelen = -1; let mut bottom_right = 1; let wanted: i32 = input.parse().unwrap(); while bottom_right < wanted { layer += 1; sidelen = 1 + layer*2; bottom_right += sidelen * 4 - 4; } println!("w...
true
5785a8466ce3b7cdd151217dd64b9ea10b81f7ed
Rust
INOVA-Technology/ZSD
/src/game.rs
UTF-8
2,399
3.15625
3
[]
no_license
use std::process::exit; use crate::{println_combat, println_warn, println_levelup}; use crate::combo::Combo; use crate::player::Player; use crate::zombie::{Zombie, ZombieType}; const ZOMBIES_PER_WAVE: u64 = 3; pub struct Game<I> { player: Player, current_zombie: Zombie, waves: I, current_wave: Zombie...
true
a188ca5017b29d41cc81971da71ae35936aff96c
Rust
hooops/crypto-crawler-rs
/crypto-pair/tests/bitmex.rs
UTF-8
1,555
2.921875
3
[ "Apache-2.0" ]
permissive
mod utils; use crypto_pair::{normalize_currency, normalize_pair}; use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collections::HashMap; use utils::http_get; const EXCHANGE_NAME: &'static str = "bitmex"; #[derive(Clone, Serialize, Deserialize)] #[allow(non_snake_case)] struct Instrument { sym...
true
0a3ab80d7c50bd13739e453d749970515e5743b7
Rust
euclio/msgpack-rust
/rmp-serde-tests/tests/derive/se.in.rs
UTF-8
3,647
3.359375
3
[]
no_license
use serde::Serialize; use rmp_serde::Serializer; #[test] fn pass_struct() { let mut buf = Vec::new(); #[derive(Serialize)] struct Struct { f1: u32, f2: u32, } let val = Struct { f1: 42, f2: 100500, }; val.serialize(&mut Serializer::new(&mut buf)).ok().unwra...
true
c9d3d50a0fc559884ce5ba303385d2bcac4caadf
Rust
xiangjt/MyPlayer
/third_party/rust/serde/src/ser/content.rs
UTF-8
19,912
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use core::marker::PhantomData; #[cfg(all(not(feature = "std"), feature = "collections"))] use collections::{String, Vec}; #[cfg(all(feature = "alloc", not(feature = "std")))] use alloc::boxed::Box; #[cfg(feature = "collections")] use collections::borrow::ToOwned; use ser::{self, Serialize, Serializer}; pub struct ...
true
704c64ad0d2a4665786d2baedc17d9329434601e
Rust
ismasgrove/raytracing
/src/plane.rs
UTF-8
1,235
2.953125
3
[]
no_license
use super::{Arc, HitRecord, Hittable, Material, Ray, Vec3, AABB}; pub struct Plane { point: Vec3, // this point represents the distance from the origin normal: Vec3, material: Arc<dyn Material>, } impl Plane { pub fn new(point: Vec3, normal: Vec3, material: Arc<dyn Material>) -> Self { Plane {...
true
7176e4cace7f0044d42642443edc3540e00fd651
Rust
ryo97321/rust-workspace
/atcoder/kyotoUnivProgrammingContest2019/main_b.rs
UTF-8
1,989
3.09375
3
[]
no_license
fn getline() -> String { let mut __ret = String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main() { let line = getline(); let params: Vec<_> = line.trim().split(' ').collect(); let n_item: usize = params[0].parse().unwrap(); let n_terms: usize = params[1].parse(...
true
34a9fa3bb2032b91e03b1da566d724aab693afca
Rust
slelaron/rtiow
/src/vec3.rs
UTF-8
4,320
3.4375
3
[]
no_license
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; #[derive(Clone, Copy, PartialEq, Debug)] pub struct Vec3 { x: f32, y: f32, z: f32, } impl Vec3 { pub fn new(x: f32, y: f32, z: f32) -> Vec3 { Vec3 { x, y, z } } pub fn x(&self) -> f32 { self.x...
true
6bc10cd3bbd71232e5af01efe55b25ce7cf95a84
Rust
Hakuyume/menoh-rs
/menoh/examples/vgg16.rs
UTF-8
3,158
2.609375
3
[ "MIT" ]
permissive
extern crate docopt; extern crate image; extern crate menoh; #[macro_use] extern crate serde_derive; use image::GenericImage; use std::cmp; use std::error; use std::fs; use std::io; use std::io::BufRead; use std::path; const USAGE: &'static str = r#" VGG16 example Usage: vgg16 [options] Options: -i --image PATH ...
true
36237ccb9b6bbb2ca3ec2f27a8b1083a9c1a5c82
Rust
staccnft/metaplex
/rust/auction/program/src/errors.rs
UTF-8
4,453
2.953125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown" ]
permissive
use { num_derive::FromPrimitive, solana_program::{ decode_error::DecodeError, msg, program_error::{PrintProgramError, ProgramError}, }, thiserror::Error, }; /// Errors that may be returned by the Auction program. #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] pub e...
true
5d5fd8da25401224a93ce19c3507d18f12ae0434
Rust
sisshiki1969/ruruby
/ruruby/src/builtin/math.rs
UTF-8
1,793
3.125
3
[ "MIT" ]
permissive
use crate::*; pub(crate) fn init(globals: &mut Globals) -> Value { let mut class = Module::class_under_object(); globals.set_toplevel_constant("Math", class); class.add_builtin_class_method(globals, "sqrt", sqrt); class.add_builtin_class_method(globals, "cos", cos); class.add_builtin_class_method(g...
true
ba34623963efe8607391221a504e47a1a91f1eed
Rust
tsuchinaga/rust-paiza-mondai
/src/warset/01.rs
UTF-8
209
2.78125
3
[]
no_license
use std::io; fn main() { let mut n = String::new(); io::stdin().read_line(&mut n).unwrap(); let i: i32 = n.trim().parse().unwrap(); if i >= 80 { println!("pass") } else { println!("fail") } }
true
73142eb58095eceed072cc008f2daeded0342dcd
Rust
gakitoru/rust-learning
/hello/src/main.rs
UTF-8
1,910
3.8125
4
[]
no_license
#[derive(Debug)] struct Person { name: String, age: u32, } #[derive(Debug)] enum Event { Quit, KeyDown(u8), MouseDown {x: i32, y: i32} } fn func(code: i32) -> Result<i32, String> { println!("code: {}", code); Ok(100) } fn error_handling(result: Result<i32, String>) -> Result<i32, String> ...
true
434a7fa7d8f3e21d05a5fa02e38e3ee9072ad47d
Rust
bytesnake/linfa
/linfa-trees/benches/decision_tree.rs
UTF-8
1,930
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; use linfa::prelude::*; use linfa_trees::DecisionTree; use ndarray::{stack, Array, Array2, Axis}; use ndarray_rand::rand::SeedableRng; use ndarray_rand::rand_distr::{StandardNormal, Uniform}; use ndarray_rand::RandomExt; use rand_isaac::Isaac64Rng...
true
3b5c4417295f59c8f56163d9ade0f93be43984b6
Rust
RustCrypto/block-ciphers
/belt-block/src/cipher_impl.rs
UTF-8
3,346
2.90625
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use crate::{belt_block_raw, from_u32, g13, g21, g5, key_idx, to_u32}; use cipher::consts::{U16, U32}; use cipher::{inout::InOut, AlgorithmName, Block, BlockCipher, Key, KeyInit, KeySizeUser}; use core::{fmt, mem::swap, num::Wrapping}; #[cfg(feature = "zeroize")] use cipher::zeroize::{Zeroize, ZeroizeOnDrop}; /// BelT...
true
7649607e3f6fc90eb767a70204cfb4a5f6c1dfaa
Rust
AlecGoncharow/m2m_diesel_test
/src/models.rs
UTF-8
1,066
2.65625
3
[]
no_license
use crate::schema::*; #[derive(Queryable, Debug)] pub struct Item { pub id: i32, pub instance_of: i32, pub title: String, } #[derive(Insertable, Debug)] #[table_name = "items"] pub struct NewItem<'a> { pub instance_of: i32, pub title: &'a str, } #[derive(Queryable, Insertable, Debug)] pub struct ...
true
611245d95e7018864a57f3bf4fc5f9908a450288
Rust
10allday-kai/api-daemon
/third-party/x509-signature/src/spki.rs
UTF-8
8,480
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
//! PKIX SubjectPublicKeyInfo parsing use super::{ der::{self, Tag}, Error, SignatureScheme, }; use ring::signature; /// Restrictions on allowed signature algorithms #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Restrictions { /// Allow all supported signature algorithms. T...
true
f72c38dd30e3cdfa8464ff44de3494823f5fae72
Rust
gnzlbg/typed_arch
/src/sealed.rs
UTF-8
2,320
2.546875
3
[]
no_license
//! Sealed traits use arch::__m64; use mem::transmute; use simd::*; macro_rules! impl_all { ($macro:ident: $($id:ident),*) => { $( $macro!($id); )* } } /// Any 64-bit wide vector type pub trait Any64 { fn as_m64(self) -> __m64; fn from_m64(x: __m64) -> Self; } macro_rules...
true
dcd46b9f110954b86cb836a7f4e6832a2dc617e8
Rust
Leopard2A5/lib-battleship
/src/results.rs
UTF-8
1,007
3.21875
3
[]
no_license
//! Result types for all operations that can fail. /// General errors when creating a game. #[derive(Copy, Clone, PartialEq, Debug)] pub enum GameError { IllegalDimensions, } /// Errors concerning ship types. #[derive(Copy, Clone, PartialEq, Debug)] pub enum ShipTypeError { IllegalShipLength, ShipTooLongF...
true
0696818a33f53c00d2e8536077ce59133801040e
Rust
sinasalek/clipboard_guardian
/src/clipboard_holder.rs
UTF-8
1,474
3.296875
3
[ "MIT" ]
permissive
use std::thread; use crossbeam::channel::{unbounded, Sender}; use std::sync::{Arc}; pub type ClipboardSenderType = Sender<String>; pub type CallbackType = Arc<dyn Fn(&String) + Send + Sync>; //pub type CallbackType = impl Fn(String); pub struct ClipboardHolder { history: Vec<String>, pub history_sender: Clip...
true
0d6ea64f02c42bae1e1b3fb653a7a3b4f3031bbe
Rust
MuhammedIrfan/runner-rs
/runner/src/runtime/local.rs
UTF-8
2,436
2.59375
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
use portpicker::pick_unused_port; use std::fs; use std::path::{PathBuf}; use std::process::{Child}; use std::{thread, time::Duration}; use super::context; use super::RuntimeFlavor; pub(crate) fn home_dir(port: u16) -> PathBuf { let mut path = std::env::temp_dir(); path.push(format!("sandbox-{}", port)); p...
true
9c3c44f3c6509a6ee34e8b02472f90411ee47d80
Rust
SpirosMakris/thalassa
/src/plugins/main_camera.rs
UTF-8
5,795
2.59375
3
[]
no_license
use bevy::{ prelude::*, render::camera::{Camera, PerspectiveProjection, VisibleEntities}, render::render_graph::base, }; const CAMERA_SPEED: f32 = 1000.0; /// A set of options for MainCamera pub struct MainCameraOptions { /// Speed the camera moves at pub speed: f32, /// Mouse related camera m...
true
9c87260be719bbd6d0f5fdf40a54ea8ebeee370b
Rust
Typas/gw2_boss_time_estimate
/src/lib.rs
UTF-8
3,996
2.828125
3
[ "MIT" ]
permissive
use csv::Reader; use lazy_static::lazy_static; pub struct BossPhase { index: String, health: f64, coeff: f64, power_coeff: f64, num_dps: f64, } struct Dps(f64, f64); struct PersonalDps { dps: Vec<Dps>, } struct SquadDps(PersonalDps); fn get_dps(dps_type: &str) -> PersonalDps { let prefi...
true
ff83fa5394f7bf76799737d6fb58426c78e7ddca
Rust
HarrisonMc555/exercism
/rust/affine-cipher/src/lib.rs
UTF-8
3,236
3.421875
3
[]
no_license
use itertools::Itertools; /// While the problem description indicates a return status of 1 should be returned on errors, /// it is much more common to return a `Result`, so we provide an error type for the result here. #[derive(Debug, Eq, PartialEq)] pub enum AffineCipherError { NotCoprime(i32), } const FIRST_LET...
true
38f374b6ac35e6d6805d66237417accf22837096
Rust
tosteiner/thoth
/thoth-app/src/models/funding/delete_funding_mutation.rs
UTF-8
1,005
2.5625
3
[ "Apache-2.0" ]
permissive
use serde::Deserialize; use serde::Serialize; const DELETE_FUNDING_MUTATION: &str = " mutation DeleteFunding( $fundingId: Uuid! ) { deleteFunding( fundingId: $fundingId ){ fundingId } } "; graphql_query_builder! { DeleteFundingRequest, Delete...
true
6f2285b0083ca91b1d06751cf9026eaa8be7d511
Rust
joelverhagen/adventofcode
/2017/rust/day13/src/main.rs
UTF-8
3,932
3.1875
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Clone, Debug)] struct FirewallLayer { depth: i32, range: i32, position: i32, forward: bool, } impl FirewallLayer { fn step(&mut self) { if self.range < 2 { return; } self.position += if self.forward...
true
40fe8abba465f14bdc434b8b93d339400dd7b05d
Rust
MichaelByrneAU/Daphnis
/src/vector.rs
UTF-8
11,592
3.59375
4
[ "MIT" ]
permissive
use std::ops; use rand::Rng; #[derive(Copy, Clone, Debug)] pub struct Vector { pub x: f64, pub y: f64, pub z: f64, } // Construction impl Vector { pub fn new(x: f64, y: f64, z: f64) -> Vector { Vector { x, y, z } } } // Computed properties impl Vector { pub fn squared_length(&self) -...
true
944409e0b6e136f750f241bb941742115813a0fe
Rust
vtavernier/glsl-lang
/lang-pp/src/lexer/glue.rs
UTF-8
7,871
3.171875
3
[ "BSD-3-Clause", "Vim" ]
permissive
//! Last stage lexer declaration use arrayvec::ArrayVec; use crate::{ lexer::{PreLexer, PreTextToken, PreToken as InputToken}, util::LineMap, }; mod token; use lang_util::TextRange; pub use token::Token; pub type TextToken = crate::util::TextToken<token::Token>; /// Final stage lexer. /// /// This lexer wr...
true
77f52650a4990bd4c8357951dd794c314e9c4617
Rust
IThawk/rust-project
/rust-master/src/test/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs
UTF-8
355
3.03125
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
fn test() { let b = Box::new(1); //~ NOTE first assignment //~| HELP make this binding mutable //~| SUGGESTION mut b drop(b); b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immut...
true
5d8be8c0fe5ec1c0832bcba4d5812401800f3895
Rust
albertofem/euler-rust
/problems/euler-problem-6/src/main.rs
UTF-8
231
3.40625
3
[]
no_license
fn main() { let sum = sum(100); let sum_squares = sum_squares(100); println!("Difference: {}", sum*sum - sum_squares); } fn sum(n: i32) -> i32 { (n * (n + 1) / 2) } fn sum_squares(n: i32) -> i32 { ((n * (n+1)*(2*n+1))/6) }
true
db2aca236f9f53f1fcd619de2785f225ffb966ce
Rust
BitSavage0202/spacesuit
/src/error.rs
UTF-8
1,099
2.84375
3
[]
no_license
use bulletproofs::r1cs::R1CSError; /// Represents an error during the proof creation of verification for a KShuffle or KValueShuffle gadget. #[derive(Fail, Copy, Clone, Debug, Eq, PartialEq)] pub enum SpacesuitError { /// Error in the constraint system creation process #[fail(display = "Invalid KShuffle constr...
true
a6a3bb204754ffb3b1fbbe630cc2c527ddd90b8f
Rust
Agrajag-Petunia/linalg
/src/linalg/quaternion.rs
UTF-8
4,127
3.359375
3
[]
no_license
use std::num::{Primitive, cast}; use euler::Euler; use vector3d::Vector3D; mod constants; pub struct Quaternion<T> { x: T, y: T, z: T, w: T } impl<T: Primitive> Quaternion<T> { pub fn new(x: T, y: T, z: T, w: T) -> Quaternion<T> { Quaternion{ x: x, y: y, z: z, w: w} } pub...
true
f1987b35868979f75924a9c2e15dc9b67135a50b
Rust
Rapunzel77/rust-doko-server
/core/src/regelsatz.rs
UTF-8
5,176
3.140625
3
[ "Apache-2.0" ]
permissive
use crate::karte::*; use crate::karte::Farbe::*; use crate::karte::Hoehe::*; use std::collections::HashMap; use std::sync::Arc; use std::rc::Rc; use std::fmt::Debug; #[derive(Copy,Clone,Debug)] pub enum SoloArt { Trumpf, FarbsoloKreuz, FarbsoloPik, FarbsoloHerz, FarbsoloKaro, } #[derive(Copy,Clone...
true
54468f883c15640a803d0b98214e6f492c796b69
Rust
wickerwaka/aoc2018
/aoc04/src/main.rs
UTF-8
3,378
3.109375
3
[]
no_license
use std::collections::HashMap; use std::io::{self, Read}; extern crate regex; use regex::Regex; extern crate chrono; use chrono::{NaiveDateTime, Timelike}; #[derive(Debug)] enum EventInfo { WakeUp, FallAsleep, OnDuty(i32), } #[derive(Debug)] struct Event { dt: NaiveDateTime, event: EventInfo, } ...
true
ae1551a196b4ee1db6939050d6686dd91169cdce
Rust
lucifer1004/cp-rust
/src/main.rs
UTF-8
5,823
2.8125
3
[]
no_license
use std::fs::{copy as fcopy, File}; use std::io::{copy, Error}; use std::path::Path; use std::process::{Command, Stdio}; use clap::Clap; use dotenv::dotenv; use git2::{Config, ObjectType, Repository, Signature}; mod codeforces; mod webdriver; /// Handy commands for competitive programming in rust. #[derive(Clap)] #[...
true
3bdb4d45c1283f06c31d363ccedd96fd9aa39f5b
Rust
patrickcsullivan/simulation
/simulation/src/system.rs
UTF-8
971
3
3
[]
no_license
///! ECS systems for the simulation. use crate::component::{Position, Velocity}; use crate::resource::ElapsedFramesCount; use specs::{Read, ReadStorage, System, WriteStorage}; pub struct SayHello; impl<'a> System<'a> for SayHello { type SystemData = ReadStorage<'a, Position>; fn run(&mut self, position: Self...
true
b0ef1e6520d9a1972766162b704db6e22a40a533
Rust
niamster/unbytify
/src/lib.rs
UTF-8
7,187
3.296875
3
[ "Apache-2.0" ]
permissive
// Copyright 2017 Dmytro Milinevskyi <dmilinevskyi@gmail.com> // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicabl...
true
2793314b9cc0ac2624822fa20d9b1ab1dd43228d
Rust
iCodeIN/ffi-convert-rs
/ffi-convert/src/lib.rs
UTF-8
7,636
3.734375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A collection of utilities (traits, data structures, conversion functions, etc ...) to ease conversion between Rust and C-compatible data structures. //! //! Through two **conversion traits**, [`CReprOf`] and [`AsRust`], this crate provides a framework to convert idiomatic Rust structs to C-compatible structs that c...
true
31d03a1d3152b1c8dcf8d3919900e70da3a964b4
Rust
blazewicz/redox
/kernel/drivers/ps2.rs
UTF-8
7,296
2.84375
3
[ "MIT" ]
permissive
use alloc::boxed::Box; use common::event::{KeyEvent, MouseEvent}; use drivers::pio::*; use schemes::KScheme; /// PS2 pub struct Ps2 { /// The data data: Pio8, /// The command cmd: Pio8, /// Left shift? lshift: bool, /// Right shift? rshift: bool, /// Caps lock? caps_lock: boo...
true
b41fa8ca5add375bab72194ac01ec92029d6296f
Rust
echorohit/derust
/src/main.rs
UTF-8
864
3.578125
4
[]
no_license
fn main() { println!("Hello, world!"); convert_fto_c(70); let nth = nth_fibonaci_number(9); println!("8th fibonaci value is {}", nth); } /** * @description: Convert temperatures between Fahrenheit and Celsius. * @author echorohit */ fn convert_fto_c(far: u32) -> f64 { println!("Your FAHRENHEIT t...
true
8d37ad4c758f4d18c6c4f4ff313960e30eab1625
Rust
veryafe/advent-of-rust-2020
/src/day08.rs
UTF-8
1,471
3.234375
3
[]
no_license
pub fn get_instructions() -> Vec<(String, isize, bool)> { let input_raw = include_str!("input08.txt"); input_raw.lines() .map(|s| (s[0..3].to_string(), s[4..].parse().unwrap(), false)) .collect() } pub fn part1() { let mut lines = get_instructions(); let mut acc:isize = 0; let mut i...
true
f16afa47ec3f10d20aca503a1102769a4c617a64
Rust
Bergmann89/asparit
/src/iter/unzip.rs
UTF-8
5,675
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ core::Driver, Consumer, Executor, Folder, ParallelExtend, ParallelIterator, Reducer, Setup, WithSetup, }; /* Unzip */ pub struct Unzip<X> { iterator: X, } impl<X> Unzip<X> { pub fn new(iterator: X) -> Self { Self { iterator } } } impl<'a, X, P, T> Driver<'a, P, T> for Unzip<...
true
6e8b172f0c43e3a751707ce0ca6d14219778bbf4
Rust
wasmerio/wasmer
/lib/vm/src/probestack.rs
UTF-8
2,995
2.796875
3
[ "MIT" ]
permissive
// This file contains code from external sources. // Attributions: https://github.com/wasmerio/wasmer/blob/master/ATTRIBUTIONS.md //! This section defines the `PROBESTACK` intrinsic which is used in the //! implementation of "stack probes" on certain platforms. //! //! The purpose of a stack probe is to provide a stat...
true
31817a39ed185c85d146d4809f9aa36d7506c194
Rust
torkeldanielsson/pe
/pe_50/src/main.rs
UTF-8
944
3.53125
4
[]
no_license
fn is_prime(n: i64) -> bool { if n == 2 { return true; } if n % 2 == 0 || n <= 1 { return false; } let mut i: i64 = 3; while i <= (n as f64).sqrt() as i64 { if n % i == 0 { return false; } i += 2; } return true; } fn main() { ...
true
6fefaf35d00795ce1593a9cf9c75648f568bbe78
Rust
mattdeboard/rs-pugbot
/src/pugbot/commands/pick.rs
UTF-8
8,429
3.09375
3
[ "MIT" ]
permissive
use crate::models::game::GameContainer; use crate::models::game::Phases; use crate::traits::has_members::HasMembers; use crate::traits::phased::Phased; use serenity::framework::standard::macros::command; use serenity::framework::standard::{Args, CommandResult}; use serenity::model::channel::Message; use serenity::prel...
true
d536d5317bb75bb1d1b00ac76e6949bbfd355508
Rust
k-hamada/exercism
/rust/saddle-points/src/lib.rs
UTF-8
1,102
3.328125
3
[]
no_license
pub fn find_saddle_points(input: &[Vec<u64>]) -> Vec<(usize, usize)> { let mut result = vec![]; for (row, n1) in max(&input) { for (col, n2) in min(&transpose(&input)) { if n1 == n2 { result.push((row, col)) } } } result } fn trans...
true