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
b8e0c27e1e529aec58869c3bf2597e338eac1241
Rust
tustvold/rust-playground
/lib/jwt/src/model.rs
UTF-8
2,968
2.59375
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::convert::TryInto; use std::hash::Hash; use std::str::FromStr; use chrono::{DateTime, Utc}; use ring::signature; use ring::signature::RsaPublicKeyComponents; use serde::{Deserialize, Serialize}; use strum_macros::{AsRefStr, EnumString}; use crate::tag; #[derive(Seria...
true
99c56c8acaf04ed931ff98f53d921c6a16a47f6a
Rust
dejanb/drogue-influxdb-function
/src/handler.rs
UTF-8
3,657
2.71875
3
[]
no_license
use crate::config::{Path, Processor}; use crate::error::ServiceError; use actix_web::{web, HttpResponse}; use chrono::Utc; use cloudevents::AttributesReader; use cloudevents::{event::Data, Event}; use influxdb::{InfluxDbWriteable, Timestamp, Type, WriteQuery}; use serde_json::Value; use std::collections::HashMap; // I...
true
82d087e4eaf4d40a28968f3360552f79002e74c2
Rust
DavidColson/RustyRaytracer
/src/vec.rs
UTF-8
3,127
3.578125
4
[ "MIT" ]
permissive
use std::ops::Add; use std::ops::AddAssign; use std::ops::Sub; use std::ops::SubAssign; use std::ops::Neg; use std::ops::Mul; use std::ops::Div; use std::ops::DivAssign; #[derive(Copy, Clone, Debug)] pub struct Vec3 { pub x: f64, pub y: f64, pub z: f64, } impl Vec3 { pub fn new(x: f64, y: f64, z: f64)...
true
4ec756d866657f9dee086963aa61d8df1be635c8
Rust
leizy0/AoCInRust
/2018/day13/src/main.rs
UTF-8
19,439
3.09375
3
[ "MIT" ]
permissive
use std::fmt; use std::fs; use std::io::{self, BufRead, Write}; use std::cmp::{max, min}; fn main() { let input_path = "input.txt"; let input_file = fs::File::open(input_path).expect(&format!("Failed to open input file({})", input_path)); let input_lines: Vec<String> = io::BufReader::new(input_file...
true
cfbab72f86b72f3ecdd8764261eaf01904cc8d92
Rust
veniamin-ilmer/crate-race
/benches/vec_intsort/bench.rs
UTF-8
2,151
2.609375
3
[ "Apache-2.0" ]
permissive
//!Sorting Vecs of u32. //! //!* *Baseline*: 1 item. //!* *Sorted*: 10,000 items, fully sorted already. //!* *Random*: 10,000 items, randomly shuffled. (The shuffling is not part of the time). //!* *Reverse*: 10,000 items, sorted in reverse order. #[macro_use] extern crate bencher; mod _std; mod _afsort; mod _cycle_s...
true
7c37d8e073d93d14e6cdff5e9de7a434101a4891
Rust
thibault-martinez/bee
/bee-message/src/message.rs
UTF-8
6,968
2.546875
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 use crate::{ parents::Parents, payload::{option_payload_pack, option_payload_packed_len, option_payload_unpack, Payload}, Error, MessageId, }; use bee_common::packable::{Packable, Read, Write}; use bee_pow::providers::{miner::Mine...
true
448c94eb26b1a9bdd96d2adeb9d251d7f339f496
Rust
vaibhavantil2/third-party-api-clients
/github/src/markdown.rs
UTF-8
1,518
3.25
3
[ "MIT" ]
permissive
use anyhow::Result; use crate::Client; pub struct Markdown { pub client: Client, } impl Markdown { #[doc(hidden)] pub fn new(client: Client) -> Self { Markdown { client } } /** * Render a Markdown document. * * This function performs a `POST` to the `/markdown` endpoint. ...
true
bc50886d6b8424ae07e4c3eb247a9449522eee62
Rust
InFarAday/Projet-RustRSA
/rrsa/src/tests.rs
UTF-8
11,752
3.125
3
[]
no_license
mod maths { /// Tests des utilitaires d'extensions des nombres et vecteurs de nombres mod nvutil { use crate::maths::{NumUtil, VecNumUtil}; use num_bigint::BigUint; /// Test nombre de chiffres d'un nombre en radix N #[test] fn nu_sz() { asse...
true
f7b2a5251fafd94a355b140fe65256421525e452
Rust
AidenZuk/mempool
/src/lib.rs
UTF-8
11,115
3.46875
3
[]
no_license
//! A thread-safe object pool with automatic return and attach/detach semantics //! //! The goal of an object pool is to reuse expensive to allocate objects or frequently allocated objects //! //! # Examples //! //! ## Creating a Pool //! //! The general pool creation looks like this //! ``` //! let pool: MemPool<T> =...
true
408bf3f23e1ce3226651dcaa005541d118b68fcb
Rust
irauta/reframe
/src/mesh.rs
UTF-8
1,129
3.265625
3
[]
no_license
use std::rc::Rc; use regl::{VertexArray, PrimitiveMode, IndexType}; pub enum DrawType { /// Non-indexed drawing. NonIndexed, /// Indexed drawing. Indexed { /// u8, u16 or u32 indices? index_type: IndexType, /// How far in the index buffer is the first index? starting_in...
true
451ea07d88f8ab2966fc5504d3d5224d62df5f91
Rust
mbillingr/lisp-in-small-pieces
/project/src/syntax/expression.rs
UTF-8
4,653
2.625
3
[]
no_license
use super::alternative::Alternative; use super::application::Application; use super::assignment::Assignment; use super::boxes::{BoxCreate, BoxRead, BoxWrite}; use super::closure::FlatClosure; use super::constant::Constant; use super::definition::GlobalDefine; use super::fixlet::FixLet; use super::function::Function; us...
true
e98b1d8b5cb93d9493cdecedb8782ef3ef753f94
Rust
giodamelio/little_boxes
/vendor/anstream/src/adapter/strip.rs
UTF-8
14,496
3.28125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use anstyle_parse::state::state_change; use anstyle_parse::state::Action; use anstyle_parse::state::State; /// Strip ANSI escapes from a `&str`, returning the printable content /// /// This can be used to take output from a program that includes escape sequences and write it /// somewhere that does not easily support ...
true
b3e2be63ea2b156257532f4e00c55d7713f69d0b
Rust
forbjok/vut
/lib/src/project/config/glob.rs
UTF-8
1,010
2.984375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::borrow::Cow; use serde_derive::Deserialize; use crate::project::VutError; /// One or more glob patterns. #[derive(Clone, Debug, Deserialize)] #[serde(rename_all = "kebab-case")] #[serde(untagged)] pub enum Globs { Single(String), Multiple(Vec<String>), } impl Globs { pub fn to_vec(&self) -> Vec...
true
f9dea46938c25106f0800946c12f562c3a8983d5
Rust
ivanceras/restq
/src/data_type.rs
UTF-8
9,366
3.015625
3
[ "MIT" ]
permissive
use crate::{ast::parser::ident, Error}; use pom::parser::*; use serde::{Deserialize, Serialize}; use sql_ast::ast as sql; use std::fmt; /// restq supports comprehensive data types /// based on rust and postgresql type, combined together /// format: <data_type>[?](contraint) /// ? - indicates it is optional, nulla...
true
58d1b0a71def351b1eb95072df99a3e2e4b4380a
Rust
ja1den/research-project
/scenarios/1/rs/src/main.rs
UTF-8
1,008
3.015625
3
[ "MIT" ]
permissive
// Import use std::{env, fs, io}; // Main Function fn main() { // Resolve Directories let root = env::current_dir() .unwrap() .join("..") .canonicalize() .unwrap(); let i_path = root.join("data/input").canonicalize().unwrap(); let o_path = root.join("data/rs").canonicalize().unwrap(); // File Names let...
true
bac7c64f26cdbc96ab95bc6347385e1801ce6b91
Rust
sile/erl_parse
/src/cst/form.rs
UTF-8
4,551
2.578125
3
[ "MIT" ]
permissive
use erl_tokenize::tokens::AtomToken; use erl_tokenize::values::Symbol; use erl_tokenize::{LexicalToken, Position, PositionRange}; use super::forms; use crate::traits::{Parse, TokenRead}; use crate::{ErrorKind, Parser, Result}; #[derive(Debug, Clone)] #[allow(clippy::large_enum_variant)] pub enum Form { ModuleAttr...
true
7d75f8d122413093e1f16b8ffd094b0e7e45866b
Rust
leshow/exercism
/hackerrank/src/sum_of_even_numbers_after_queries.rs
UTF-8
1,363
3.546875
4
[]
no_license
// 985. Sum of Even Numbers After Queries // Easy // We have an array A of integers, and an array queries of queries. // For the i-th query val = queries[i][0], index = queries[i][1], we add val to // A[index]. Then, the answer to the i-th query is the sum of the even values // of A. (Here, the given index = queries[i...
true
4e5bac68910d629d8d86e30d898e1b0d093d4c4d
Rust
LehmRob/tmp
/rust/array/src/main.rs
UTF-8
876
4
4
[]
no_license
fn main() { println!("Hello, friend!"); // ARRAYS // ====== // Declare arrays let a1 = [1, 2, 3]; // a1: [i32; 3] let a2 = [1, 2, 3, 4]; // a2: [i32; 4] let a3 = [0; 20]; // a3: [i32; 20] declare a array with 20 elements and all initilized with 0 // Get the length of the array ...
true
152e9455d2b7276fb473478ef531b152e3cc1af0
Rust
JLockerman/FuzzyLog
/servers/tokio_server/src/main.rs
UTF-8
9,881
2.578125
3
[ "BSD-3-Clause" ]
permissive
#[macro_use] extern crate log; extern crate env_logger; extern crate tokio_server; use std::env; use std::net::{SocketAddr, IpAddr, Ipv4Addr}; pub fn main() { let _ = env_logger::init(); let Args {port_number, group, num_worker_threads, upstream, downstream} = parse_args(); let ip_addr = IpAddr:...
true
ee7cbc388f47db45a32e073a0a4c1e1ab350b49f
Rust
chris-morgan/diffbot-rust-client
/src/diffbot/test.rs
UTF-8
5,283
2.75
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern mod diffbot = "diffbot#1.0"; extern mod extra = "extra#0.10-pre"; use extra::json; use extra::treemap::TreeMap; fn invalid_token() -> ~str { ~"0" } fn valid_token() -> ~str { ~"6932269b31d051457940f3da4ee23b79" } #[test] pub fn invalid_key() { assert_eq!(diffbot::call(&from_str("http://example.co...
true
565a2e01fbd40d514369cd63a536ad280b1f2582
Rust
royswale/leetcode
/src/bin/check-if-n-and-its-double-exist.rs
UTF-8
1,034
3.671875
4
[ "MIT" ]
permissive
fn main() {} struct Solution; impl Solution { pub fn check_if_exist(arr: Vec<i32>) -> bool { let mut map = std::collections::HashMap::<i32, ()>::new(); // for (index, value) in arr.iter().enumerate() { // map.insert(*value, index); // } // // for (index, value)...
true
b01c68c2ad4cc9332946fcbd7350a759cc4e5f72
Rust
mjcarson/syncwrap
/src/lib.rs
UTF-8
8,354
3.71875
4
[ "MIT" ]
permissive
//! # Syncwrap //! //! Wraps asynchronous functions in order to make them synchronous based on if a //! "sync" feature is enabled. This is useful when writting http clients as you //! can write async methods and wrap them for use in synchronous code bases //! automatically. //! //! # Usage //! ```toml //! [dependencies...
true
db9fff4e8bf732907ee7bdbefdd75feddff602ec
Rust
zexho994/Zex
/cmd/src/main.rs
UTF-8
3,467
3.171875
3
[ "Apache-2.0" ]
permissive
use clap::App; use clap::Arg; use std::fs::File; use std::io::Read; use std::path::Path; const DEFAULT_PATH: &str = "/Users/zexho/Github/Zex/sample"; // const DEFAULT_PATH: &str = "/Users/a994/Github/Zex/sample"; /// ./target/debug/cmd -f /echo/echo_int.zex --out all fn main() { // 配置cmd命令 let matches = App::...
true
b79f45f29b476251d8af29088d2658f1eb6cfd5e
Rust
james2509/wiremock-rs
/src/mock_actor.rs
UTF-8
3,875
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::active_mock::ActiveMock; use crate::{Mock, Request}; use bastion::prelude::*; use futures_timer::Delay; use http_types::{Response, StatusCode}; use log::{debug, warn}; use std::time::Duration; #[derive(Clone)] pub(crate) struct MockActor { pub actor_ref: ChildRef, } #[derive(Clone, Debug)] struct Reset...
true
6fc601038b09ceae48d97674a2fa7f6aa0ce4cd3
Rust
fractalide/netsim
/src/wire/mac.rs
UTF-8
1,464
3.109375
3
[ "MIT", "BSD-3-Clause" ]
permissive
use crate::priv_prelude::*; use rand; /// An ethernet hardware MAC address. #[derive(Clone, Copy, PartialEq)] pub struct MacAddr { bytes: [u8; 6], } impl fmt::Debug for MacAddr { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:02X}:{:02X}:{:02X}:{:02X}:{:02X}:{:02X}", s...
true
7e719170d48c270d7d49bc290bacc733b91c6cb9
Rust
innoave/genevo
/src/selection/tournament.rs
UTF-8
8,567
3.421875
3
[ "Apache-2.0", "MIT" ]
permissive
//! The `tournament` module. //! //! The provided `SelectionOp` implementations are: //! * `TournamentSelector` use crate::{ algorithm::EvaluatedPopulation, genetic::{Fitness, Genotype, Parents}, operator::{GeneticOperator, MultiObjective, SelectionOp, SingleObjective}, random::{random_index, random_pr...
true
57b774a4e0470c339207ac4653500cb4e2a185a5
Rust
miakramer/cpsc-532w-project
/evaluator/src/utilities.rs
UTF-8
871
2.75
3
[]
no_license
use libc::c_double; use num_traits::Float; extern "C" { fn lgamma(x: c_double) -> c_double; } pub trait BasicFloat { fn as_f64(self) -> f64; fn as_f32(self) -> f32; fn to_self_f32(f: f32) -> Self; fn to_self_f64(f: f64) -> Self; } impl BasicFloat for f32 { fn as_f32(self) -> f32 {self} ...
true
612996ef40d769d195aa6c27090c9928bdd3f888
Rust
TheusZer0/ctf-archives
/PlaidCTF/2021/crypto/Proxima_Concursus/src/main.rs
UTF-8
3,068
2.609375
3
[ "MIT" ]
permissive
mod connect4; mod digester; mod secret; mod stories; mod utils; use std::collections::HashMap; use connect4::Connect4; use digester::Digest; use utils::{read, read_line, OrExitWith}; fn main() { println!("{}", stories::INTRO); loop { println!("{}", stories::CHOICE); let choice = read("Choic...
true
a311b99a4074c8be73c31d7849213e9270d77a01
Rust
zthompson47/tokio-uring
/src/io/stdout.rs
UTF-8
464
2.6875
3
[ "MIT" ]
permissive
/* use crate::buf; use crate::driver::Op; use std::io; */ // use std::os::unix::io::RawFd; pub struct Stdout(()); pub fn stdout() -> Stdout { Stdout(()) } // const STDOUT: RawFd = 1; impl Stdout { /* pub async fn write(&self, buf: buf::Slice) -> io::Result<usize> { let op = Op::write_at(STDOUT,...
true
ca3cc8a49dfde703840970b0e11fa41fff37197c
Rust
kinofmat/Rust_Module
/src/main.rs
UTF-8
10,958
3.859375
4
[]
no_license
use std::collections::HashMap; // To allow me to use the hashmap I created with the menu items. /* This function will remove any newline characters or returns that are read in. In this the string is passed by reference. I created this as an example and initially used both remove, and removed, but for convienence I en...
true
73a49bbc2714443b27e4bdac0036a670046b81b9
Rust
MGM103/Rust_Basics
/slices/src/main.rs
UTF-8
547
3.40625
3
[]
no_license
//slice have the format [start..end], where start is the first position //and end is one more than the last position //it does this as end-start is the length of the slice //if the range starts at 0 the first value can be omitted [..end] //vice versa [start..] //also [..] is the entire string //str is the type for a st...
true
33007e8153616488720c33dc4a783f8b14436dda
Rust
kingchazzy/devand
/devand-core/src/string_utils.rs
UTF-8
239
2.984375
3
[ "Apache-2.0" ]
permissive
pub fn trimlow(s: String) -> String { // We help the user, trimming spaces and converting to lowercase let s = s.to_lowercase(); // Note: this allocates a new string, in place trimming does not exist s.trim().to_string() }
true
c0caa70f1a613bc33a92db6085e1b3d369e76b3e
Rust
phyber/adventofcode
/2019/day03/src/main.rs
UTF-8
2,825
3.625
4
[]
no_license
// day03 use std::env; use std::error::Error; use std::fs::File; use std::io::{ self, prelude::*, BufReader, }; // CLI arguments type Args = Vec<String>; // Moves that can be made #[derive(Debug, Clone, PartialEq)] enum Direction { Up(usize), Down(usize), Left(usize), Right(usize), } impl...
true
52d8d51129599d33d6622f968612a0a1f376b357
Rust
nocproject/noc
/rust/agent/src/proto/twamp/server_greeting.rs
UTF-8
6,299
2.65625
3
[ "BSD-3-Clause" ]
permissive
// --------------------------------------------------------------------- // TWAMP Server-Greeting // --------------------------------------------------------------------- // Copyright (C) 2007-2021 The NOC Project // See LICENSE for details // --------------------------------------------------------------------- use s...
true
137c6118473304b6a94eb9dd5e4ef217f813f2dc
Rust
huangqian/rust-in-action
/examples/function-pointer.rs
UTF-8
404
3.5625
4
[]
no_license
pub fn math(op: fn(i32, i32) -> i32, a: i32, b: i32) ->i32{ op(a, b) } fn sum(a: i32, b: i32) -> i32{ a + b } fn product(a: i32, b:i32) -> i32{ a * b } fn is_true() -> bool { true} fn true_maker() -> fn() -> bool {is_true} fn main(){ let a = 2; let b = 3; assert_eq!(math(sum, 2, 3), ...
true
35985f7c7f37f35aec06d0b6d419f618c2524f40
Rust
sam-wright/Advent-of-Code
/2020/day9/src/lib.rs
UTF-8
3,503
3.328125
3
[]
no_license
use std::collections::vec_deque::VecDeque; use std::fs::File; use std::io::Read; pub fn read_input(filename: &str) -> Vec<i64> { let mut contents = String::new(); let mut file = File::open(filename).unwrap(); file.read_to_string(&mut contents).unwrap(); let collection: Vec<i64> = contents.split("\n")....
true
4b510afef448c8d03eb284124ceff0b88e9873f0
Rust
spacejam/seaslug
/src/smt.rs
UTF-8
1,670
2.90625
3
[]
no_license
//! SMT solver based on Dutertre & de Moura's paper //! [A Fast Linear-Arithmetic Solver for DPLL(T)](cav06.pdf). //! //! For cases where z3 is too heavy of a dependency. pub struct Input; pub struct Output; pub fn solve(_: Input) -> Output { todo!() } struct Atom; struct Solver { atoms: Vec<Atom>, } impl ...
true
7eb977d83c93f0e1d72c7d492234586bde9770aa
Rust
SotaWatanabe/ethereum-bridge
/eth-types/src/utils.rs
UTF-8
1,746
2.828125
3
[]
no_license
#![cfg_attr(not(feature = "std"), no_std)] use sp_std::prelude::*; use sp_std::vec; #[macro_export] macro_rules! fixed_hex_bytes_unchecked { ($str:expr, $len:expr) => {{ let mut bytes: [u8; $len] = [0; $len]; let slice = $crate::hex_bytes_unchecked($str); if slice.len() == $len { bytes.copy_from_slice(&slic...
true
6243c99693b39d951b51aa0616dad6fbf82948c5
Rust
lucifer1004/AtCoder
/abc189/src/bin/a.rs
UTF-8
177
2.734375
3
[]
no_license
use proconio::input; use proconio::marker::Chars; fn main() { input! { s: Chars, } println!("{}", if s[0] == s[1] && s[1] == s[2] {"Won"} else {"Lost"}); }
true
af6f9c0725e7d9a6c639f0fcaf3f0017cbc29178
Rust
matklad/once_cell
/tests/it/race_once_box.rs
UTF-8
3,389
3.234375
3
[ "MIT", "Apache-2.0" ]
permissive
#[cfg(feature = "std")] use std::sync::Barrier; use std::sync::{ atomic::{AtomicUsize, Ordering::SeqCst}, Arc, }; use once_cell::race::OnceBox; #[derive(Default)] struct Heap { total: Arc<AtomicUsize>, } #[derive(Debug)] struct Pebble<T> { val: T, total: Arc<AtomicUsize>, } impl<T> Drop for Pebb...
true
75300969424b42f931be992ca06bbc3f97ff1846
Rust
dpchamps/WASMBoi
/src/spec/opcodes/ld.rs
UTF-8
7,263
2.671875
3
[]
no_license
use crate::dasm::InstructionData; use crate::spec::cpu::*; use crate::spec::mmu::MMU; use crate::spec::mnemonic::Mnemonic; use crate::spec::opcode::Instruction; use crate::spec::opcodes::unexpected_op; use crate::spec::register::{RegisterRefMut, TRegister}; use crate::spec::register_ops::RegisterOp; use crate::util::b...
true
652fdda09e5f0ca5342de1edb33a3db28fea5b0f
Rust
mozilla/gecko-dev
/third_party/rust/ffi-support/src/string.rs
UTF-8
7,002
3.1875
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
/* Copyright 2018-2019 Mozilla Foundation * * Licensed under the Apache License (Version 2.0), or the MIT license, * (the "Licenses") at your option. You may not use this file except in * compliance with one of the Licenses. You may obtain copies of the * Licenses at: * * http://www.apache.org/licenses/LICENS...
true
87ef2bab854121e57523b373937640e9117f3e2f
Rust
hr567/Ana
/src/process/cgroup/hierarchy.rs
UTF-8
1,674
2.859375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fs::{read_to_string, write}; use std::io; use std::path::Path; use nix::unistd::Pid; use super::AttrFile; /// Hierarchy in the cgroup. pub trait Hierarchy<'a> { /// The path of this hierarchy. fn path(&self) -> &Path; /// `cgroup.procs` file in this hierarchy. /// /// Can read from and ...
true
e70b47b2d2bfba0a4035033b1c194aff2add7d9a
Rust
akitsu-sanae/verifront
/src/program/domain/boolean.rs
UTF-8
313
3
3
[ "BSL-1.0" ]
permissive
use super::Domain; #[derive(Debug)] pub struct Boolean {} #[derive(Debug)] pub enum ConstSymbol { True, False, } #[derive(Debug)] pub enum OperatorSymbol { And, Or, Not, Equal, } impl Domain for Boolean { type ConstSymbol = ConstSymbol; type OperatorSymbol = OperatorSymbol; }
true
f869c797d9ac69d03e4ddc2f9eca93614549874a
Rust
nathdobson/thread_local_arena
/src/owned_arena.rs
UTF-8
9,631
2.640625
3
[ "Apache-2.0" ]
permissive
use std::cell::UnsafeCell; use alloc::raw_vec::RawVec; use std::mem; use std::cmp; use std::ptr::null_mut; use std::isize; use alloc::allocator::Alloc; use alloc::allocator::Layout; use alloc::allocator::AllocErr; use alloc::allocator::Excess; use alloc::allocator::CannotReallocInPlace; use std::ptr; const INITIAL_BLO...
true
49a0d37540b98417414d871d8d153a62c77a09a8
Rust
oshunter/fuchsia
/third_party/rust_crates/vendor/tokio/src/util/slab/shard.rs
UTF-8
3,704
3.140625
3
[ "MIT", "BSD-3-Clause" ]
permissive
use crate::util::slab::{page, Address, Entry, MAX_PAGES}; use std::fmt; // ┌─────────────┐ ┌────────┐ // │ page 1 │ │ │ // ├─────────────┤ ┌───▶│ next──┼─┐ // │ page 2 │ │ ├────────┤ │ // │ │ │ │XXXXXXXX│ │ // │ local_free──┼─┘ ├────────┤ │ // │ global_free─┼─┐ │ ...
true
0c3ddfe2471e4edbf045af98cb839b0b58815f18
Rust
zellyn/exercism-rust
/nth-prime/src/lib.rs
UTF-8
433
3.234375
3
[ "MIT" ]
permissive
// See https://exercism.io/tracks/rust/exercises/nth-prime/solutions/fc48d015d75c48b5bba6b9a0d923c963 // for a more impressive, lazy-iterator, solution. pub fn nth(n: u32) -> u32 { let mut primes: Vec<u32> = vec![2, 3, 5]; let i = n as usize; let mut nn = 5; while i + 1 >= primes.len() { nn += ...
true
f3f30ea1a33c5397d04ca506bba88eeb78fe34c5
Rust
whentze/raik
/src/lib.rs
UTF-8
3,091
3.109375
3
[]
no_license
#![allow(non_camel_case_types)] use std::fmt; extern crate byteorder; pub mod instruction; #[derive(Debug, Clone)] pub struct Memory { pub data: Vec<u8>, } impl fmt::LowerHex for Memory { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { let bytes_per_line: usize = 32; printl...
true
0695a4f67ac866ab80495896b0cc6bb7cabab23f
Rust
deepinthebuild/cryptopals
/set3/challenge19/src/main.rs
UTF-8
1,998
2.703125
3
[]
no_license
extern crate cryptobuddy; extern crate rustc_serialize; use std::io::BufReader; use std::io::prelude::*; use std::fs::File; use std::str; use rustc_serialize::base64::FromBase64; use cryptobuddy::{stream, utils, freq_analysis}; static DATA_PATH: &'static str = "data/19.txt"; fn load_data() -> Vec<Vec<u8>> { let...
true
e2fc6373b0776aff937ff8d14424e73d6c4c50dc
Rust
shikharvashistha/oak
/experimental/oak_async/tests/dummy_data.rs
UTF-8
1,501
2.765625
3
[ "Apache-2.0" ]
permissive
// // Copyright 2020 The Project Oak Authors // // 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 applicable law o...
true
4bdcbf65d6968f568b6322c36eb86a637e2a65a7
Rust
connorskees/grass
/crates/lib/tests/unary.rs
UTF-8
2,313
2.6875
3
[ "MIT" ]
permissive
#[macro_use] mod macros; test!( unary_pos_unquoted_ident, "a {\n color: +foo;\n}\n", "a {\n color: +foo;\n}\n" ); test!( unary_pos_whitespace, "a {\n color: + foo;\n}\n", "a {\n color: +foo;\n}\n" ); test!( unary_pos_dblquoted_ident, "a {\n color: +\"foo\";\n}\n", "a {\n c...
true
f279a414f60879a020ed00afe7ecd09bcfa1fc48
Rust
knokko/knukki-rs
/src/components/menu/flat/simple/domain.rs
UTF-8
4,774
3.5625
4
[]
no_license
use crate::Point; #[derive(Copy, Clone, Debug)] pub struct ComponentDomain { min_x: f32, min_y: f32, max_x: f32, max_y: f32, } impl ComponentDomain { pub fn between(min_x: f32, min_y: f32, max_x: f32, max_y: f32) -> Self { Self { min_x, min_y, max_x, ...
true
ae1af88ae0a87289dd96b0e7baba5a7fe21e0f83
Rust
sclaire-1/tokio
/tokio/src/net/driver/reactor/dispatch/sharded_slab.rs
UTF-8
9,370
3.0625
3
[ "MIT" ]
permissive
use super::*; use std::fmt; use crate::loom::sync::Mutex; /// A sharded slab. pub(crate) struct Slab { shards: Box<[Shard]>, } /// A slab implemented with a single shard. // TODO(eliza): once worker threads are available, this type will be // unnecessary and can be removed. #[derive(Debug)] pub(crate) struct Sin...
true
97c89c378dd85193b9baed13af6da7b8641570ec
Rust
katharostech/luminance-glow
/src/lib.rs
UTF-8
2,968
2.8125
3
[]
no_license
//! Glow backend for Luminance //! //! This crate provides a [glow] backend for [luminance]. It is capable of targeting desktop using //! OpenGL and web using both WebGL 2 and WebGL 1 ( though WebGL 1 has some caveats such as //! supported texture formats ). //! //! [luminance]: https://crates.io/crates/luminance //! /...
true
a31a2ef027829f94484cc753ccaff18d24bf5ad4
Rust
Gilnaa/rusty3bar
/src/infinite_array.rs
UTF-8
2,109
3.125
3
[ "Apache-2.0" ]
permissive
//! by dtolnay //! A struct used to deserialize an infinite array of JSON objects. use serde::de::DeserializeOwned; use serde_json; use std::io; use std::marker::PhantomData; /// A struct used to deserialize an infinite array of JSON objects of type T, /// coming from stream of type R. pub struct InfiniteArray<R, T>...
true
e2e8d41903f25ad387741424a1a1aefb7d048a15
Rust
feather-rs/feather
/feather/old/server/entity/src/broadcasters/entity_creation.rs
UTF-8
4,744
3.109375
3
[ "Apache-2.0" ]
permissive
use feather_core::entitymeta::EntityMetadata; use feather_core::network::packets::PacketEntityMetadata; use feather_core::util::Position; use feather_server_types::{ CreationPacketCreator, EntitySendEvent, EntitySpawnEvent, Game, Network, NetworkId, PlayerJoinEvent, SpawnPacketCreator, }; use fecs::{IntoQuery, ...
true
3343e677b8066ccab13f51494d8c841ec095850a
Rust
paulcacheux/AdventOfCode2020
/src/day12.rs
UTF-8
5,589
3.5
4
[ "MIT" ]
permissive
use crate::common::AdventResult; #[derive(Debug, Clone, Copy)] enum Direction { North, South, East, West, Left, Right, Forward, } impl Direction { fn get_offsets(self) -> (i32, i32) { match self { Direction::North => (0, -1), Direction::South => (0, 1), ...
true
4d0cff25a282cb1b65f28d806f3749c4283f1b23
Rust
voetsjoeba/aoc2019
/src/day24.rs
UTF-8
14,332
3.015625
3
[]
no_license
// vim: set ai et ts=4 sts=4 sw=4: #![allow(unused)] use std::convert::From; use std::collections::{HashSet, HashMap}; use std::fmt; use crate::util; use crate::dprint::*; #[derive(Clone, PartialEq, Eq, Debug, Hash)] struct Biome(u32); // biome is 5x5, so can be encoded in bits impl Biome { fn bit(n: usize) -> u32...
true
09370d4c35b7ba6a004401f093e68fbade44118f
Rust
LeopoldArkham/Molten
/examples/cargo-add.rs
UTF-8
676
2.515625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
extern crate Molten; use std::io::{Read, Write}; use std::fs::File; use std::error::Error; use Molten::key_value; fn main() { match run() { Err(e) => println!("{}", e), _ => {} } } fn run() -> Result<(), Box<Error>> { let mut buf = String::new(); let mut f = File::open("examples/_...
true
c2261bc7096488b55cb6aa279438be0e4df8b862
Rust
petrSchreiber/advent-of-code-2018-rs
/day_01/src/part01.rs
UTF-8
108
2.671875
3
[]
no_license
pub fn get_frequency(increments: &std::vec::Vec<i32>) -> i32 { increments.into_iter().sum::<i32>() }
true
6ac37f3f4dc63d40c6ec5ce7429ef63e46a96614
Rust
kparkins/learn_rust
/src/calculations.rs
UTF-8
845
3.375
3
[]
no_license
use std::collections::HashMap; pub fn mean(numbers: &Vec<i32>) -> f32 { let sum = numbers.iter().fold(0, |a, b| a + b) as f32; let length = numbers.len() as f32; return sum / length; } pub fn median(numbers: &Vec<i32>) -> f32 { let mut numbers = numbers.clone(); numbers.sort(); let midpoint ...
true
8caf6a61a59821d93b7720a97017dc34e5e12e10
Rust
maxim-h/rust-o-rithms
/haffman_coding_4-2-5/src/binary_tree.rs
UTF-8
2,560
3.59375
4
[]
no_license
use std::boxed::Box; #[derive(Debug, Clone)] pub struct Node { pub ch: Option<char>, pub freq: u32, pub l_0: Option<Box<Node>>, pub r_1: Option<Box<Node>>, } impl Node { fn get_freq<'a>(&'a self) -> &'a u32 { &self.freq } pub fn new( c: Option<char>, f: Option<u32>...
true
c9cd74561b76f1099f01fdd8658c2e4f36319680
Rust
isgasho/dialectic
/dialectic-reconnect/src/maybe_bounded.rs
UTF-8
2,541
3.890625
4
[ "MIT" ]
permissive
//! This module defines two enums, [`Sender`] and [`Receiver`], which wrap either a bounded or //! unbounded Tokio sender or receiver, respectively. //! //! These types implement the subset of the sender/receiver API necessary for this crate, not the //! full API, most of which is not used. use tokio::sync::mpsc::{ ...
true
cd89c675de0c65b66bbc632507eb04d3804e4767
Rust
microrack/coresynth
/fw/rust_lib/src/os/cmsis_os/semaphore.rs
UTF-8
1,885
2.78125
3
[]
no_license
pub use super::bindings::osSemaphoreId; use super::bindings::*; use super::{Error, Result}; pub struct Semaphore { id: osSemaphoreId, } #[allow(dead_code)] impl Semaphore { pub fn new(count: u32) -> Result<Semaphore> { assert!(count <= core::i32::MAX as u32); let semaphore_def = osSemaphoreDef...
true
2134d38fad938a7092de942a9188e918fd15472f
Rust
Kurble/Tutris9
/client/src/main.rs
UTF-8
4,542
2.71875
3
[ "MIT" ]
permissive
mod game; mod menu; mod matchmaking; mod util; mod connection; mod controls; mod buttons; mod persistent; mod stats; use quicksilver::{ Result, geom::{Transform, Vector}, graphics::{Color, Background::Col}, lifecycle::{Settings, State, Window, Event, run}, combinators::Future, }; use futures::Async...
true
a315ba20d485dd86a8de8132e7f8172b07feb0f5
Rust
rust-lang/rust
/tests/ui/pattern/issue-106862.rs
UTF-8
992
2.90625
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
// run-rustfix #![allow(unused)] use Foo::{FooB, FooA}; enum Foo { FooA { opt_x: Option<i32>, y: i32 }, FooB { x: i32, y: i32 } } fn main() { let f = FooB { x: 3, y: 4 }; match f { FooB(a, b) => println!("{} {}", a, b), //~^ ERROR expected tuple struct or tuple variant, found varian...
true
09756322cc7ef81fa7f80b56c9d73ae2323c902d
Rust
m00p1ng/kattis-problem
/LV1/1.2/autori/autori.rs
UTF-8
289
2.828125
3
[]
no_license
use std::io::{self, BufRead}; fn main() { let mut buff = String::new(); let stdin = io::stdin(); stdin.lock().read_line(&mut buff).unwrap(); let words: Vec<&str> = buff.split("-").collect(); for w in words { print!("{}", w.chars().nth(0).unwrap()); } }
true
8880be76de121ca62d85176bdf9809d58d6efbea
Rust
Phaiax/emotim
/src/lib.rs
UTF-8
4,964
3
3
[]
no_license
//! Converts normal images into emoticon versions by replacing chunks of the //! original image with emoticons of similar color. //! //! ``` //! use std::path::Path; //! use emotim::*; //! let emos = read_emoticons(); //! let mut ii = read_input_image("Munch_Schrei_6.jpg"); //! let emoimg = Emoimage...
true
99bd6ca13601051d6e59aa5468aa92a204283382
Rust
Byron/gitoxide
/gix-ref/src/store/packed/decode.rs
UTF-8
2,098
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::convert::TryInto; use gix_object::bstr::{BStr, ByteSlice}; use winnow::{ combinator::{delimited, opt, preceded, terminated}, error::{FromExternalError, ParserError}, prelude::*, token::take_while, }; use crate::{ parse::{hex_hash, newline}, store_impl::packed, }; #[derive(Debug, Part...
true
0c685c9cd3c4ddf6368ef00f495a21b54b43063c
Rust
e14tech/rmonopoly
/src/main.rs
UTF-8
607
2.765625
3
[ "BSD-2-Clause" ]
permissive
extern crate rand; mod input; mod dice; mod player; mod jail; mod game; use player::Player; fn main() { let number_of_players = input::get_number_of_players(); let mut players: Vec<Player> = Vec::new(); for i in 0..number_of_players { let player_name = input::get_player_name(i); player...
true
2027b07d9680e504c0f56884fac1cd088c1f867b
Rust
sshashank124/zapp
/src/filesystem.rs
UTF-8
1,165
2.78125
3
[]
no_license
use std::fs::{self, Permissions}; use std::io; use std::os::unix::fs::PermissionsExt; use std::path::{Path, PathBuf}; use serde::{Deserialize, Deserializer, de::Error}; pub fn expand_path(path: &str) -> PathBuf { let path = shellexpand::tilde(path); PathBuf::from(&*path) } pub fn create_valid_parent(path: ...
true
2191eb51a7e25c11b26629bf9f289147b08a39d1
Rust
attilahorvath/exercism-rust
/etl/src/lib.rs
UTF-8
319
2.625
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; pub fn transform(input: &BTreeMap<i32, Vec<char>>) -> BTreeMap<char, i32> { input .iter() .flat_map(|(&score, chars)| { chars.iter().flat_map(|&c| c.to_lowercase()).map(move |c| { (c, score) }) }) .collect() }
true
3604042df8dcf69c873233727bc378f1715145da
Rust
doytsujin/genawaiter
/src/lib.rs
UTF-8
7,759
3.9375
4
[]
no_license
/*! This crate implements generators for Rust. Generators are a feature common across many programming language. They let you yield a sequence of values from a function. A few common use cases are: - Easily building iterators. - Avoiding allocating a list for a function which returns multiple values. Rust has this fe...
true
aed74ffe9d495c8335e4b0df76bef40cd7d1b8e6
Rust
samsung-ads-grave-yard/mini-rs
/src/aio/http.rs
UTF-8
7,983
2.71875
3
[ "MIT" ]
permissive
// TODO: make a web crawler example. use std::cell::RefCell; use std::collections::VecDeque; use std::fmt::Debug; use std::io; use std::mem; use std::rc::Rc; use crate::aio::handler::{ Handler, Loop, Stream, }; use crate::aio::net::{ TcpConnection, TcpConnectionNotify, }; use crate::aio::uhttp_uri...
true
201c9ccf25ef2cfc4cf355e9ccc7df4dd42c077e
Rust
lapce/lapce
/lapce-app/src/keypress/press.rs
UTF-8
3,415
3.0625
3
[ "CC-BY-4.0", "Apache-2.0", "LicenseRef-scancode-free-unknown" ]
permissive
use std::fmt::Display; use floem::keyboard::{Key, ModifiersState}; use tracing::warn; use super::key::KeyInput; #[derive(Clone, Debug, PartialEq, Eq, Hash)] pub struct KeyPress { pub(super) key: KeyInput, pub(super) mods: ModifiersState, } impl KeyPress { pub fn to_lowercase(&self) -> Self { let...
true
97434b08dd309063de545581ee779c05103af7c9
Rust
amling/rlagar
/src/misc.rs
UTF-8
464
2.796875
3
[]
no_license
use chrono::Local; pub fn debug_log(msg: impl AsRef<str>) { let msg = msg.as_ref(); eprintln!("{} - {}", Local::now().format("%Y%m%d %H:%M:%S"), msg); } pub fn debug_time<T>(label: impl AsRef<str>, cb: impl FnOnce() -> T) -> T { let label = label.as_ref(); let t0 = std::time::Instant::now(); debug...
true
d2c4f87bdc7c92f7be6a816e4d6334ece2eed28e
Rust
ricky26/advent-of-code-2020
/src/bags.rs
UTF-8
3,190
3.078125
3
[]
no_license
use nom::{ IResult, character::complete::{space0, digit1, alpha1, space1, char}, bytes::complete::{tag}, combinator::{opt, recognize, map}, sequence::{pair, tuple}, multi::separated_list1, branch::alt, }; use std::collections::BTreeMap; fn skip_whitespace(input: &str) -> &str { space0::...
true
1173f51bda18c6b426f9696330524633cfc15a42
Rust
Corallus-Caninus/windows-rs
/crates/tests/winrt/enums/tests/test.rs
UTF-8
800
3.1875
3
[]
no_license
use test_winrt_enums::*; use Component::Enums::*; #[test] fn signed() { let value = Signed::One; assert!(value.0 == 1i32); let value = Signed::Two; assert!(value.0 == 2i32); let value = Signed::Three; assert!(value.0 == 3i32); let value: Signed = 2i32.into(); assert!(value == Signed:...
true
277b3b836b4f94d09c136a555dcbf56d77500f1a
Rust
mapx/leetcode-rust
/src/util/union_find.rs
UTF-8
1,448
3.1875
3
[ "MIT" ]
permissive
use std::mem; use std::usize; pub struct UnionFind { weights: Vec<usize>, groups: Vec<usize>, } impl UnionFind { pub fn new(size: usize) -> UnionFind { let mut groups = Vec::with_capacity(size); for i in 0..size { groups.push(i); } UnionFind { weight...
true
972d85dc38fb829c1535778447f3a169e142b0f1
Rust
rbartlensky/Lua-interpreter
/luavm/src/lib/instructions/arithmetic_operators.rs
UTF-8
1,199
3.40625
3
[]
no_license
use errors::LuaError; use luacompiler::bytecode::instructions::{first_arg, second_arg, third_arg}; use Vm; /// Generates a function called `$op`, which takes two parameters: a mutable reference to a /// vm and an instruction, and returns whether the instruction is executed succesfully /// or not by the vm. This macro ...
true
3e0e927cf27229ee67fb36c7daaf3dbe0a05e799
Rust
tomaka/futures-rs
/tests/stream.rs
UTF-8
8,216
2.875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
extern crate futures; use futures::{failed, finished, Future, promise}; use futures::stream::*; mod support; use support::*; // #[test] // fn smoke() { // let (tx, rx) = channel::<i32, u32>(); // tx.send(Ok(1)) // .and_then(|tx| tx.send(Ok(2))) // .and_then(|tx| tx.send(Ok(3))) // .schedule...
true
41af863287ff14e47de576869f1bf0ead356ac1f
Rust
agmcleod/adventofcode-2016
/22/src/main.rs
UTF-8
10,083
2.984375
3
[]
no_license
extern crate regex; extern crate read_input; use std::collections::{HashMap, HashSet}; use regex::Regex; #[derive(Debug)] struct Node { coords: String, size: usize, used: usize, avail: usize, coords_as_num: [usize; 2], } impl Clone for Node { fn clone(&self) -> Node { Node{ ...
true
312a402520eea2df867df6c891551c5165dac170
Rust
jonnyom/Exercism-exercises
/rust/bob/src/lib.rs
UTF-8
509
3.5
4
[]
no_license
pub fn reply(message: &str) -> &str { match message.trim() { x if x.is_empty() => "Fine. Be that way!", x if x.ends_with("?") => match x { x if is_uppercase(x) => "Calm down, I know what I'm doing!", _ => "Sure.", }, x if is_uppercase(x) => "Whoa, chill out!",...
true
bb808ca9e91b05f337c0016fcd968a07ea8d7900
Rust
akimash/abc
/90/c.rs
UTF-8
698
3.265625
3
[]
no_license
use std::io::*; use std::str::FromStr; pub fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) ...
true
bae4a9411fa46e5001026bdb2731b28be0753758
Rust
sighttviewliu/grin
/wallet/src/display.rs
UTF-8
3,352
2.53125
3
[ "Apache-2.0" ]
permissive
// Copyright 2018 The Grin Developers // // 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 applicable law or agree...
true
ce7b025efd2feca0e08e51abbba7f93217f2f2c9
Rust
kod-kristoff/bevy_ascii_terminal
/src/render/renderer_tile_data.rs
UTF-8
2,341
3.1875
3
[ "MIT" ]
permissive
use bevy::math::{UVec2, Vec2}; use crate::terminal::Tile; use super::glyph_mapping::GlyphMapping; #[derive(Default)] pub struct TerminalRendererTileData { //pub fg_colors: Vec<[f32; 4]>, //pub bg_colors: Vec<[f32; 4]>, pub fg_colors: Vec<[u8; 4]>, pub bg_colors: Vec<[u8; 4]>, pub uvs: Vec<[f32; 2...
true
c73bdf876cabb8bed4640295aeae3554673498d1
Rust
5mattmatt1/voxport
/src/main.rs
UTF-8
20,984
2.796875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
extern crate collada_io; // Export extern crate clap; // CLI extern crate dot_vox; // Import extern crate stl_io; // Export pub mod app; const INPUT_FILEPATH: &'static str = "input.vox"; const OUTPUT_STL_FILEPATH: &'static str = "output.stl"; const OUTPUT_DAE_FILEPATH: &'static str = "output.dae"; const _OUTPUT_PAL_F...
true
5defcb3ce16f1f41efee202e17fadfe1d23ffe44
Rust
jakeisnt/rustlings-implementation
/exercises/primitive_types/primitive_types4.rs
UTF-8
441
3.8125
4
[ "MIT" ]
permissive
// primitive_types4.rs // Get a slice out of Array a where the ??? is so that the test passes. // Execute `rustlings hint primitive_types4` for hints!! #[test] fn slice_out_of_array() { let a = [1, 2, 3, 4, 5]; // Need & to borrow the reference, which allows us to take a slice of it. // Without '&', it's ...
true
6bd1cbacdd799a555c99a79c4d3ddafe8f9f0242
Rust
SymmetricChaos/project_euler_rust
/src/aux_funcs.rs
UTF-8
8,379
3.3125
3
[]
no_license
use std::fmt::Debug; use std::convert::TryFrom; use std::collections::HashMap; use mod_exp::mod_exp; use num::traits::{Unsigned,Zero,ToPrimitive}; use std::cmp::max; pub fn int_to_digits<T: Unsigned + Zero + ToPrimitive + Clone>(n: T, base: T) -> Vec<u8> { if n == T::zero() { return vec![0u8] } let...
true
a9421c6e7aef50f1ce5aa3f9f93abd6345c958ba
Rust
eldruin/driver-examples
/stm32f1-bluepill/examples/mcp4921-ads1115-display-bp.rs
UTF-8
4,760
2.578125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Loop setting a position from 0 to 4095 to the channel 0 of a MCP4921 //! digital-to-analog converter. //! The voltage output of the MCP4921 device will then be measured by the //! ADS1115 analog-to-digital converter and will be printed to the //! SSD1306 OLED display. //! //! This example is runs on the STM32F103 "...
true
2cf32e6c548fcbacc16ca9a0d5de9eb626bed9e4
Rust
chop0/aardvark-rust
/src/error.rs
UTF-8
539
2.640625
3
[]
no_license
use crate::var::AardvarkValue; use std::error::Error; use std::fmt; #[derive(Debug)] pub enum AardvarkError { Return(Box<dyn AardvarkValue>), Other(String) } impl fmt::Display for AardvarkError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { AardvarkError::Ret...
true
0f9c69555c80847f6c40f1b72cd8a2110a6d8535
Rust
naomijub/atm-crux
/src/ui/mod.rs
UTF-8
5,905
2.796875
3
[]
no_license
mod login_input; mod menu; mod operation_input; mod result_pages; use iced::{button, text_input, Align, Column, Container, Element, Length, Sandbox, Text}; use crate::db::{create_account, deposit, statement, withdraw}; use login_input as login; use menu::Menu; use operation_input as op; use result_pages as pages; use...
true
14e8fc7c1551ab71636e4f63de790de45c1de6cf
Rust
doitian/ckb
/sync/src/utils.rs
UTF-8
3,521
2.890625
3
[ "MIT" ]
permissive
use crate::{Status, StatusCode}; use ckb_error::{Error as CKBError, ErrorKind, InternalError, InternalErrorKind}; use ckb_metrics::metrics; use ckb_network::{CKBProtocolContext, PeerIndex, ProtocolId, SupportProtocols}; use ckb_types::packed::{RelayMessageReader, SyncMessageReader}; use ckb_types::prelude::*; /// Send...
true
2f644452416649770d500e5a3284dd4e5238c5e2
Rust
doytsujin/teloc
/teloc/src/service_provider.rs
UTF-8
13,561
3.1875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use crate::container::{ ConvertContainer, Init, InstanceContainer, SingletonContainer, TransientContainer, }; use crate::scope::{InitScoped, ScopedContainerElem, ScopedInstanceContainer}; use crate::Scope; use frunk::hlist::{HList, Selector}; use frunk::{HCons, HNil}; use std::marker::PhantomData; /// `ServiceProv...
true
06288adb928b419a8123d7870118181b1015241e
Rust
Tubbz-alt/lrad
/lrad-lib/src/docker.rs
UTF-8
8,958
2.671875
3
[ "MIT" ]
permissive
use actix_web::{client, HttpMessage}; use futures::prelude::*; use git2::Repository; use percent_encoding::{utf8_percent_encode, QUERY_ENCODE_SET}; use std::collections::HashMap; use tar::Builder; use tokio_uds::UnixStream; use crate::error::Error; use crate::vcs::VcsError; use std::time::Duration; pub fn build_imag...
true
57ab4d341540e8aa8de7b0079cf2eab84824bf38
Rust
gilescope/wasm-tools
/crates/wasm-encoder/src/tables.rs
UTF-8
2,194
3.515625
4
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LLVM-exception" ]
permissive
use super::*; /// An encoder for the table section. /// /// # Example /// /// ``` /// use wasm_encoder::{Module, TableSection, TableType, ValType}; /// /// let mut tables = TableSection::new(); /// tables.table(TableType { /// element_type: ValType::FuncRef, /// minimum: 128, /// maximum: None, /// }); ///...
true
8f91ba10e2dbdfe3a85dcbb9d2142b783072860a
Rust
01intelligence/hulk
/src/strset/mod.rs
UTF-8
15,197
3.171875
3
[ "Apache-2.0" ]
permissive
use std::collections::HashSet; use std::fmt; use serde::de::{self, Deserialize, Deserializer, SeqAccess, Visitor}; use serde::ser::{Serialize, SerializeSeq, Serializer}; #[derive(PartialEq, Eq, Clone, Debug)] pub struct StringSet(HashSet<String>); impl StringSet { pub fn new() -> StringSet { StringSet(Ha...
true
7041c3d78c985b63ea817df2b405b5b074a5022c
Rust
naru2001/learn-Rust
/hello/src/lifetime.rs
UTF-8
183
3.5625
4
[]
no_license
fn main(){ let y; { let x=5; // x~ y=&x; // y~ dbg!(x); // ~x } dbg!(y); // ~y(xのライフタイムを超えることはできない) }
true
9b4bf4c4cfa2bdd618cfba6c8b9cffe7c456f60c
Rust
oxalica/nil
/crates/ide/src/ide/assists/convert_to_inherit.rs
UTF-8
5,776
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
//! Convert `path = value;` into `inherit key;`. //! This covers, //! - `prefix.key = key;` => `prefix = { inherit key; };` //! Here the `prefix` set mut not be `rec`. The code before is actually //! an infinite recursion while the code after is not. //! - `prefix.key = from.key;` => `prefix = [rec] { inherit (from...
true
99f3f1835421ee0f6ab0090d014fa1867d4bbeff
Rust
xartyx/flavours
/src/operations/apply.rs
UTF-8
10,594
2.65625
3
[ "MIT" ]
permissive
use anyhow::{anyhow, Context, Result}; use rand::seq::SliceRandom; use std::fs; use std::io::{self, Read}; use std::path; use std::process; use std::str; use std::thread; use crate::config::Config; use crate::find::find; use crate::operations::build::build_template; use crate::scheme::Scheme; /// Picks a random path,...
true