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
d804ae6ab3df2c95691321cda514eb45c0530bb5
Rust
sinlov/rust_playground
/src/grammar/5_slice.rs
UTF-8
486
2.921875
3
[ "Apache-2.0" ]
permissive
fn print_slice_demo(n: &[f64]) { for elt in n { println!("{}", elt); } } #[test] fn slice_type() { let v: Vec<f64> = vec![0.0, 0.707, 1.0, 0.707]; let a:[f64; 4] = [0.0, 0.707, 1.0, 0.707]; let sv: &[f64] = &v; let sa: &[f64] = &a; // slice refence is fat pointer print_slice_de...
true
ecfd3d03030eeea5d1e1db1b1ca585b374020311
Rust
CoreRC/rtsam
/src/core/matrix.rs
UTF-8
4,035
2.75
3
[ "BSD-3-Clause" ]
permissive
use nalgebra as na; use nalgebra::base::{DMatrix, DMatrixSlice, DVector}; pub fn skew_symmetric<N: na::RealField + Copy>( wx: N, wy: N, wz: N, ) -> na::OMatrix<N, na::U3, na::U3> { na::Matrix3::new(N::zero(), -wz, wy, wz, N::zero(), -wx, -wy, wx, N::zero()) } pub fn skew_symmetric_v<N: na::RealField +...
true
a6e9d3e931139d0ddee6ebf925d6578dbef5a789
Rust
hpistor/Advent-Of-Code-2019-Rust
/src/day6.rs
UTF-8
2,266
3.3125
3
[]
no_license
use pathfinding::directed::bfs::bfs; use std::str::FromStr; #[aoc_generator(day6)] fn generator_input(input: &str) -> Vec<OrbitRelation> { input .lines() .map(|s| OrbitRelation::from_str(s).unwrap()) .collect() } pub struct OrbitRelation { pub parent: String, pub identity: String, ...
true
5eb2e9da015ed765a442c338acec698c9f231087
Rust
phil-opp/redox-kernel
/src/arch/x86_64/paging/temporary_page.rs
UTF-8
1,608
3.171875
3
[ "MIT" ]
permissive
//! Temporarily map a page //! From [Phil Opp's Blog](http://os.phil-opp.com/remap-the-kernel.html) use memory::Frame; use super::{ActivePageTable, Page, VirtualAddress}; use super::entry::EntryFlags; use super::table::{Table, Level1}; pub struct TemporaryPage { page: Page, } impl TemporaryPage { pub fn new...
true
028fdb21190d02d2f110a7f66c2c138e72f18e98
Rust
cgrimes01/adventofcode
/2020/day1/src/main.rs
UTF-8
1,561
3.609375
4
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; use std::path::Path; fn main() { let mut numbers: Vec<i32> = Vec::new(); if let Ok(lines) = read_lines("input.txt") { for line in lines { if let Ok(text) = line { let val : i32 = text.parse().expect("Not a number!"); ...
true
4856c3283385012b2c7745315cd72db69a9af27e
Rust
casept/minitor
/minionion/src/cell/auth_challenge.rs
UTF-8
2,042
2.84375
3
[]
no_license
use super::variable_cell::{VariableCell, VariableCommand}; use std::io::{Cursor, Error, Read}; use byteorder::{NetworkEndian, ReadBytesExt}; // Length of AUTH_CHALLENGE cell challenge const CHALLENGE_LEN: usize = 32; #[derive(Debug, Clone)] enum AuthMethods { RsaSha256TlsSecret = 1, Ed25519Sha256Rfc5705 = 3...
true
114f4698277f83e3c5a9314f21322274bb76a216
Rust
dgront/BioShell
/bioshell-seq/src/sequence/sequence_profile.rs
UTF-8
6,877
3.34375
3
[]
no_license
use core::fmt::{Formatter, Display}; use std::string::String; use crate::msa::MSA; use crate::sequence::{ProfileColumnOrder, Sequence}; #[derive(Clone, Debug)] /// Represents a sequence profile. /// /// A protein sequence profile describes preference for each of the 20 standard amino acid residue types /// (possibly...
true
c25bbfa5bb6a54b6249d200a758a9d7f0f60fa3c
Rust
abatkin/aws-presigner-rs
/src/util.rs
UTF-8
1,450
2.734375
3
[ "MIT" ]
permissive
use chrono::{DateTime, Utc}; use hmac::{Hmac, Mac}; use percent_encoding::AsciiSet; use sha2::{Digest, Sha256}; const URLENCODE_PATH: AsciiSet = percent_encoding::NON_ALPHANUMERIC .remove(b'-') .remove(b'.') .remove(b'_') .remove(b'~') .remove(b'/'); const URLENCODE_PARAM: AsciiSet = percent_encod...
true
351e5c1663713a87c84750fd4f8d2b9add7e4f9a
Rust
paveloom-university/Stellar-Astronomy-Laboratory-Workshop-S09-2021
/src/orbit/mod.rs
UTF-8
9,134
3.015625
3
[ "MIT" ]
permissive
//! This module defines the [`Orbit`] struct //! //! Additional modules split the implementation of the struct //! into different files. use serde::Deserialize; use crate::{F, I}; pub mod calc; mod io; /// An alias to `&mut F` type MutFRef<'a> = &'a mut F; /// An alias to `&mut Vec<F>` type MutVecFRef<'a> = &'a mu...
true
eeaeb99bc99358cc076139c2134193ea2ccdc1af
Rust
hueftl/project_euler
/src/bin/p001.rs
UTF-8
255
3.421875
3
[ "MIT" ]
permissive
fn main() { let mut sum = 0; for x in 0..1000 { if x % 3 == 0 { sum += x } else if x % 5 == 0 { sum += x } } println!("The sum of all multiples of 3 and 5 below 1000 equals to {}", sum); }
true
96a0b76c9ad2693ec3e4f1d3dbd5c15dd96e2093
Rust
jstzwj/HanBLAS
/src/kernel/generic/asum.rs
UTF-8
4,763
2.5625
3
[ "MIT" ]
permissive
use crate::{c32, c64, HanInt}; pub unsafe fn sasum_generic(n: HanInt, x: *const f32, incx: HanInt) -> f32 { let mut ret = 0.0e0f32; if n <= 0 || incx <= 0 { return ret; } if incx == 1 { let mut px = x; let px_end = x.offset(n as isize); let m = n % 4; if m != 0...
true
0875067920eef258a61684c964ba155cdc64a902
Rust
kiwiscott/aoc-2019
/src/day8.rs
UTF-8
1,453
3.046875
3
[]
no_license
use aoc_runner_derive::{aoc, aoc_generator}; #[aoc_generator(day8)] fn parse_input(input: &str) -> Vec<Vec<i32>> { let numbers: Vec<i32> = input .chars() .filter(|p| p.is_ascii_digit()) .map(|m| m.to_string().parse::<i32>().unwrap()) .collect(); let mut result: Vec<Vec<i32>> = ...
true
93c0334af9ffe84f0ff28583b282682312f30c00
Rust
jbooth/raft-rs
/src/conn.rs
UTF-8
6,860
2.609375
3
[]
no_license
use std::net::TcpStream; use std::io; use std::fmt; use std::error; use std::result::Result; use std::sync::mpsc::channel; use std::sync::mpsc::{Receiver, Sender}; use std::sync::atomic::AtomicUsize; use std::sync::atomic::Ordering; use std::sync::RwLock; use std::sync::Arc; use std::time::Duration; use chashmap::CHas...
true
76f6dfeb0443bd38ad2abaf78e4b9b04088fe164
Rust
mingyli/tankrs
/server/src/listener.rs
UTF-8
3,750
2.71875
3
[]
no_license
use std::collections::HashMap; use anyhow::Result; use async_std::net::{TcpListener, TcpStream}; use async_std::sync::{Arc, Mutex, RwLock}; use async_std::task; use futures::{stream, StreamExt}; use log::{debug, info, warn}; use uuid::Uuid; use crate::publisher; use crate::world; // Listen for and enqueue actions fr...
true
b358c53a6572dc2fecd11f059cfb308cc639fc84
Rust
ruipserra/learn_opengl
/src/debug.rs
UTF-8
2,534
3.171875
3
[]
no_license
use gl; use gl::types::GLuint; use std::fmt; use std::error::Error; #[macro_export] macro_rules! check_gl_error { () => { match $crate::debug::GlError::check() { Some(error) => println!("{}:{}: {}", file!(), line!(), error), _ => (), } } } #[derive(Debug)] pub enum GlE...
true
4a9e1ba1bd012190ee988e821dc74870a927dfbd
Rust
kumanote/cardano-serialization-lib
/rust/src/transaction/withdrawal.rs
UTF-8
2,908
2.796875
3
[ "MIT" ]
permissive
use crate::address::RewardAddress; use crate::Coin; use std::io::{Write, BufRead, Seek}; use cbor_event::Serialize; use cbor_event::se::Serializer; use cbor_event::de::Deserializer; use crate::serialization::{Deserialize, DeserializeError, DeserializeFailure, Key}; use crate::{to_from_bytes, to_bytes, from_bytes}; #[d...
true
51e89e288482acb8c5676dba75897722a44c4599
Rust
tatetian/ngo2
/src/libos/src/entry/mod.rs
UTF-8
947
2.625
3
[ "BSD-3-Clause" ]
permissive
//! Entrypoints subsystem of the LibOS. //! //! The entrypoints of the LibOS can be broadly classified into two categories: //! * External entrypoints (i.e., ECalls) through which untrusted code can enter //! into the enclave (see the `enclave` module). //! * Internal entrypoints can be further classified into two cate...
true
8d9b7cf8050007a45c36854377c6cdfdf19a6d65
Rust
itsmoirob/rust_tut
/src/lib.rs
UTF-8
440
3.796875
4
[]
no_license
use std::error::Error; // how to make a function pub fn greet_int(x: i64) { println!("Hello to number {}.", x); } // how to make a string function pub fn greet_str(x: &str) { println!("Hello to {}.", x); } pub fn return_str(x: &str) -> String { format!("Get back {}.", x) } // using enum #[derive(Debug)] pub e...
true
b92d95eea22a1c1c376eb1486452004044b41ac6
Rust
bfffs/bfffs
/bfffs-core/src/raid/codec.rs
UTF-8
21,090
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
// vim: tw=80 // This module contains methods that haven't yet been integrated into vdev_raid #![allow(unused)] use crate::types::SGList; use fixedbitset::FixedBitSet; use std::borrow::BorrowMut; use super::sgcursor::*; /// An encoder/decoder for Reed-Solomon Erasure coding in GF(2^8), oriented /// towards RAID appl...
true
ee8f3c46fca30231049696f70ec3b42c25853633
Rust
muzudho/rust-kifuwarabe-wcsc29-lib
/src/sheet_music_format/tape_label.rs
UTF-8
4,911
3.21875
3
[ "MIT" ]
permissive
use serde::*; /// 汎用テープ・ラベル。 /// 元データをそのまま抜き出し、ぴったりした項目がなければ、どこかに入れる。 /// 内容の順序は、 /// * 一意性 /// * テープ名 /// * 時 /// 対局年月日、開始時刻、終了時刻。 /// * 場所 /// * 催し物名 /// * 先手 /// * 後手 /// * ルール /// * 持ち時間制 /// * ハンディキャップ /// * ゲーム内容分析情報 /// * 戦型 /// * ツール付加情報 /// * 棋譜の保存形式 #[derive(Clone, Debug, Default, Des...
true
488a9e6e37efa88101d191c9ce5f0a16db642e89
Rust
crypto-com/jellyfish-merkle-tree
/language/move-prover/stackless-bytecode-generator/src/stackless_control_flow_graph.rs
UTF-8
3,241
2.671875
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 //! Adapted from control_flow_graph for Bytecode, this module defines the control-flow graph on //! Stackless Bytecode used in analysis as part of Move prover. use crate::stackless_bytecode::Bytecode; use bytecode_verifier::control_fl...
true
4b42ae959172ac8eb155fa8eab7493e95e982e1d
Rust
bodagovsky/LFUcache
/src/cache.rs
UTF-8
20,334
3.015625
3
[]
no_license
pub mod LFU { use std::cell::RefCell; use std::collections::HashMap; use std::fmt; use std::rc::{Rc, Weak}; #[derive(Debug)] pub struct LFUCache { len: i32, cap: i32, keys: HashMap<i32, Rc<RefCell<Node>>>, freqs: HashMap<i32, Rc<RefCell<Freq>>>, head: Opt...
true
4f08bfe0a42d71e796dfbdf454b042ee3f1ecbcd
Rust
EdvinAlvarado/RemakeStdArray
/LinkedList.rs
UTF-8
5,290
3.828125
4
[ "BSD-3-Clause" ]
permissive
trait Collectable<T: std::marker::Copy> { fn push(&mut self, n: T); fn pop(&mut self) -> Option<T>; fn get(&self, i: usize) -> Option<T>; } type NodeBox<T> = Option<Box<Node<T>>>; #[derive(PartialEq, Eq, Clone, Debug)] struct Node<T> { pub val: T, pub next: NodeBox<T>, } impl<T: std::marker::Copy...
true
41d23eab52d12abf4e3f89a71a145ee20a3c4a9d
Rust
polyhorn/polyhorn
/crates/polyhorn-android/src/raw/environment.rs
UTF-8
902
2.625
3
[ "MIT" ]
permissive
use polyhorn_android_sys::{Activity, Env}; use polyhorn_ui::layout::LayoutTree; use std::sync::{Arc, RwLock}; /// Opaque type that wraps the shared layout tree. #[derive(Clone)] pub struct Environment { activity: Activity, env: Env<'static>, layout_tree: Arc<RwLock<LayoutTree>>, } impl Environment { /...
true
1993345376b481e900c135a002463311b06b2c0f
Rust
daboross/fern-macros-rs
/tests/lib.rs
UTF-8
1,638
2.6875
3
[ "MIT" ]
permissive
#![feature(old_io)] //! This test file mostly just has tests that make sure that the macros successfully compile. extern crate fern; #[macro_use] extern crate fern_macros; use std::sync; #[test] fn test_log() { fern::local::set_thread_logger(sync::Arc::new( Box::new(fern::NullLogger) as fern::BoxedLogger...
true
a947d82592ce0b7a38c2d488efe3500aa368ccd4
Rust
cristianchaparroa/bikes
/src/bikes/ports/bike_repository.rs
UTF-8
422
2.859375
3
[]
no_license
use crate::bikes::Bike; use uuid::Uuid; // BikeWriter is in charge to write information related // to Bikes pub trait BikeWriter { // It persists for first time a bike fn create(&self, bike: Bike) -> Bike; fn update(&self, id: Uuid, bicycle: Bike) -> Bike; fn delete(&self, id: Uuid) -> usize; } pub t...
true
017acd087eb9f18a9332ee71e838eac353812a14
Rust
tonykuttai/etig
/src/fun.rs
UTF-8
5,795
2.59375
3
[]
no_license
use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; use std::io; use std::fs::File; use std::io::{BufRead,BufReader,Read,stdin}; use std::env; static mut dist1_062:[[i64; 100]; 100] = [[0; 100];100]; static mut v_062:[[i64; 100]; 100] = [[0; 100];100]; static mut tmp_062:[i64;1000]=[0;100...
true
5539dc7fe3056a6ed0cbaac6dc9c4302e211d369
Rust
hoggetaylor/typed-html
/rocket/src/main.rs
UTF-8
1,300
2.53125
3
[]
no_license
#![feature(proc_macro_hygiene, decl_macro, try_from)] extern crate rocket; extern crate typed_html; extern crate typed_html_macros; use rocket::http::ContentType; use rocket::response::Content; use rocket::{get, routes}; use typed_html::text; use typed_html::types::LinkType; use typed_html_macros::html; #[get("/")] ...
true
77877ffcb6f80986b9312324766888ce1d90586b
Rust
SebastienGllmt/chain-libs
/chain-impl-mockchain/src/rewards.rs
UTF-8
7,335
3.015625
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::block::Epoch; use crate::value::{Value, ValueError}; use chain_core::mempack::{ReadBuf, ReadError}; use std::num::NonZeroU64; use typed_bytes::ByteBuilder; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum ReducingType { Linear, Halvening, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub stru...
true
092f8328533708505125d5e74acaa65e1d95760d
Rust
simonjiao/rust-algorithm
/src/bin/meeting_rooms.rs
UTF-8
1,246
3.21875
3
[ "BSD-2-Clause" ]
permissive
//https://leetcode-cn.com/problems/meeting-rooms/ fn overlap(i1: &Vec<i32>, i2: &Vec<i32>) -> bool { if (i1[0] >= i2[0] && i1[0] < i2[1]) || (i1[1] > i2[0] && i1[1] <= i2[1]) { return true; } false } fn can_attend_meeting(intervals: Vec<Vec<i32>>) -> bool { for (idx, m) in intervals.iter().enu...
true
f883dc9d5d726e47bf2d40e14d54793d9a327ac6
Rust
499070844/Minewreeper
/src/controller.rs
UTF-8
629
2.6875
3
[]
no_license
use crate::{ Minewreeper, Model, render }; pub trait Controller { fn renew_board(&mut self); fn dig(&mut self, center: &(u8, u8)); fn check(&mut self, center: Vec<&(u8, u8)>); } impl Controller for Minewreeper { fn renew_board(&mut self) { self.renew(); render(&format!("{}", self)[..]...
true
1d2720229a322981dfea07fd04ba211ce1f2f126
Rust
likr-sandbox/rust-js-sandbox
/src/mithril/render.rs
UTF-8
1,965
2.71875
3
[]
no_license
extern crate webplatform; use std::rc::Rc; use std::cell::RefCell; use std::ops::Deref; use self::webplatform::{Document,HtmlNode}; use super::core::{AttributeValue,Component,Node}; pub fn mount<'a, T: 'a + Component>( document: Rc<RefCell<Document<'a>>>, root: Rc<RefCell<HtmlNode<'a>>>, compo...
true
cd93b1fc82f0704704dd5308cc5208c709069d52
Rust
devil-k/gluesql
/src/ast/operator.rs
UTF-8
1,264
3.359375
3
[ "Apache-2.0" ]
permissive
use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum UnaryOperator { Plus, Minus, Not, } #[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum BinaryOperator { Plus, Minus, Multiply, Divide, Modulo, ...
true
325c8364841af3e808a0040104f950e95406b150
Rust
jburell/rust_presentation
/examples/ex3d.rs
UTF-8
245
2.796875
3
[]
no_license
#![feature(core_intrinsics)] fn print_type_of<T>(_: &T) { println!("Type is: {}", unsafe { std::intrinsics::type_name::<T>() }); } fn main() { let a:i8 = -1; let b = 3u8; let c = a + b; print_type_of(&c); }
true
de63ca692337a5803d1d6e7274428f6966a682ac
Rust
ivanceras/html2sauron
/src/lib.rs
UTF-8
5,163
2.515625
3
[]
no_license
#![deny(warnings)] #![deny(clippy::all)] use sauron::prelude::*; use sauron_syntax::html_to_syntax; use sauron_syntax::Options; #[macro_use] extern crate log; pub enum Msg { ChangeInput(String), Convert, ToggleMacro, ToggleArray, } pub struct App { input: String, output: String, options: ...
true
9d2fdfea851767bd8a37bc091b218247701b51d2
Rust
dmitry-pechersky/algorithms
/leetcode/980_Unique_Paths_III.rs
UTF-8
2,036
2.921875
3
[]
no_license
struct Solution {} impl Solution { pub fn unique_paths_iii(mut grid: Vec<Vec<i32>>) -> i32 { fn dfs(x: usize, y: usize, grid: &Vec<Vec<i32>>, n: usize, m: usize, empty_cnt: u32, in_stack: &mut Vec<Vec<bool>>, in_stack_cnt: &mut u32, path_cnt: &mut i32) { in_stack[x][y] = true; *in_...
true
de3f4e3ad32cd4d0b475ec8f7d322c49cf2f18ae
Rust
Tiancheng-Luo/nll-souffle
/src/ir.rs
UTF-8
1,065
3.515625
4
[]
no_license
pub struct Input { pub blocks: Vec<Block>, } pub struct Block { pub name: String, pub statements: Vec<Statement>, pub goto: Vec<String>, } pub struct Statement { pub effects: Vec<Effect>, } pub enum Effect { /// A borrow `borrow` occured in this statement; the resulting /// reference had ...
true
98d136bdfb81023a39cdb16327e97ecf9bb1c9db
Rust
intdxdt/robust_orientation
/src/lib.rs
UTF-8
5,098
2.90625
3
[ "MIT" ]
permissive
use robust_sum::robust_sum as rsum; use robust_subtract::robust_subtract as rdiff; use robust_scale::robust_scale as rscale; use two_product::two_product as tprod; const EPSILON: f64 = 1.1102230246251565e-16; const ERRBOUND3: f64 = (3.0 + 16.0 * EPSILON) * EPSILON; const ERRBOUND4: f64 = (7.0 + 56.0 * EPSILON) * EPSIL...
true
a9cc93116c26b54b95f57a5af309458f1ce7cb86
Rust
isgasho/lfu-cache
/src/lib.rs
UTF-8
30,086
3.609375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#![warn(clippy::pedantic, clippy::nursery, clippy::cargo)] #![deny(missing_docs)] //! This crate provides an LRU cache with constant time insertion, fetching, //! and removing. //! //! Storage of values to this collection allocates to the heap. Clients with a //! limited heap size should avoid allocating large values ...
true
c93d3c47412187271b718b93f97d569fe5c77963
Rust
mozilla/gecko-dev
/third_party/rust/wasmparser/src/readers/core/custom.rs
UTF-8
2,041
3.296875
3
[ "LicenseRef-scancode-unknown-license-reference", "LLVM-exception", "Apache-2.0" ]
permissive
use crate::{BinaryReader, Result}; use std::ops::Range; /// A reader for custom sections of a WebAssembly module. #[derive(Clone)] pub struct CustomSectionReader<'a> { // NB: these fields are public to the crate to make testing easier. pub(crate) name: &'a str, pub(crate) data_offset: usize, pub(crate)...
true
821e2ec6407fb36936c418aac84f244394dd9d7e
Rust
renorram/udp_even_odd_game
/src/server.rs
UTF-8
2,554
3.15625
3
[ "MIT" ]
permissive
use std::net::{UdpSocket, SocketAddr}; use crate::game::{Game, HandPlayed, GameError}; enum ServerError { GameKind(GameError), ParsingError(String), } pub const DEFAULT_SERVER_ADDRESS: &'static str = "127.0.0.1:34254"; impl ToString for ServerError { fn to_string(&self) -> String { match self { ...
true
bf98caa5e399260b1bef5f67e7cd6f14dfda6dc1
Rust
Start9Labs/md-packer
/src/main.rs
UTF-8
2,641
3.03125
3
[ "MIT" ]
permissive
use std::io::{BufRead, Read}; use std::path::Path; use anyhow::Error; /// ``` /// <!-- MD_PACKER_INLINE BEGIN --> /// ![stuff](http://example.com/foo.jpg) /// <!-- MD_PACKER_INLINE END --> /// ``` /// becomes /// ``` /// ![stuff](data:image/png;base64,...") /// ``` fn main() -> Result<(), Error> { let regex = re...
true
498e58753efa24a32d57d244b5a2a9bb455f55c9
Rust
yxiuz/csnode-rs
/src/core_logic/round.rs
UTF-8
2,134
3.4375
3
[]
no_license
use std::time::Instant; use log::{info}; use num_format::{Locale, ToFormattedString}; pub struct Round { // the first round after start first: u64, // time point the first round started first_start: Instant, // current round current: u64, // time point current round started current_s...
true
d8ec288d838f703f2e24238bc04985d784f3c644
Rust
Masterchef365/simplified_othello
/src/minimax.rs
UTF-8
2,049
2.96875
3
[]
no_license
use crate::{legal_moves, Board, Player, State}; /// Implements the minimax descision function /// Returns a sucessor state for `next_player` pub fn minimax(state: State) -> State { let player = state.next_player; let mut best = None; let mut best_score = std::isize::MIN; for (_, state) in legal_moves(s...
true
979014dd751ce3f5ac26d319e883e31ca0311f72
Rust
nonvirtualthunk/rust-survival-hex
/samvival/data/src/entities/actions.rs
UTF-8
1,664
2.5625
3
[]
no_license
use common::prelude::*; use game::core::Progress; use entities::character::CharacterData; use entities::tile::TileData; use game::Entity; use game::world::WorldView; use std::fmt::Debug; use std::fmt::Formatter; use std::fmt::Error; use std::hash::Hash; use std::hash::Hasher; use entities::selectors::EntitySelector; us...
true
194bcbd5e198d1496b06465ac7fbfdfd260c547e
Rust
fortyninemaps/plyband
/src/types.rs
UTF-8
404
3.09375
3
[ "MIT" ]
permissive
use std::cmp::Ordering; #[derive(PartialEq, PartialOrd, Clone, Copy, Debug)] pub struct RealF64 { pub v: f64, } impl Ord for RealF64 { fn cmp(&self, other: &Self) -> Ordering { if self.v.is_nan() { Ordering::Equal } else { self.partial_cmp(other).unwrap_or(Ordering::Equ...
true
ed6957dc6fa9b785292f739b67a1fb6e34dec0dc
Rust
drbrain/AOC
/2020/src/bin/day_5b.rs
UTF-8
1,353
3.28125
3
[]
no_license
use anyhow::Result; use aoc2020::read; fn main() -> Result<()> { let input = read("./05.input")?; println!("part A: {}", day_5b_a(&input)); println!("part B: {}", day_5b_b(&input)); Ok(()) } fn day_5b_a(input: &str) -> u32 { input.split('\n').map(|path| seat_id(path)).max().unwrap() } fn day_5...
true
1f9e0268fcb3e1d889c891fa2dcee9bcb1b21b16
Rust
gngeorgiev/fut_pool_rs
/src/guard.rs
UTF-8
1,096
2.984375
3
[]
no_license
use crate::object::PoolObject; use crate::pool::Pool; pub struct PoolGuard<T> where T: PoolObject, { object: Option<T>, pool: Pool<T>, } impl<T> PoolGuard<T> where T: PoolObject, { pub(crate) fn new(object: T, pool: Pool<T>) -> PoolGuard<T> { PoolGuard { object: Some(object), ...
true
c0653a5a8dd401815c7b572ab68411ede36477eb
Rust
mitsuhiko/failure
/failure-0.1.X/src/lib.rs
UTF-8
1,220
2.609375
3
[ "MIT", "Apache-2.0" ]
permissive
//! An experimental new error-handling library. Guide-style introduction //! is available [here](https://boats.gitlab.io/failure/). //! //! The primary items exported by this library are: //! //! - `Fail`: a new trait for custom error types in Rust. //! - `Error`: a wrapper around `Fail` types to make it easy to coales...
true
e5a6652598c792a4cc9619f70788f0d1fa67e815
Rust
phynalle/civetcat
/src/colorizer.rs
UTF-8
926
2.84375
3
[]
no_license
use std::rc::Rc; use style::{Style, StyleTree}; use syntax::rule::Grammar; use syntax::tokenizer::Tokenizer; pub struct LineColorizer { scopes: StyleTree, tokenizer: Tokenizer, } impl LineColorizer { pub fn new(scopes: StyleTree, grammar: &Rc<Grammar>) -> LineColorizer { LineColorizer { ...
true
02d70cd3180b9191e75336eec057f352a204fe22
Rust
BProg/rust_exercism
/sieve/src/lib.rs
UTF-8
524
2.921875
3
[]
no_license
pub fn primes_up_to(upper_bound: u64) -> Vec<u64> { let mut primes = vec!(); let mut is_prime: Vec<bool> = vec![]; is_prime.resize((upper_bound + 1) as usize, true); let mut p = 2; while p * p <= upper_bound { if is_prime[p as usize] { let mut i = p * p; while i <= upper_bound { is_pri...
true
92811d58bf1e647312e37c1d3f208ad0bb521d6e
Rust
AljoschaMeyer/magma-exploration
/magma-server/src/lib.rs
UTF-8
2,102
2.53125
3
[]
no_license
#![feature(never_type)] #![feature(generators, generator_trait)] use magma_common::*; use std::collections::HashMap; use std::hash::Hash; use std::marker::PhantomData; use std::io::Write; use std::ops::{Generator, GeneratorState}; use async_trait::async_trait; use futures::Stream; #[async_trait(?Send)] pub trait St...
true
ba3e18c36e68a22ac2b8c4f5646070f65f5dc132
Rust
pythonhacker/project-euler-rust
/problem49.rs
UTF-8
1,244
2.90625
3
[ "Apache-2.0" ]
permissive
// Prime permutations extern crate itertools; use itertools::Itertools; mod common; use common::{vectorp_to_digit_u32, digit_to_vector_u32, is_prime_u32}; fn prime_permute() -> String { let mut n:u32 = 1001; let mut count: usize = 0; loop { if is_prime_u32(n) { let n_vec: Vec<u...
true
f0bae8829cafe2b3bc3d209a625ff82a72fa2a76
Rust
willox/mlua
/src/serde/mod.rs
UTF-8
5,759
3.140625
3
[ "MIT" ]
permissive
//! (De)Serialization support using serde. use std::os::raw::{c_int, c_void}; use std::ptr; use serde::{Deserialize, Serialize}; use crate::error::Result; use crate::ffi; use crate::lua::Lua; use crate::table::Table; use crate::util::{assert_stack, protect_lua, StackGuard}; use crate::value::Value; pub trait LuaSer...
true
5015347ba1d0c7cb270e6fcf9b309124506df347
Rust
EmbarkStudios/axum
/examples/hello-world/src/main.rs
UTF-8
1,558
2.984375
3
[ "MIT" ]
permissive
//! Run with //! //! ```not_rust //! cargo run -p example-hello-world //! ``` #[tokio::main] async fn main() { use axum::async_trait; use axum::http::StatusCode; use axum::{ extract::{extractor_middleware, FromRequest, RequestParts}, routing::{get, post}, Router, }; // An e...
true
d753d643443890d7b29f7a1233b3cfa01dc88d3e
Rust
josecm/exercism-rust
/palindrome-products/src/lib.rs
UTF-8
1,415
3.4375
3
[]
no_license
#[derive(Debug, PartialEq, Eq)] pub struct Palindrome { factors: Vec<(u64, u64)>, } impl Palindrome { pub fn new(a: u64, b: u64) -> Palindrome { Self { factors: vec![(a, b)], } } pub fn value(&self) -> u64 { assert!(self.factors.len() > 0); self.factors[0].0...
true
e200a36c6fc8c9d26ce8a0523808e2f06354b85f
Rust
bennyhodl/btc-tx-search
/src/mempool.rs
UTF-8
3,776
2.765625
3
[]
no_license
// use reqwest; use serde_derive::{Serialize, Deserialize}; use reqwest::{Error, Url}; use std::fmt; use colored::*; /** * * Transaction Structs */ #[derive(Serialize, Deserialize, Debug)] pub struct Transaction { txid: String, version: u8, locktime: u8, vin: Vec<Vin>, vout: Vec<Prevout>, siz...
true
ba3d49e7c1f55c3210153d2ea53a3615fa4ba2bc
Rust
giodamelio/little_boxes
/vendor/rustix/src/maybe_polyfill/no_std/os/fd/raw.rs
UTF-8
5,491
2.984375
3
[ "MIT", "Apache-2.0", "LLVM-exception" ]
permissive
//! The following is derived from Rust's //! library/std/src/os/fd/raw.rs at revision //! fa68e73e9947be8ffc5b3b46d899e4953a44e7e9. //! //! All code in this file is licensed MIT or Apache 2.0 at your option. //! //! Raw Unix-like file descriptors. #![cfg_attr(staged_api, stable(feature = "rust1", since = "1.0.0"))] #!...
true
d2a9be581b53b2f271e8eed701c05214e67f1242
Rust
andete/atsam4lc8c
/src/pm/hsbmask/mod.rs
UTF-8
16,561
2.625
3
[ "Apache-2.0", "MIT" ]
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::HSBMASK { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
true
6188067420c822d7a9f276cc482cbedd1ebaed0c
Rust
edwintcloud/rusty_api
/src/models/user.rs
UTF-8
1,319
2.9375
3
[]
no_license
use diesel; use diesel::prelude::*; use diesel::mysql::MysqlConnection; use schema::users; extern crate bcrypt; #[table_name = "users"] #[derive(Serialize, Deserialize, Queryable, Insertable, AsChangeset)] pub struct User { pub id: Option<i32>, pub first_name: String, pub last_name: String, pub email: ...
true
796216b3bb77c5579b591e299b037b303b25b77d
Rust
itto-ki/atcoder
/ABC/024/A.rs
UTF-8
765
3.21875
3
[]
no_license
fn read_i32quartet() -> (i32, i32, i32, i32) { let mut input = String::new(); let _ = std::io::stdin().read_line(&mut input); let v: Vec<i32> = input.trim() .split_whitespace() .map(|x| x.parse().unwrap()) .collect(); (v[0], v[1], v[2], v[3]) } fn read_i32pair() -> (i32, i32) { ...
true
a1824e264f75df3dcd5eb13ddb27ad8af724cf0f
Rust
anlumo/cef
/src/multimap.rs
UTF-8
4,062
3.0625
3
[]
no_license
use cef_sys::{ cef_string_multimap_alloc, cef_string_multimap_append, cef_string_multimap_clear, cef_string_multimap_enumerate, cef_string_multimap_find_count, cef_string_multimap_free, cef_string_multimap_key, cef_string_multimap_size, cef_string_multimap_t, cef_string_multimap_value, }; use std::colle...
true
38c2a6a8f297755b4eb0193ef762d19a2e803577
Rust
max-ym/kobzar_env
/src/path.rs
UTF-8
8,888
2.84375
3
[]
no_license
//! Each resource in the system has it's own path and unique identifier. Path is used //! to identify the resource as a class with similar properties whereas ID identify each //! instance of it. ID is big enough to be used in complex systems with multiple computers with //! very little chance to have overlapping IDs. I...
true
3a9b1efb4d9100175850e168c005292a2c7beefc
Rust
ejmg/rsass
/src/functions/mod.rs
UTF-8
5,970
2.65625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::error::Error; use crate::variablescope::Scope; use crate::{css, sass}; use lazy_static::lazy_static; use std::collections::BTreeMap; use std::sync::Arc; use std::{cmp, fmt}; #[macro_use] mod macros; mod color; mod list; mod map; mod math; mod meta; mod selector; mod string; pub fn get_builtin_function(nam...
true
cac2093e50ef35ba75954433e827215d112fee50
Rust
FlorianWilhelm/polars
/polars/polars-core/src/series/comparison.rs
UTF-8
6,117
2.921875
3
[ "MIT" ]
permissive
//! Comparison operations on Series. use super::Series; use crate::apply_method_numeric_series; use crate::prelude::*; use crate::series::arithmetic::coerce_lhs_rhs; macro_rules! impl_compare { ($self:expr, $rhs:expr, $method:ident) => {{ match $self.dtype() { DataType::Boolean => $self.bool()...
true
18050e6a749d2b00c5a780fa17df0e13fc075861
Rust
saward/soloud-rs
/soloud/src/filter/waveshaper.rs
UTF-8
685
2.546875
3
[ "LicenseRef-scancode-other-permissive", "MIT" ]
permissive
use super::ParamType; use crate::prelude::*; /// Wave shaper filter attributes #[repr(u32)] #[derive(FilterAttr, Copy, Clone, Debug, PartialOrd, PartialEq)] pub enum WaveShaperFilterAttr { /// "Wet" attribute Wet = 0, /// "Amount" attribute Amount = 1, } /// Wrapper around the wave shaper filter #[der...
true
27fa1a3cfa8f1e2a9ae01fc03ca53a4c39ff6bb0
Rust
Fraser999/ewok
/src/peer_state.rs
UTF-8
7,000
3.109375
3
[]
no_license
use name::Name; use std::collections::{BTreeMap, BTreeSet}; use std::mem; use params::NodeParams; use block::Block; use self::PeerState::*; use itertools::Itertools; #[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)] enum PeerState { /// Appeared in all current blocks at some point. Confirmed, /// App...
true
44506848cae6b91f94f22c5d7133213fed04698e
Rust
mvanschellebeeck/advent-of-code-20
/src/day03.rs
UTF-8
957
3.375
3
[]
no_license
use std::fs; pub fn solve(part: u8) -> Option<i64> { match part { 1 => Some(part_1(3, 1)), 2 => Some(part_2()), _ => None, } } pub fn part_1(right: i64, down: i64) -> i64 { let input: Vec<Vec<char>> = fs::read_to_string("input/day03_p1") .unwrap() .lines() ....
true
342632abba3186879ecd34c80f1c75906ee4cf34
Rust
noahbkim/htor
/src/evaluator/expansion.rs
UTF-8
918
2.90625
3
[]
no_license
use crate::error::AnonymousEvaluationError; use crate::evaluator::scope::EvaluatorScope; pub trait Expansion { fn expand( &self, scope: &EvaluatorScope, args: &Vec<Vec<u8>>, ) -> Result<Vec<u8>, AnonymousEvaluationError>; } pub struct InlineExpansion { name: String, value: Vec<...
true
aaad2839f444dca7e5d7c1c60feacdcccfb470ee
Rust
fabien-michel/advent-of-code-2020
/src/days/day12.rs
UTF-8
3,226
3.390625
3
[]
no_license
use crate::utils::print_day_banner; use crate::utils::read_lines; #[derive(Debug)] struct Instruction { action: char, value: isize, } pub fn day12_01() { print_day_banner(12, 1); let instructions = load_instructions(); let mut x: isize = 0; let mut y: isize = 0; let mut orientation: isize ...
true
d715d2f070e979676055037d067073da8da5f8d8
Rust
weichweich/p2p_fun
/src/key.rs
UTF-8
1,089
2.65625
3
[]
no_license
use crate::Opt; use libp2p::identity::{ed25519, Keypair}; use std::{ error::Error, fs::File, io::{Read, Write}, }; pub fn get_keypair(matches: &Opt) -> Result<Keypair, Box<dyn Error>> { if matches.generate_key { log::info!("Generate new key pair."); let keypair = ed25519::Keypair::gener...
true
756b2ee79cec6afa39196cbdf317c50cf0829370
Rust
qelphybox/dotenv-linter
/tests/cli_exclude.rs
UTF-8
1,129
2.53125
3
[ "MIT" ]
permissive
#[allow(dead_code)] mod cli_common; use cli_common::TestDir; #[test] fn exclude_one_file() { let test_dir = TestDir::new(); let testfile = test_dir.create_testfile(".env", " FOO="); test_dir.test_command_success_with_args(&["--exclude", testfile.as_str()]); } #[test] fn exclude_two_files() { let test...
true
3b814ef08b471ad114e8458724f3b7c32cc3d9d1
Rust
croquelois/aoc-2019-rust
/advent02/src/main.rs
UTF-8
1,382
3.453125
3
[]
no_license
use std::fs; fn parse(filename: impl AsRef<std::path::Path>) -> Vec<usize> { return fs::read_to_string(filename).expect("Something went wrong reading the file") .split(",").map(|s| s.parse::<usize>().unwrap()).collect(); } fn process(mem: &mut [usize]) { let mut i = 0; loop { let op = mem[i]; let in...
true
1f0a355c8b6ad42b71a28531975d13a7a4c224af
Rust
GaloisInc/crucible
/crux-mir/lib/core/src/slice/mod.rs
UTF-8
160,490
2.515625
3
[ "BSD-3-Clause" ]
permissive
//! Slice management and manipulation. //! //! For more details see [`std::slice`]. //! //! [`std::slice`]: ../../std/slice/index.html #![stable(feature = "rust1", since = "1.0.0")] use crate::cmp::Ordering::{self, Greater, Less}; use crate::fmt; use crate::intrinsics::{assert_unsafe_precondition, exact_div}; use cra...
true
889813141b3e5eac174544ab66b0087b2042585d
Rust
isotop751/rust-adventures
/guessing/src/main.rs
UTF-8
1,476
3.671875
4
[]
no_license
use std::io; use std::io::Write; use rand::Rng; use std::cmp::Ordering; fn main() { let secret: u64 = rand::thread_rng().gen_range(1..101); println!("The secret number is {}", secret); let mut counter: u64 = 1; loop { if counter > 10 { println!("\tYou have used all ...
true
68a42001d971b391bcb6d07d71099671e6f8751d
Rust
w23/alacritty
/alacritty_terminal/src/tty/windows/automatic_backend.rs
UTF-8
5,310
2.84375
3
[ "Apache-2.0" ]
permissive
//! Types to determine the appropriate PTY backend at runtime. //! //! Unless the winpty feature is disabled, the PTY backend will automatically fall back to //! WinPTY when the newer ConPTY API is not supported, as long as the user hasn't explicitly //! opted into the WinPTY config option. use std::io::{self, Read, W...
true
80da172b9b64d1d2c81f0719eadd49573a1b31b0
Rust
jtescher/tracing-opentelemetry
/src/span_ext.rs
UTF-8
3,344
2.703125
3
[ "MIT" ]
permissive
use crate::layer::{build_context, WithContext}; use opentelemetry::api; /// `OpenTelemetrySpanExt` allows tracing spans to accept and return /// OpenTelemetry `SpanContext`s. pub trait OpenTelemetrySpanExt { /// Associates `self` with a given `OpenTelemetry` trace, using /// the provided parent context. //...
true
3719eb3ce0260527e368c202bbfb204c7172733f
Rust
notify-rs/notify
/notify/src/config.rs
UTF-8
3,961
3.5
4
[ "CC0-1.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0", "LicenseRef-scancode-public-domain" ]
permissive
//! Configuration types use std::time::Duration; /// Indicates whether only the provided directory or its sub-directories as well should be watched #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] pub enum RecursiveMode { /// Watch all sub-directories as well, including directories created afte...
true
bdd54658a82871210d49ca7e2540bf44f8195fe7
Rust
complez-rs/deep_thought
/src/optimizer/optim_trait.rs
UTF-8
547
2.75
3
[ "MIT" ]
permissive
use crate::neural_network::NeuralNetwork; /// Implement this for your custom optimizers pub trait Optimizer { /// Create a new Optimizer instance based on the networks shape. Some Optimizers require knowledge about hidden layer sizes /// which is why you need to pass a reference to the network here fn new(...
true
936890248c0ee6f13221dd64165d9ce1154a25c1
Rust
whispermemory/nickel.rs
/src/response.rs
UTF-8
3,938
2.9375
3
[ "MIT" ]
permissive
extern crate mustache; use std::str; use std::sync::{Arc, RWLock}; use std::collections::HashMap; use std::io::{IoResult, File}; use std::io::util::copy; use std::path::BytesContainer; use serialize::Encodable; use http; use time; use mimes::get_media_type; ///A container for the response pub struct Response<'a, 'b: ...
true
905153cfd20cccb540fc50e84a74c7db14c18a2c
Rust
LevitatingBusinessMan/dagon
/src/server/commands/mod.rs
UTF-8
757
2.5625
3
[]
no_license
extern crate dagon_lib; use dagon_lib::protocol::{MessageCommand, MessageData}; use std::net::SocketAddr; mod register; use register::register; mod authenticate; use authenticate::authenticate; type ArgumentList= Vec::<&'static str>; pub fn command_handler(message: MessageCommand, peer: SocketAddr) -> Vec<u8> { r...
true
2060109657e826f3f99b891f09cbaca88ca0d633
Rust
ksavinash9/rust-protobuf
/protobuf/src/reflect/accessor/map.rs
UTF-8
2,954
2.578125
3
[ "BSD-2-Clause" ]
permissive
use std::collections::HashMap; use std::hash::Hash; use Message; use core::message_down_cast; use reflect::runtime_types::RuntimeType; use reflect::accessor::FieldAccessor; use reflect::types::ProtobufType; use reflect::accessor::AccessorKind; use reflect::map::ReflectMapRef; use reflect::map::ReflectMapMut; use core...
true
c444cc3948d1ccc240d0857b7bacc69c6ca3f5cb
Rust
Barre/dockerfile-parser-rs
/tests/parsing.rs
UTF-8
3,751
2.703125
3
[ "MIT", "LicenseRef-scancode-dco-1.1" ]
permissive
// (C) Copyright 2019-2020 Hewlett Packard Enterprise Development LP extern crate dockerfile_parser; use dockerfile_parser::*; mod common; use common::*; #[test] fn parse_basic() -> Result<(), dockerfile_parser::Error> { let dockerfile = Dockerfile::parse(r#" FROM alpine:3.10 RUN apk add --no-cache curl ...
true
f867015e18964a321a6cebd1b1f35c963b0923a8
Rust
Wazner/mssql-browser
/src/error.rs
UTF-8
6,993
3.25
3
[]
no_license
use std::error::Error; use std::net::SocketAddr; /// An error that can be returned from the different browser operations pub enum BrowserError< #[cfg(any(feature = "tokio", feature = "async-std"))] SFError: Error = <super::socket::DefaultSocketFactory as super::socket::UdpSocketFactory>::Error, #[cfg(any(f...
true
2072d9c0ae88ae1e937d00007a31528041fe4515
Rust
katharostech/parry
/src/bounding_volume/bounding_sphere_ball.rs
UTF-8
589
2.96875
3
[ "Apache-2.0" ]
permissive
use crate::bounding_volume::BoundingSphere; use crate::math::{Isometry, Point, Real}; use crate::shape::Ball; impl Ball { /// Computes the world-space bounding sphere of this ball, transformed by `pos`. #[inline] pub fn bounding_sphere(&self, pos: &Isometry<Real>) -> BoundingSphere { let bv: Boundi...
true
30a0ae39e2dc75dfc24c98b66877198f62bc4a8f
Rust
konradsz/adventofcode2016
/day08/src/main.rs
UTF-8
3,002
3.40625
3
[]
no_license
#[macro_use] extern crate lazy_static; use regex::Regex; use std::fs; type Screen = Vec<Vec<Pixel>>; const SCREEN_WIDTH: usize = 50; const SCREEN_HEIGHT: usize = 6; #[derive(Copy, Clone, PartialEq)] enum Pixel { On, Off, } fn part_1(screen: &Screen) -> usize { screen.iter().flatten().filter(|p| **p == Pi...
true
13deec039cabe7b7ad0f676310bc42ff6ee77bb1
Rust
mehmetsefabalik/rust-mongodb-example
/src/controller.rs
UTF-8
929
2.65625
3
[ "MIT" ]
permissive
use actix_web::{web, HttpResponse, Responder}; #[derive(serde::Deserialize)] pub struct User { name: String, } pub async fn index(app_data: web::Data<crate::AppState>, user: web::Query<User>) -> impl Responder { let result = web::block(move || app_data.service_container.user.create(&user.name)).await; mat...
true
092344431b3057a5070464d08b93aa6146f3f5dc
Rust
pipi32167/LeetCode
/rust/src/problem_0760.rs
UTF-8
742
3.359375
3
[]
no_license
use std::collections::HashMap; #[derive(Debug)] struct Solution {} impl Solution { pub fn anagram_mappings(a: Vec<i32>, b: Vec<i32>) -> Vec<i32> { let mut map: HashMap<i32, Vec<i32>> = HashMap::new(); b.into_iter().enumerate().for_each(|(i, v)| { let entry = map.entry(v).or_insert(vec...
true
6808bb6bdee1be129e8e86cb44f67cc710e6a4d7
Rust
redox-os/orbtk
/orbtk_widgets/src/image_widget.rs
UTF-8
972
3.0625
3
[ "MIT", "CC-BY-4.0" ]
permissive
use crate::{api::prelude::*, proc_macros::*, render::prelude::*}; widget!( /// The `ImageWidget` widget is used to draw an image. It is not interactive. /// /// **style:** `image-widget` ImageWidget { /// Sets or shares the image property. /// /// Set image property: ///...
true
76cebddb32e203aa4094811ed7523208486314b5
Rust
elichai/Lorenz
/src/x25519.rs
UTF-8
4,060
2.53125
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::secret::Secret; use crate::Error; use lazy_static::lazy_static; use rand_os::OsRng; use ring::digest::SHA256; use ring::hkdf; use ring::hmac::SigningKey; use rustc_hex::{FromHex, ToHex}; use std::fmt; use std::str::FromStr; use x25519_dalek::{PublicKey, StaticSecret}; use zeroize::{Zeroize, Zeroizing}; lazy...
true
2baf6c4f41592ee7377c2238b822e39a562b2ebf
Rust
LinAGKar/advent-of-code-2017-rust
/day1a/src/main.rs
UTF-8
395
3.234375
3
[ "MIT" ]
permissive
use std::io; fn main() { let mut string = String::new(); io::stdin().read_line(&mut string).expect("Failed to read line"); let numbers : Vec<u32> = string.trim().chars().map(|x| x.to_digit(10).expect("Non-digit found")).collect(); println!("{}", (0..numbers.len()).filter(|x| { numbers[*x] == nu...
true
d83ece9b1bf82a9100f4c7c3c23956cb4f1e7533
Rust
McM1k/DSLR
/src/parser.rs
UTF-8
1,659
2.953125
3
[]
no_license
use crate::student::Student; pub fn get_train_file_content(filename: String) -> Vec<Student> { let mut csv = csv::Reader::from_path(filename).expect("cannot read csv"); let mut data = Vec::new(); for line in csv.records() { let sr = line.expect("Cannot parse one of the lines"); let tokens...
true
7f551c69676671d7733ea666521e0b8ba1cf14e0
Rust
mtn/viola-jones
/src/preprocess.rs
UTF-8
8,444
3.203125
3
[ "MIT" ]
permissive
/// Functions for loading the pre-processing data extern crate image; use super::{Classification, Matrix}; use image::{DynamicImage, GenericImageView}; use ndarray::Array; use std::fs; /// Take two lists of integral images and flatten them into a list of (img, label) tuples fn flatten_to_classlist( integral_faces...
true
a4717a76159e942a5aa56b44ea375eeb17ff44b9
Rust
str4d/metrics
/metrics/tests/macros/02_metric_name.rs
UTF-8
133
2.625
3
[ "MIT" ]
permissive
use metrics::counter; fn valid_name() { counter!("abc_def", 1); } fn invalid_name() { counter!("abc$def"); } fn main() {}
true
034d0aae5e9eb9d225209e2e497e8e5b04f80c42
Rust
dcorderoch/TallerRust
/OOP/clases.rs
UTF-8
1,642
4.1875
4
[]
no_license
use std::cmp::Ordering; //consiste en ganar metodos de la estructura, de forma que derive #[derive(Copy, Clone)] struct Punto { x: i32, y: i32 } struct Rectangulo { origen: Punto, ancho: i32, alto: i32 } // le implementa un metodo a la estructura rectangulo impl Rectangulo { // self hace refe...
true
a05c852212580613b1cc644636795e02b5b6bd23
Rust
oberien/heradoc
/src/resolve/include.rs
UTF-8
3,521
3.390625
3
[]
no_license
//! Result type of the resolution of a file include. use std::path::{Path, PathBuf}; use std::str::FromStr; use url::{Url, ParseError}; use super::BASE_URL; /// Represents the current context we're including from #[derive(Debug, PartialEq, Eq)] pub struct Context { /// Full URL to the file / content /// ...
true
06426258950ae6876074af9150643c329800726d
Rust
PhilipDaniels/rtest
/cargo_test_parser/src/doc_test.rs
UTF-8
2,576
3.421875
3
[ "MIT" ]
permissive
use crate::{parse_context::ParseContext, parse_error::ParseError, utils::parse_leading_usize}; #[derive(Debug, Default, Clone, PartialEq, Eq)] pub struct DocTest<'a> { pub name: &'a str, pub line_number: usize, pub file_name: &'a str, } impl<'a> DocTest<'a> { /// Construct a new `DocTest` from a line ...
true
05ab1c9899213443cfdbf22695259c906b63176e
Rust
r0ck3r008/ptree
/src/ptree/mod.rs
UTF-8
2,296
3.203125
3
[]
no_license
use std::collections::HashMap; struct Pnode { slice: String, hmap: HashMap<char, Child>, } type Child = Box<Pnode>; pub struct Ptree { root: Child, size: usize, } fn getlvl(s1: &str, s2: &str) -> usize { let mut count = 0; let v1: Vec<char> = s1.chars().collect(); let v2: Vec<char> = s2....
true
c1dc3c1c5f63fde37da5ebc29f31c2da9179eae6
Rust
dkandalov/katas
/rust/hello-rust/src/8-functions.rs
UTF-8
4,121
3.75
4
[ "Unlicense" ]
permissive
#![allow(dead_code, unused_variables)] fn main() { // 8 // (http://rustbyexample.com/fn.html) fn is_divisible_by(lhs: u32, rhs: u32) -> bool { if rhs == 0 { return false; } lhs % rhs == 0 } fn void_return(n: u32) -> () {} fn void_return2(n: u32) {} // 8...
true
279289ea00259c016df14124ec511c1b2a2dd609
Rust
RKochenderfer/homrs
/server/src/cust_error.rs
UTF-8
373
2.9375
3
[]
no_license
use std::convert::TryFrom; type BoxedError = Box<dyn std::error::Error + Send + Sync>; // A simple type alias so as to DRY. pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>; #[derive(Debug)] pub struct Error(pub &'static str); impl Error { pub fn boxed(error: &str) -> BoxedE...
true