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
6b273f6b1a83e7def9bd3d3beb49248531ac7bc5
Rust
gitter-badger/rsrl
/src/agents/control/actor_critic.rs
UTF-8
1,895
2.71875
3
[ "MIT" ]
permissive
use Parameter; use agents::{ControlAgent, PredictionAgent}; use domains::Transition; use fa::QFunction; use geometry::{Space, ActionSpace}; use policies::{Policy, Greedy}; use std::marker::PhantomData; /// Regular gradient descent actor critic. pub struct ActorCritic<S: Space, Q, C, P> where Q: QFunction<S>, ...
true
4ea7b44a7cc6e2b1064ac905e118b5d2e3c0ad8c
Rust
sportelliluciano/g8-dinero-oxidado
/src/logger.rs
UTF-8
1,751
3.453125
3
[]
no_license
use std::{ fs::File, io::prelude::*, sync::{Arc, Mutex}, time::{Duration, Instant} }; pub struct Logger { file: Option<Mutex<File>>, timer: Instant } impl Logger { pub fn new_to_stdout() -> Self { Self { file: None, timer: Instant::now() } } pub fn new_to_file(path: &st...
true
229bbff13ae44660a2c691e1090d4cdfc721b245
Rust
hershi/AdeventOfCode2017
/aoc_7/src/main.rs
UTF-8
2,445
3.234375
3
[]
no_license
extern crate regex; use std::iter::repeat; use std::io::prelude::*; use std::io::BufReader; use std::fs::File; use std::collections::HashMap; use regex::Regex; #[derive(Debug)] struct InputRecord { name: String, weight: u32, children: Vec<String>, } impl InputRecord { fn new(name: String, weight: u32...
true
ce6539fd868f22463b512e67c180fe56a41e8851
Rust
Thaddeus19/rust-programming
/router/src/lib.rs
UTF-8
2,409
3.59375
4
[]
no_license
use std::collections::HashMap; use std::rc::Rc; pub struct Request { method: String, url: String, headers: HashMap<String, String>, body: Vec<u8>, } pub struct Response { code: u32, headers: HashMap<String, String>, body: Vec<u8>, } type BoxedCallback = Box<Fn(&Request) -> Response>; pub...
true
3f90f700ab7dba62580c296687df4b4601bb7b71
Rust
elexing/pagination
/src/lib.rs
UTF-8
2,507
3.375
3
[ "MIT", "Apache-2.0" ]
permissive
//! 分页库一共包含3个分页请求模型:`PageParam`,`PageRequest` 和 `OffsetRequest`. 一般情况下, `PageRequest` //! 和`PageParam`应该是来自于客户端或者外部的模型; 在内部,当求请求数据库时,通过`PageRequest.into_offset`将其转 //! 换成`OffsetRequest`. //! //! Usage : //! ``` rust //! use pagination::{ //! PageParams, //! OffsetParams, //! DefaultIntoOffset //! }; //! let page_par...
true
90398e8ab3b6d79466e2cfe4fdd39b68e79068d3
Rust
nyarly/gotham
/middleware/diesel/src/state_data.rs
UTF-8
1,540
3.078125
3
[ "MIT", "Apache-2.0" ]
permissive
//! Defines data structure for storage in Gotham State that provides access to the underlying r2d2 //! pool so a connection can be established if required by Middleware or Handlers. use diesel::Connection; use r2d2::{Error, Pool, PooledConnection}; use r2d2_diesel::ConnectionManager; use gotham; use gotham::state::{F...
true
bebc63d963d5d4d6f90cc113e8aa1dd6ba143f23
Rust
scottlamb/rtsp-types
/src/headers/content_length.rs
UTF-8
1,688
2.765625
3
[ "MIT" ]
permissive
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com> // // Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT> use super::*; /// `Content-Length` header ([RFC 7826 section 18.17](https://tools.ietf.org/html/rfc7826#section-18.17)). #[derive(Debug, Clone, Copy, Par...
true
875c1b6cea03cb4c0d41858eb0b9bffa0f7f81a2
Rust
vegtamr-ab/queueing-system
/src/queueing_system/analytics.rs
UTF-8
2,884
2.78125
3
[]
no_license
use super::simulation::*; use super::statistics::*; use super::types::*; fn get_student_value(cl: ConfidenceLevel) -> f64 { match cl { ConfidenceLevel::Standard => 1.6649, ConfidenceLevel::High => 1.96, ConfidenceLevel::VeryHigh => 2.5758, } } fn number_of_entries(cl: ConfidenceLevel, ...
true
498f0add55f5e4aa55ea1587385c2f1146307987
Rust
h-hirai/MyRecordOfAtCoder
/ABC097/d_equals.rs
UTF-8
1,925
3.640625
4
[]
no_license
struct UnionFindTree { par: Vec<usize>, } impl UnionFindTree { fn new(n: usize) -> UnionFindTree { UnionFindTree { par: (0..n).collect(), } } fn root(&mut self, x: usize) -> usize { let p = self.par[x]; if p == x { x } else { ...
true
da16d54ff1182b7bd6cc129c5e7f59031c14f47f
Rust
d-plaindoux/rust-traits
/example/src/lib.rs
UTF-8
2,107
3.796875
4
[ "Apache-2.0" ]
permissive
#[allow(dead_code)] struct MyStruct { source: String, } trait MyTrait { fn my_trait(source: String) -> Self; fn description(&self) -> String; } impl MyTrait for MyStruct { fn my_trait(source: String) -> Self { // Self ≡ MyStruct MyStruct { source } } fn description(&self) -> ...
true
684e15dcbddc2fa9d8bba3d684d8ddf3a06114e8
Rust
h3nnn4n/Apothema
/src/cube/benchmarks.rs
UTF-8
1,867
2.765625
3
[]
no_license
use super::{get_random_move, Cube, Move}; use std::time::Instant; const MOVE_GRANULARITY: u64 = 1000; const TIME_GRANULARITY: f64 = 0.5; const N_REPS: u32 = 5; pub fn fixed_move_per_sec() -> u64 { let mut total_move_count = 0; let mut total_elapsed_time = 0; for _ in 0..N_REPS { let start_time = ...
true
22bf262cb0a9a747545744756f1016e331a582e3
Rust
Cykooz/tank_war
/src/scenes/main_menu.rs
UTF-8
2,761
2.6875
3
[ "MIT" ]
permissive
use std::cmp::min; use ggez; use ggez::graphics::Color; use ggez::{event, graphics}; use ggez_goodies::scene; use crate::input; use crate::scenes; use crate::types::Point2; use crate::world::World; #[derive(Debug, PartialEq, Eq, Clone, Copy)] enum MenuItem { Play, Quit, } const MENU_ITEMS: [(MenuItem, &str)...
true
9418ed7764894b1cfa16267363803de08a7bf83f
Rust
PragmaTwice/ichigo-lang
/src/preprocess/unicode_coverter.rs
UTF-8
969
2.875
3
[ "Apache-2.0" ]
permissive
use super::unicode_symbols::UNICODE_SYMBOLS; use lazy_static::lazy_static; use regex::Regex; pub fn convert(input: &str) -> Result<String, String> { lazy_static! { static ref UNICODE_SYMBOL_MATCHER: Regex = Regex::new(r"\\([A-Za-z0-9_^+\-]*)").unwrap(); } let mut current_pos = 0usize; let mut ...
true
4692f4309fb873302a7ab869995a9c84d11fbd1e
Rust
sharkbound/rust-projects
/pattern_matching_examples/src/main.rs
UTF-8
2,368
3.921875
4
[ "MIT" ]
permissive
/// /// video resource: /// https://www.youtube.com/watch?v=8_HPKGZGM5I /// fn main() {} fn if_inline_if_pattern_matching() { // inline w/ if statement let value = Some(9); if let Some(val2) = value { // code here if VALUE is Some(val2) } else { // code here if VALUE is None } } f...
true
d2dc65c1a8035dd2f433920e7eb5de3de308a67f
Rust
yeslogic/allsorts
/src/tag.rs
UTF-8
10,181
3.484375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Utilities and constants for OpenType tags. //! //! See also the [`tag!`](../macro.tag.html) macro for creating tags from a byte string. use crate::error::ParseError; use std::{fmt, str}; /// Generate a 4-byte OpenType tag from byte string /// /// Example: /// /// ``` /// use allsorts::tag; /// assert_eq!(tag!(b"g...
true
5d38f2d0f203dc6d22e8c0190a981346cb377464
Rust
barollet/Discord-Go-game-manager
/src/challenge.rs
UTF-8
3,258
3.21875
3
[]
no_license
use std::collections::HashMap; use serenity::model::id::UserId; use serenity::prelude::*; use crate::game::GameInfo; // A hashmap with a list of current challenges (two instance per challenge) #[derive(Default)] pub struct ChallengeList(HashMap<UserId, Vec<UserId>>); impl ChallengeList { // Add the correspondin...
true
fcddd35ab37036ef187ba82a0c88d2ed9f07fd23
Rust
MAIF/otoroshi
/tools/otoroshi-remote-tunnel-agent/src/otoroshi.rs
UTF-8
7,938
2.71875
3
[ "Apache-2.0" ]
permissive
use base64::{encode}; use hyper::{Method, Request, Client}; use serde::{Deserialize, Serialize}; use hyper_tls::HttpsConnector; use crate::opts::Opts; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct OtoroshInfos { pub domain: String, pub scheme: String, pub exposed_port_http: i16, pub expo...
true
a240fff445557451418ea130381c0e739e2ed16f
Rust
Catamondium/projects
/Rust/mol/src/main.rs
UTF-8
431
2.65625
3
[ "Unlicense" ]
permissive
use mol::{mass, normalize}; use std::{env, process}; fn main() { let args: Vec<String> = env::args().skip(1).collect(); for dirty in args { let clean = normalize(dirty); match mass(&clean) { Ok(m) => { println!("{}: {} g/mol", clean, m); } Err...
true
f27e39a0a5454817e1801a0c4f8919d11a36ff23
Rust
omid/gitversion
/src/versioning/semver.rs
UTF-8
1,639
2.765625
3
[ "MIT" ]
permissive
use crate::{ config::{Config, Type}, versioning::Versioning, }; use git2::Repository; use regex::Regex; use semver::Version; pub struct Semver {} impl Versioning for Semver { fn current_version(config: &mut Config) -> String { let repo = Repository::open(config.dir) .map_err(|e| format...
true
b50f39d393f272e40cd58d8c392ad3c09a90e0bb
Rust
peppizza/songbird
/src/input/codec/opus.rs
UTF-8
1,515
2.875
3
[ "ISC" ]
permissive
use crate::constants::*; use audiopus::{coder::Decoder as OpusDecoder, Channels, Error as OpusError}; use parking_lot::Mutex; use std::sync::Arc; #[derive(Clone, Debug)] /// Inner state used to decode Opus input sources. pub struct OpusDecoderState { /// Inner decoder used to convert opus frames into a stream of s...
true
c2ce02764a8a58580272c1be15932decd95bbd69
Rust
ciuncan/hackerrank-solutions
/src/warmup_challenges/jumping_on_the_clouds/mod.rs
UTF-8
2,848
3.46875
3
[ "MIT" ]
permissive
use crate::lib; /// Solution for: /// https://www.hackerrank.com/challenges/jumping-on-the-clouds/problem #[allow(dead_code)] pub fn main() { let clouds: Vec<Cloud> = lib::parse_two_line_input(); let total_jumps = calculate_total_jumps(&clouds); println!("{:}", total_jumps); } use crate::enum_per_char;...
true
8d535f4bc92ffb723440b53f9ec573d079431cbb
Rust
Kuzirashi/godwoken
/crates/common/src/state.rs
UTF-8
8,541
2.734375
3
[ "MIT" ]
permissive
//! State // the State keeps consistent interface upon lower storage structure (SMT or other trees). // // Key domain: // // The account and some special values used in the Godwoken are persisted in the state kv storage. // We serperate these keys into different key domains. // // Any `key` in the State must be convert...
true
379e7eeda4c1bed119e252f5e62b93284ce3d1b5
Rust
acw/cryptonum
/src/signed/base.rs
UTF-8
5,592
2.9375
3
[ "ISC" ]
permissive
macro_rules! signed_impls { ($sname: ident, $name: ident) => { #[derive(Clone, PartialEq, Eq)] pub struct $sname { negative: bool, value: $name } impl $sname { /// Generate a new signed number from an unsigned number and a /// boolean ...
true
e1bf6782578fea645a981f70f6045bb8e3783eb3
Rust
shakyShane/wf2
/env_proc/tests/test.rs
UTF-8
2,041
2.53125
3
[]
no_license
#[macro_use] extern crate serde_derive; extern crate serde; use env_proc::env_vars; use std::collections::BTreeMap; env_vars! { HOST_UID="501" HOST_GID="20" MAGE_ROOT_DIR="/var/www" MAGE_HOST="https://local.m2" MAGE_ADMIN_USER="admin" MAGE_ADMIN_PASS="password123" MAGE_ADMIN_FIRSTNAME="Jo...
true
b26a2f0c9f1adc32b4a45a82a824d9eda471d8a1
Rust
swilcox3/flexi-cad
/ui/data-model-wasm/src/lib.rs
UTF-8
7,189
2.65625
3
[]
no_license
#![allow(non_snake_case)] extern crate data_model; extern crate wasm_bindgen; #[macro_use] extern crate serde_json; use data_model::*; use wasm_bindgen::prelude::*; // This is like the `main` function, except for JavaScript. #[wasm_bindgen(start)] pub fn main_js() -> Result<(), JsValue> { console_error_panic_hook...
true
d93d1be2e57f57b8480e4ea7f0d7217d29f4e93b
Rust
Mulyu/rust-syn-flood
/src/main.rs
UTF-8
1,301
2.640625
3
[]
no_license
use pnet; use pnet::datalink::channel; use pnet::datalink::Channel::Ethernet; use pnet::datalink::Config; use pnet::datalink::interfaces; use pnet::packet::ipv4::MutableIpv4Packet; use pnet::packet::tcp::{MutableTcpPacket, TcpFlags}; use rand::Rng; use std::net::Ipv4Addr; const IPV4_HEADER_LEN: usize = 20; const TCP_H...
true
127115daba69311aa09ea40fa98cdcc806b62324
Rust
yueguanyu/mikudos-rust-app
/src/my_mod/traits.rs
UTF-8
558
3.78125
4
[ "MIT" ]
permissive
// 接口 pub trait Area { fn area(&self) -> f64; } pub trait Factory { fn test() -> i32; } // 具体类 pub struct Circle { pub r: f64, } // 让【具体类】实现【接口】 impl Area for Circle { fn area(&self) -> f64 { std::f64::consts::PI * self.r // 作为返回值 => 必须使用 () 括起来,并不能写 ; } } impl Circle { pub fn new(r:...
true
9ceb1114dc7bca2b259a9d36c36ead4088a8f6cc
Rust
TheDan64/daily-quote
/backend/src/main.rs
UTF-8
3,380
2.609375
3
[ "Apache-2.0" ]
permissive
#![feature(proc_macro)] #![feature(plugin)] #![plugin(docopt_macros)] #[macro_use] extern crate diesel; #[macro_use] extern crate diesel_codegen; extern crate docopt; extern crate dotenv; #[macro_use] extern crate lazy_static; extern crate rand; extern crate regex; extern crate rustc_serialize; pub mod counts; pub mod...
true
36e99a8333bf24c41ef8e9126598979337100f56
Rust
TimWSpence/rust-playground
/src/show.rs
UTF-8
413
3.546875
4
[]
no_license
pub trait Show { fn show(&self) -> String; } impl Show for String { fn show(&self) -> String { self.to_string() } } impl <T: Show> Show for [T] { fn show(&self) -> String { let mut temp = self.into_iter().map(|x| x.show()).fold("".to_string(), |mut acc, x| {acc.push_str(x.as_str()); a...
true
095a7847ab0960c8670ad5c4888550cb5c4d91c0
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/abc197/src/bin/c.rs
UTF-8
771
2.9375
3
[]
no_license
use std::cmp::min; use proconio::input; fn main() { input! { n: usize, a: [u64; n], }; let mut ans = 0_u64; for &a_i in a.iter() { ans |= a_i; } for bits in 0..1 << (n - 1) { let mut is = vec![]; for i in 0..(n - 1) { is.push((bits >> i) & 1 ...
true
f1273b2cc00885ac5e9c45e1dcd0dc5e198ccf2e
Rust
thibault-martinez/bee
/bee-crypto/src/ternary/bigint/t242/mod.rs
UTF-8
4,858
2.828125
3
[ "Apache-2.0" ]
permissive
// Copyright 2020-2021 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 //! This module contains logic to convert an integer encoded by 242 trits to the same integer encoded by 384 bits (or 48 //! signed bytes, `i8`). //! //! At the core of this a slice of binary-coded, balanced trits is interpreted fanned-out `t2...
true
c596c452d360c7c8b024e626cab02b2c81324d29
Rust
SuperHuangXu/learn-rust
/RBE-fn/src/main.rs
UTF-8
3,669
4.1875
4
[]
no_license
use std::mem; use std::ops::Deref; struct Rectangle { x: f64, y: f64, } impl Rectangle { // `&self` 是 `self: &Self` 的语法糖,其中 `Self` 是方法调用者的类型。这里 `Self` == `Rectangle` fn area(&self) -> f64 { self.x * self.y } // 这个方法要求调用者是可变的 // `&mut self` 为 `self: &mut Self` 的语法糖 fn translate(...
true
24cbe4bf109ba0b7d0107b6b2f91be952234cc56
Rust
victoryang00/Delight
/delight_book/benches/chapter16.rs
UTF-8
1,950
2.734375
3
[ "MIT" ]
permissive
#![feature(test)] extern crate test; extern crate delight_book; use delight_book::chapter16::*; use std::borrow::BorrowMut; #[bench] fn bench_logic_inc_from_xy(b: &mut test::Bencher) { let mut I = 0; let mut W = 0; b.iter(|| { let n = 30; let N: i64 = 1 << 2 * n; let mut x = 0; ...
true
c5ca9ccc0242ed2e68a6d6dcbe66db985dacc4bd
Rust
Nineball54/rpg-attributes
/src/main.rs
UTF-8
1,816
3.296875
3
[ "MIT" ]
permissive
use rand::distributions::Uniform; use rand::prelude::{thread_rng, ThreadRng}; use rand::Rng; fn main() { for _ in 0..=10 { attributes_engine(); } } #[derive(Copy, Clone, Debug)] pub struct Dice { amount: i32, range: Uniform<i32>, rng: ThreadRng, } impl Dice { // Modelled after d20 po...
true
35444d799eb8a3baf46e1f260ae33ab7a79daf2a
Rust
svedi-travis/nosql_test
/prestgris/src/main.rs
UTF-8
4,287
2.515625
3
[]
no_license
extern crate iron; extern crate mount; extern crate persistent; extern crate postgres; extern crate r2d2; extern crate r2d2_redis; extern crate r2d2_postgres; extern crate rand; extern crate redis; #[macro_use] extern crate router; use iron::prelude::*; use iron::status; use iron::typemap::Key; use mount::Mount; use p...
true
2c9f057295ee64cacb1a5a3c05ecb5d90eb0f254
Rust
denilson020898/rwp
/c03/async_functions/src/main.rs
UTF-8
954
3.171875
3
[]
no_license
use async_std; use futures::executor::block_on; use futures::future::join_all; use std::vec::Vec; use std::{thread, time}; async fn do_something(number: i8) -> i8 { println!("number {} is running", number); let two_seconds = time::Duration::new(2, 0); thread::sleep(two_seconds); return 2; } fn main() ...
true
b2bd5d8694642ad5a85fc320dbf5985ff469192f
Rust
loganyu/leetcode
/problems/078_subsets.rs
UTF-8
889
3.203125
3
[]
no_license
/* Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]] ...
true
d22ed9837d6680fa903a7e72b99cb2fd3f83f7ff
Rust
withfig/console
/src/windows_term/colors.rs
UTF-8
12,665
2.90625
3
[ "MIT" ]
permissive
use std::io; use std::mem; use std::os::windows::io::AsRawHandle; use std::str::Bytes; use windows_sys::Win32::Foundation::HANDLE; use windows_sys::Win32::System::Console::{ GetConsoleScreenBufferInfo, SetConsoleTextAttribute, CONSOLE_SCREEN_BUFFER_INFO, FOREGROUND_BLUE as FG_BLUE, FOREGROUND_GREEN as FG_GREEN...
true
3321a0ff9a1cf681a19ea0052aff2fd424852c74
Rust
porky11/ncollide
/ncollide_geometry/shape/convex.rs
UTF-8
939
3.078125
3
[ "BSD-2-Clause" ]
permissive
use utils; use shape::SupportMap; use math::{Isometry, Point}; #[derive(PartialEq, Debug, Clone)] /// The implicit convex hull of a set of points. pub struct ConvexHull<P> { points: Vec<P>, } impl<P> ConvexHull<P> { /// Creates a polytope from a set of point. /// /// The set of point as not assumed t...
true
51fdfe1d43e5f2ef5d072a97d4900becb35777bb
Rust
basement-drift/shrek
/gpt2/server/src/main.rs
UTF-8
2,363
2.765625
3
[]
no_license
mod generator; use std::env; use tokio::{ sync::{mpsc, oneshot}, task, }; use tonic::{transport::Server, Request, Response, Status}; use tracing::{debug, error, info}; use gpt2_proto::gpt2::gpt2_server as proto; use gpt2_proto::gpt2::{GenerateRequest, GeneratedText}; type Responder = oneshot::Sender<String>;...
true
c544a7df0d3095d0f421f00348d8f98fac4e514c
Rust
kamadorueda/alejandra
/src/alejandra/src/builder.rs
UTF-8
8,853
2.984375
3
[ "Unlicense" ]
permissive
#[derive(PartialEq)] pub(crate) enum Step { Comment(String), Dedent, Format(rnix::SyntaxElement), FormatWider(rnix::SyntaxElement), Indent, NewLine, Pad, Token(rnix::SyntaxKind, String), Whitespace, } #[derive(Clone)] pub(crate) struct BuildCtx { pub force_wide: bool, ...
true
d4e09604d0c51b7b359eaf5ed94ba84daac22402
Rust
paradoxix/cornflake
/src/lib.rs
UTF-8
4,444
2.734375
3
[ "BSD-2-Clause" ]
permissive
use std::default::Default; use std::error::Error as StdError; use std::fmt; use std::result; use std::time::{SystemTime, SystemTimeError, UNIX_EPOCH}; // DEFAULT_EPOCH is 2016-01-01T00:00:00.000 static DEFAULT_EPOCH: u64 = 1451602800; #[derive(Debug, Clone)] pub struct Config { pub node_id_bits: i8, pub sequ...
true
9fd18e879301d45b045f8acfb6c27dc0fb55065c
Rust
arfa123/RustPrograms
/07_refrences_and_borrowing/src/main.rs
UTF-8
4,695
4.71875
5
[]
no_license
fn main() { // ################ References and Borrowing ################ // In Rust, we can use the variable reference and pass to any function // without transferring its ownership. let s1 = String::from("hello"); let len = calculate_length(&s1); // This ampersands are references, // and they...
true
51405df41802b8e06f3d51bc8c01848e72f6f706
Rust
nikgaevoy/SPbTrueSkill
/distributions/src/normal/tests.rs
UTF-8
3,110
2.921875
3
[]
no_license
use super::*; extern crate rand; use rand::prelude::*; #[test] fn mean() { let mut rng = rand::thread_rng(); for _i in 0..10 { let a = Gaussian { mu: rng.gen(), sigma: rng.gen() }; let b = Gaussian { mu: rng.gen(), sigma: a.sigma }; let c = (&a + &b) * 0.5; assert!(approx_eq...
true
543ecfae1a2a91dcc7404a7ef94e30d4f7f8ec8f
Rust
kjmrknsn/dataopen
/src/web/access_logger.rs
UTF-8
2,579
2.734375
3
[ "MIT", "Apache-2.0" ]
permissive
use chrono::prelude::*; use iron::{AroundMiddleware, Handler}; use iron::prelude::*; use super::handler::prelude::uid; use super::super::log; pub struct AccessLogger; impl AroundMiddleware for AccessLogger { fn around(self, handler: Box<Handler>) -> Box<Handler> { Box::new(AccessLoggerHandler::new(handler...
true
62f65d28d957ba850dfab4b93d8c136b0cb42362
Rust
clauswilke/sinab
/src/sinab/src/utils/tagged_union_with_jump_tables.rs
UTF-8
6,782
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
/// Create an enum with methods that match on it, /// where matching is implemented as a jump table /// (static array of function pointers, indexed by discriminant). /// /// This is based on RFC 2195: /// <https://rust-lang.github.io/rfcs/2195-really-tagged-unions.html> /// /// See usage example in test at the end of t...
true
9de5ff78117557d7f0ebd3ea39fd479a1def9cc2
Rust
microsoft/onefuzz
/src/agent/debuggable-module/src/load_module.rs
UTF-8
2,059
2.71875
3
[ "LicenseRef-scancode-generic-cla", "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. use std::io::Cursor; use anyhow::{bail, Result}; use goblin::Hint; use crate::linux::LinuxModule; use crate::loader::Loader; use crate::path::FilePath; use crate::windows::WindowsModule; use crate::Module; pub trait LoadModule<'data> where ...
true
0187bcc023cc0800eb1bb920274b0d05e7ac8b5a
Rust
brigand/rust-analyzer
/crates/gen_lsp_server/examples/02_gen_lsp_server_with_logging.rs
UTF-8
4,166
3.03125
3
[ "Apache-2.0", "MIT" ]
permissive
//! A minimal example LSP server that can only respond to the `gotoDefinition` request. To use //! this example, execute it and then send an `initialize` request. //! //! ```no_run //! Content-Length: 85 //! //! {"jsonrpc": "2.0", "method": "initialize", "id": 1, "params": {"capabilities": {}}} //! ``` //! //!...
true
45caf9f368d857c80d9f21b214599b1c27229630
Rust
renatoathaydes/jgrab
/jgrab-client/src/main.rs
UTF-8
8,246
2.921875
3
[ "Apache-2.0" ]
permissive
use std::net::{TcpStream, Shutdown}; use std::io::{Stdin, stdin, stdout, Read, Write, Error, Result, Cursor}; use std::fs::File; use std::env; use std::iter::Iterator; use std::str; use std::option::Option; use std::process::{Command, Child, exit}; use std::path::PathBuf; use std::thread::sleep; use std::time::Duration...
true
f224358ae7bac1aa449a159e6869a6fd2193fa63
Rust
koengit/trainspotting
/railml2dgraph/src/dgraph.rs
UTF-8
6,389
2.90625
3
[]
no_license
use std::collections::HashMap; use base::*; use branching::*; #[derive(Debug,Clone)] pub struct DGraphModel { pub nodes: Vec<DGraphNode>, pub edges: Vec<Edge>, } impl Default for DGraphModel { fn default() -> Self { DGraphModel { nodes: Vec::new(), edges: Vec::new() } } } pub type Link = (Par...
true
7dcabcb20f19b2b272c4d6013071b4c63ba6c813
Rust
guangyuz/gossip_rust
/tests/lunch_100_servers.rs
UTF-8
1,175
2.734375
3
[]
no_license
#[cfg(test)] mod tests { use std::thread; use std::time::Duration; use std::io::prelude; use std::io::Write; extern crate gossiprust; use gossiprust::server::Server; use gossiprust::message::Message; extern crate tokio; use tokio::io; use tokio::net::TcpStream; use tokio::p...
true
9eb00ee575c8112f57eb9302b2ceae73348bee7b
Rust
On0n0k1/mysql_layer
/src/bin/delete.rs
UTF-8
770
2.671875
3
[ "MIT" ]
permissive
use lib::{ // request_post, request_delete, lambda::{ funcionario::{ // funcionario::Funcionario, delete::{ DeleteRequest, }, }, message::Message, }, }; fn main() { // let request = Funcionario::new( // 55, // ...
true
8c85d0a9145307f41293d150ab9c50c03149f939
Rust
durran/bson-rust
/src/document.rs
UTF-8
1,596
3.65625
4
[]
no_license
use linked_hash_map::LinkedHashMap; use bson::Bson; /// Represents a BSON document. #[derive(Clone, Debug, PartialEq)] pub struct Document { elements: LinkedHashMap<String, Bson> } /// The implementation for `Document`. impl Document { /// Create a new `Document`. /// /// # Returns /// The new `D...
true
1bb7943b59c9511468e54712e3f606ad537b690f
Rust
belltoy/leetcode-rs
/src/power_of_two.rs
UTF-8
1,154
4.3125
4
[ "MIT" ]
permissive
//! # 231. 2的幂 //! //! 难度 简单 //! //! 给定一个整数,编写一个函数来判断它是否是 2 的幂次方。 //! //! ## 示例 1: //! //! ```text //! 输入: 1 //! 输出: true //! 解释: 2^0 = 1 //! ``` //! //! ## 示例 2: //! //! ```text //! 输入: 16 //! 输出: true //! 解释: 2^4 = 16 //! ``` //! //! ## 示例 3: //! //! ```text //! 输入: 218 //! 输出: false //! ``` //! //! See [leetcode](ht...
true
0e6cee897c67aa8d6b88ae6a708475dd0aab829f
Rust
smitea/rhai
/src/module/resolvers/file.rs
UTF-8
6,159
3.125
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use crate::stdlib::{ boxed::Box, collections::HashMap, io::Error as IoError, path::PathBuf, string::String, }; use crate::{Engine, EvalAltResult, Module, ModuleResolver, Position, Shared}; /// Module resolution service that loads module script files from the file system. /// /// Script files are cached so they are...
true
2f16746814ca4a860def353086e097933be3e3fb
Rust
ThomCoder/Install_A_Bot
/src/systemconfig.rs
UTF-8
2,680
3.25
3
[ "MIT" ]
permissive
use crate::{ errors::{Error, ErrorCode}, tomlhelper, }; pub struct Systemconfig { pub name: Option<String>, pub install_cmd: String, } pub enum SupportedSystems { Linux, Mac, Windows, } impl SupportedSystems { pub fn value(&self) -> &str { match self { SupportedSys...
true
c91fc0e801d5c91c374c66499ee54d2d71d741e1
Rust
adamhooper/topogeo
/src/clip/edge.rs
UTF-8
4,637
3.46875
3
[ "CC0-1.0", "LicenseRef-scancode-public-domain" ]
permissive
use geo::Point; use clip::types::{ClipLocation, ClipMask}; /// Clips an edge so that only the part the mask includes is returned. /// /// # Examples /// /// ``` /// use topogeo::clip::ClipMask; /// use topogeo::clip::edge::clip_edge; /// use topogeo::geo::Point; /// /// // . /// // *-.--* /// // . / /// // ./ /...
true
6a0a3248395063cb3f64191fa8bf4e18c072a7ec
Rust
lukethacoder/rust-adventures
/sfdx-list/src/main.rs
UTF-8
1,738
2.859375
3
[]
no_license
use std::{env,fs}; use colored::*; use regex::Regex; mod schema; const PATH_VAR: &str = "HOMEPATH"; const STATE_FOLDER: &str = ".sfdx"; fn main() { println!("Running main...\n"); // regex to check for valid json files // "borrowed" from https://github.com/forcedotcom/sfdx-core/blob/552d6f2301b29f03ca9cb0cdc293...
true
15d8657f446fb9fdbfe36e258aa85bdd500b8ab9
Rust
jstoja/grokking_algorithms
/rust/src/lib.rs
UTF-8
1,608
3.15625
3
[ "MIT" ]
permissive
mod chapter1_4; mod chapter5_; use chapter1_4::*; #[cfg(test)] mod tests { use super::*; #[test] fn test_binary_search() { let data = vec![1, 3, 5, 7, 9]; let tests = vec![ (3, Ok(1)), (-1, Err("Guess not found")), (2, Err("Guess not found")), ...
true
87488b8f2702a91369cf802a1c6d310c0c7d0db7
Rust
RustyBamboo/rosrust
/src/tcpros/service.rs
UTF-8
6,637
2.515625
3
[ "MIT" ]
permissive
use rustc_serialize::{Encodable, Decodable}; use std::net::{TcpListener, TcpStream}; use std::thread; use std::sync::Arc; use std::sync::mpsc::{channel, Sender, Receiver}; use std::collections::HashMap; use std; use super::decoder::DecoderSource; use super::encoder::Encoder; use super::error::{ErrorKind, Result}; use s...
true
b7bb23d3dd2a7646094ef203d7aa2fed5950d3d5
Rust
cmbrandenburg/rss2email
/src/config.rs
UTF-8
1,110
2.78125
3
[ "MIT" ]
permissive
use {Error, std, toml}; use std::path::Path; #[derive(Clone, Debug, Deserialize, Serialize)] pub struct Config { pub recipient: String, pub smtp_server: String, pub smtp_username: String, pub smtp_password: String, } impl Config { pub fn load<P: AsRef<Path>>(config_path: P) -> Result<Self, Error> ...
true
046f36dd63a2a134ac4fb7a071153af69ae7458d
Rust
gitter-badger/spectra
/src/render/shader/cheddar/parser.rs
UTF-8
3,966
2.953125
3
[ "BSD-3-Clause" ]
permissive
//! The Cheddar shading language parser. //! //! This module exports several identifiers, parser function combinators and utility functions to //! transform and handle the Cheddar AST. use nom::alphanumeric; use std::str::from_utf8_unchecked; use glsl::parser::{external_declaration, identifier}; pub use glsl::parser::...
true
69dde02c721b39219d743f9b2530ecafb3e01b37
Rust
mrobakowski/arcon
/execution-plane/arcon/src/metrics/gauge.rs
UTF-8
916
3.078125
3
[ "AGPL-3.0-only" ]
permissive
// Copyright (c) 2020, KTH Royal Institute of Technology. // SPDX-License-Identifier: AGPL-3.0-only /// Gauge metric representing a value that can go up and down #[derive(Debug, Clone)] pub struct Gauge { value: u128, } impl Gauge { /// Create new Gauge #[inline] pub fn new() -> Gauge { Gauge ...
true
a8d8f2f853b21ceffa261ac0f44a3bad4b66cf03
Rust
balajisivaraman/rust-book
/references/src/main.rs
UTF-8
1,775
4.28125
4
[]
no_license
fn main() { let s1 = String::from("hello"); let len = calculate_length(&s1); println!("The length of {} is {}", s1, len); let mut str = String::from("Hello"); // below code will not compile because we're creating // two mutable references to the same piece of data in the same lexical scope /...
true
774e1da6f00dcf5e2853206ad9c4f2f87a271fac
Rust
Ryanmtate/fluvio
/src/cli/src/topic/helpers/list_sc.rs
UTF-8
2,786
2.9375
3
[ "Apache-2.0" ]
permissive
//! //! # Fluvio SC - List Topic Processing //! //! Retrieve all Topics and print to screen //! use prettytable::Row; use prettytable::row; use prettytable::cell; use log::debug; use flv_client::ScClient; use flv_client::SpuController; use flv_client::metadata::topic::TopicMetadata; use crate::error::CliError; use ...
true
5dcd9f6ede340f5a82f96c3ed5bd9c7beaf31ecf
Rust
3gx/fuzzapi
/src/typ.rs
UTF-8
6,561
3.46875
3
[]
no_license
use function; // A Native type is a type that is builtin to the language. #[derive(Clone, Copy, Debug, PartialEq)] pub enum Native { U8, U16, U32, U64, Unsigned, Usize, I8, I16, I32, I64, Integer, F32, F64, Boolean, Character, Void, } impl Native { // True if this type is "wider" than the given Native type. W...
true
1b904f24a67206cb51a4e3a14c770e675ac74913
Rust
JordanLevin/rust-projects
/text-adventure/src/main.rs
UTF-8
2,811
3.375
3
[]
no_license
extern crate readline; extern crate rand; use readline::readline; use rand::Rng; const SIZE: usize = 20; #[derive(Debug, Copy, Clone)] enum TileType { Forest, Field, Mountain, Water, } #[derive(Debug, Copy, Clone)] struct Tile { pub Type: TileType, pub enemy_chance: i32, pub loot_cha...
true
07539d8c6704b16c8d90e95028756681c655adae
Rust
CBenoit/autocmd
/src/lib.rs
UTF-8
2,672
3.3125
3
[ "MIT" ]
permissive
extern crate colored; //use std::io::Write; // for stderr use std::process::Command; use std::thread; use std::time; use colored::*; // conditional println macro #[macro_export] macro_rules! cprintln { ( $cond:ident ) => { if $cond { println!(); } }; ( $cond:ident, $( $x:expr ...
true
129e42bbeccd1257b50aedc0bdd3960cf139a93b
Rust
evomassiny/fluffy-penguin
/src/activation.rs
UTF-8
5,233
3.421875
3
[ "Apache-2.0" ]
permissive
//! Here we declare all the activation function we might use in our artificial neural network, //! namely: ReLu, Sigmoid, Softmax, Tanh. //! See https://en.wikipedia.org/wiki/Activation_function for more. pub trait TransferFunctionTrait<T> { fn isrlu(&self, alpha: T) -> T; fn isru(&self, alpha: T) -> T; fn...
true
975615a9cbb26f843bd460530f3be3ec68da821a
Rust
dyxushuai/wal
/src/test_utils.rs
UTF-8
3,791
3.34375
3
[]
no_license
use std::env; use std::fmt; use std::usize; use rand; use rand::{Rng, SeedableRng}; use rand::distributions::Sample; use segment; pub struct EntryGenerator { seed: usize, /// Random number generator. rng: rand::StdRng, /// Gamma(shape=1.25, scale=25.6) distribution for generating entry sizes. /...
true
3b227b4839da1be487df420886d04830f06f63c0
Rust
comit-network/secp256kfun
/ecdsa_fun/tests/against_c_lib.rs
UTF-8
3,502
2.53125
3
[ "0BSD" ]
permissive
#![cfg(feature = "libsecp_compat")] use ecdsa_fun::{ self, fun::{Point, Scalar, TEST_SOUNDNESS}, }; use secp256k1::{Message, PublicKey, SecretKey}; fn rand_32_bytes() -> [u8; 32] { use rand::RngCore; let mut bytes = [0u8; 32]; rand::thread_rng().fill_bytes(&mut bytes); bytes } /// Verify that ...
true
ff79550f8577f1dc90aa3c92ca8e4ac7652e9244
Rust
RinatValiullov/rust_land
/for_loop1.rs
UTF-8
146
3.109375
3
[]
no_license
fn main() { let new_arr = ['a', 'b', 'c']; for letter in new_arr.iter() { println!("Letter in new array is {}", letter); } }
true
289bdcdc3ead6dc2d57e39875922f25f51331f5c
Rust
bamling/pong-rs
/src/systems/game/player_input.rs
UTF-8
1,290
2.9375
3
[]
no_license
use amethyst::{ ecs::{ Read, ReadExpect, System, Write, }, input::InputHandler, }; use crate::resources::{ Command, CommandChannel, GameMode, Player, }; /// PlayerInput system encapsulates player input handling and converts receiver input into /// Commands. ...
true
413504104c5b419ce564d22297271da569132877
Rust
AndreasOM/shader-crusher
/build.rs
UTF-8
1,845
2.890625
3
[ "MIT" ]
permissive
use std::env; use std::fs::File; use std::io::Write; use std::path::Path; fn all_combinations(input: &[u8; 4], l: u8) -> Vec<String> { let mut r = Vec::new(); if l <= 0 { } else if l == 1 { for i in input { r.push(format!("{}", *i as char).to_string()); } } else { let s = all_combinations(&input, l - 1); ...
true
7dec3bae06650fea45016a0bd16bb608f4d15cfc
Rust
GaloisInc/mir-verifier
/lib/libcore/convert/num.rs
UTF-8
19,794
3.09375
3
[]
permissive
use super::{From, TryFrom}; use crate::num::TryFromIntError; mod private { /// This trait being unreachable from outside the crate /// prevents other implementations of the `FloatToInt` trait, /// which allows potentially adding more trait methods after the trait is `#[stable]`. #[unstable(feature = "c...
true
077e883bd6c139eea7008767c65941b629c9c5ed
Rust
Wooker/adns-2620
/src/adns_2620.rs
UTF-8
2,527
2.546875
3
[]
no_license
use core::ptr::{read_volatile, write_volatile}; /* #define Config 0x40 #define Status 0x41 #define Delta_Y 0x42 #define Delta_X 0x43 #define SQual 0x44 #define MaxPix 0x45 #define MinPix 0x46 #define PixSum 0x47 #define PixData 0x48 #define ShutterUp 0x49 #define ShutterDown 0x4A #define...
true
699ee902f6822448da1d15e68f31f2d607751d1d
Rust
derrickbaldwin/exercism-rust
/bob/src/lib.rs
UTF-8
786
3.671875
4
[]
no_license
pub fn is_capped(s: &str) -> bool { s == s.to_ascii_uppercase() } pub fn is_question(s: &str) -> bool { s.ends_with("?") } pub fn is_a_char(s: &str) -> bool { for x in s.chars() { if x.is_alphabetic() { return true; } } false } pub fn reply(message: &str) -> &str { ...
true
35c88c3555437cca8e658b2b66f7880220dc3455
Rust
Hakuyume/qemu-run
/qemu-run/src/config/cpu.rs
UTF-8
1,367
3.046875
3
[]
no_license
use serde::Deserialize; use std::borrow::Cow; #[derive(Debug, Default, Deserialize)] #[serde(deny_unknown_fields)] pub struct Cpu { #[serde(default)] kvm: bool, #[serde(rename = "type")] type_: Option<String>, cores: Option<usize>, } impl Cpu { pub fn gen_params(&self) -> Vec<Cow<'_, str>> { ...
true
29b84730643f74ba737d381c5a8fd5c9927f687f
Rust
tokio-rs/axum
/axum/src/macros.rs
UTF-8
2,291
2.859375
3
[ "MIT" ]
permissive
//! Internal macros macro_rules! opaque_future { ($(#[$m:meta])* pub type $name:ident = $actual:ty;) => { opaque_future! { $(#[$m])* pub type $name<> = $actual; } }; ($(#[$m:meta])* pub type $name:ident<$($param:ident),*> = $actual:ty;) => { pin_project_lite...
true
462384564b42582d8c0fb6fb4a9fcf210b59e810
Rust
arucil/parsergens
/grammar/src/lexer/nfa.rs
UTF-8
986
2.6875
3
[ "MIT" ]
permissive
use std::hash::Hash; use std::fmt::{self, Debug}; use std::borrow::Borrow; use super::dfa::Dfa; use super::nfa_builder::NfaBuilder; use crate::{Map, Set}; #[derive(Debug)] pub struct Nfa<A, P, V> { pub transitions: Map<(State, Option<A>), Set<State>>, pub state_letters: Map<State, Set<A>>, pub accept_states: Map...
true
b16aee0876dff85e8163528a8b083de30ec4dcc2
Rust
lock19960613/SCL
/Daily/Rust/Leetcode554-砖墙.rs
UTF-8
543
2.875
3
[]
no_license
use std::collections::HashMap; impl Solution { pub fn least_bricks(wall: Vec<Vec<i32>>) -> i32 { let mut hash = HashMap::new(); for line in wall.iter(){ let mut sum = 0; let end = line.len() - 1; for i in 0..end{ sum += line[i]; let ...
true
7c5cc153dfef070c1c65d5d80272c46cb03d88d8
Rust
Antti/rubygems-rust-experiments
/src/define_methods.rs
UTF-8
4,962
3.09375
3
[]
no_license
// Typesafe method definition, example on rb_define_method(VALUE klass, const char *name, VALUE (*func)(), int argc) // Goal: be able to define method in type safe maner. // Type variance: method arguments. // Cases: // * Positive number of arguments, function definition looks like: // pub extern "C" fn fu...
true
088abb20d66db6b4e8e7aab95bc2d5471cd4133a
Rust
filestar-project/rust-fil-proofs
/storage-proofs/core/src/por.rs
UTF-8
12,430
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
use anyhow::ensure; use serde::{Deserialize, Serialize}; use std::marker::PhantomData; use crate::{ error::{Error, Result}, hasher::{Domain, Hasher}, merkle::{MerkleProofTrait, MerkleTreeTrait}, parameter_cache::ParameterSetMetadata, proof::{NoRequirements, ProofScheme}, }; #[derive(Debug, Clone, ...
true
b85713263c3fecd6882168cbc6c4bd0c8f5e5726
Rust
tg-rs/tgbot
/examples/send_file.rs
UTF-8
6,892
2.578125
3
[ "MIT" ]
permissive
use dotenv::dotenv; use futures_util::future::BoxFuture; use std::{env, io::Cursor}; use tgbot::{ longpoll::LongPoll, methods::{EditMessageMedia, SendAnimation, SendDocument, SendPhoto, SendVideo}, mime, types::{ InlineKeyboardButton, InputFile, InputFileReader, InputMedia, InputMediaAnimation, ...
true
8dc790b541d9e043ef2925f2d3b0550405fe662c
Rust
basstabs/Snoop
/engine/src/gameloop.rs
UTF-8
1,002
3
3
[]
no_license
use sfml::system::Clock; use super::game::Game; pub fn rungame(step: i32, game: &mut Game) { //Update using the same step each frame let timestep = step as f32; //Initialize time variables let timer = Clock::start(); let mut previous = timer.elapsed_time().as_milliseconds(); let mut lag = 0;...
true
2c37735b56f65fda2cfe50749fdf6c60051cf942
Rust
Ainevsia/Leetcode-Rust
/38. Count and Say/src/main.rs
UTF-8
1,690
3.953125
4
[ "BSD-2-Clause" ]
permissive
fn main() { let x = Solution::count_and_say(6); println!("x = {:#?}", x); } struct Solution {} impl Solution { pub fn count_and_say(n: i32) -> String { if n == 1 { return "1".to_string() } let s: Vec<u8> = Self::count_and_say(n - 1).bytes().collect(); let mut ret = "".to_string(); ...
true
623168f1fdd23b11266f98989aa6c9b48c0da87e
Rust
MyK00L/zerosumrs
/src/default_heuristic.rs
UTF-8
2,505
2.5625
3
[]
no_license
use crate::game::*; use crate::heuristic::Heuristic; use crate::mancala; use crate::othello; use crate::tablut; use crate::tictactoe; pub struct DefaultHeuristic; impl Heuristic<tablut::Tablut> for DefaultHeuristic { fn eval(g: &tablut::Tablut) -> i64 { match g.state() { State::Win => i64::MAX - g.turn as i64, ...
true
da94fa5e32da09d627331ff71ea8c72c52838a21
Rust
ihciah/thrift-parser
/examples/int_constant.rs
UTF-8
2,837
3.5
4
[]
no_license
//! This file is meant to illustrate how to use nom to parse. use std::str::FromStr; use nom::branch::alt; use nom::bytes::complete::{tag, take_while}; use nom::character::complete::{char as cchar, digit1, satisfy, space0}; use nom::combinator::{map, map_res, opt, recognize}; use nom::sequence::{preceded, tuple}; use...
true
f44596c12a0e4044432baf35e7a42d3b998a11d7
Rust
jakyle/pathfinding-grid
/src/pathfinding/dijkstra_max_move.rs
UTF-8
2,234
2.953125
3
[]
no_license
use crate::prelude::{Grid, Location}; use std::collections::{BinaryHeap, HashMap, HashSet}; use super::BHeapState; pub fn path_2d(grid: Grid, start: &Location, max_move: usize) -> HashSet<Location> { let mut visited = HashSet::new(); let mut cost_so_far = HashMap::new(); let mut heap = BinaryHeap::new();...
true
41aa0890a320937f3fca8fff9058d8d6faec68c9
Rust
Despire/broadcast-server
/src/main.rs
UTF-8
4,504
2.515625
3
[ "MIT" ]
permissive
use tokio::net::TcpListener; use tokio::net::TcpStream; use tokio::sync::mpsc; use tokio::sync::mpsc::UnboundedReceiver; use tokio::sync::mpsc::UnboundedSender; use tokio::sync::Mutex; use tokio_stream::StreamExt; use tokio_util::codec::Framed; use tokio_util::codec::LinesCodec; use std::collections::HashMap; use std:...
true
7ba7dcaa04ed9d033161025dcf64a606d9f7a655
Rust
cryptobioz/dyn-livedns-gandi
/src/main.rs
UTF-8
11,904
2.71875
3
[]
no_license
#[macro_use] extern crate serde_derive; #[cfg(test)] extern crate tempdir; #[cfg(test)] extern crate mockito; extern crate serde_json; extern crate reqwest; extern crate clap; extern crate ini; use ini::Ini; use clap::{Arg, App}; use std::process::exit; #[cfg(not(test))] const GANDI_URL: &str = "https://dns.api.ga...
true
dfb4514e5db76dbc674edb54c0aa73c2cc1520ee
Rust
natepisarski/graveyard
/capture/src/libcap.rs
UTF-8
1,224
2.78125
3
[]
no_license
/* libcap - Data structures and functions for use in main */ use std; use std::io::{BufferedWriter, File, fs, FilePermission, IoResult, process}; use std::io::process::{Process}; pub struct CaptureContext { pub process: Process, pub commands: Vec<String>, pub filename: Path } impl CaptureContext { p...
true
6defd059074bec3f1b6c270ac2dbe3b1fb7e8216
Rust
iCodeIN/web-browser-lsp
/src/lib.rs
UTF-8
2,131
2.515625
3
[ "MIT" ]
permissive
#[macro_use] extern crate async_trait; pub mod lsp_ext; mod transport; mod worker; use playwright::Playwright; use std::{ env, fs, path::{Path, PathBuf}, process }; #[async_trait] trait LspServer { type Notification; type Request; type Response; type InitializeParams; type InitializeR...
true
1f6409ece3050217fa22abd65ce8111911187c2c
Rust
Jimskapt/rust-book-fr
/FRENCH/listings/ch13-functional-features/listing-13-04/src/main.rs
UTF-8
935
3.171875
3
[ "Apache-2.0", "MIT", "Unlicense", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
use std::thread; use std::time::Duration; fn simuler_gros_calcul(intensite: u32) -> u32 { println!("calcul très lent ..."); thread::sleep(Duration::from_secs(2)); intensite } // ANCHOR: here fn generer_exercices(intensite: u32, nombre_aleatoire: u32) { let resultat_lent = simuler_gros_calcul(intensite...
true
69ff321b4d12213d6f5fccb72521e213ae207f3c
Rust
brittos/learning-rust
/estudos/cap07/ex02-matriz-ordenate/src/main.rs
UTF-8
415
3.390625
3
[]
no_license
/** * Capítulo 7 - Estruturas homogêneas * Exemplos de Ordenação de Matriz * */ fn main() { let mut matriz = [100,200,33,2,5,79,1550,1]; let tamanho = matriz.len(); println!("{:?}", matriz); for i in 0..tamanho { for j in 0..tamanho { if &matriz[i] > &matriz[j] { ...
true
0140ce628205bf28512c215fdbf2e1fb56450c6b
Rust
MinusKelvin/fumen-rs
/src/lib.rs
UTF-8
27,991
2.953125
3
[ "MIT" ]
permissive
#[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Fumen { pub pages: Vec<Page>, pub guideline: bool } #[derive(Clone, Debug, Eq, PartialEq, Hash)] pub struct Page { pub piece: Option<Piece>, /// y-up pub field: [[CellColor; 10]; 23], pub garbage_row: [CellColor; 10], pub rise: bool, ...
true
869c6936f41a1415b4feb34872ad02c80360e2f8
Rust
NicolasLagaillardie/mpst_rust_github
/tests/http/simple_http_get.rs
UTF-8
644
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use hyper::{Body, Client, Response, StatusCode}; use std::error::Error; #[tokio::main] async fn aux() -> Result<Response<Body>, Box<dyn Error + Send + Sync>> { let client = Client::new(); let uri = "http://httpbin.org/ip".parse()?; // Await the response... // let mut resp = client.get(uri).await?; ...
true
987da4c98aae8bb9221ae42409a89e38973994a5
Rust
WisartArfun/Divisionaries
/src/prog/api/mod.rs
UTF-8
5,696
2.765625
3
[]
no_license
use std::{str, sync::{Arc, Mutex}, thread}; use serde::{Deserialize, Serialize}; use serde_json; extern crate bucketer; use bucketer::bucket::{Bucket, BucketData, ConnectionHandler, BucketManager, BucketServer, BucketMessage}; use crate::prog::tic_tac_toe::TicTacToe; pub struct ApiBucket { connection_handler: A...
true
3eee3376690fa42e9ebba2fed8cd437f4dfc0d55
Rust
yishn/adventofcode
/2018/19.rs
UTF-8
3,136
3.375
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::prelude::*; fn get_input() -> std::io::Result<String> { let mut file = File::open("19.txt")?; let mut contents = String::new(); file.read_to_string(&mut contents)?; Ok(contents) } #[derive(Debug, Clone, Eq, PartialEq, Hash)] struct State(Vec<usize>); impl State { ...
true
6f8f0be0502e43828b866f4795b8db4dabfd36b6
Rust
m0riiiii/rust_practice
/mrbgpdv2/src/packets/open.rs
UTF-8
3,206
3.09375
3
[]
no_license
use std::net::Ipv4Addr; use anyhow::Context; use bytes::{BufMut, BytesMut}; use super::header::{Header, MessageType}; use crate::bgp_type::{AutonomousSystemNumber, HoldTime, Version}; use crate::error::ConvertBytesToBgpMessageError; #[derive(PartialEq, Eq, Debug, Clone, Hash)] pub struct OpenMessage { header: Hea...
true