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
34b2726804ac7a8693422dbc64db1158a1611450
Rust
gianlucamazza/proofmarshal
/hoard/src/refs.rs
UTF-8
982
3.203125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::borrow::Borrow; use std::ops::Deref; use std::fmt; use owned::IntoOwned; pub enum Ref<'a, T: ?Sized + IntoOwned> { Ref(&'a T), Owned(T::Owned), } impl<'a, T: ?Sized + IntoOwned> Deref for Ref<'a, T> { type Target = T; fn deref(&self) -> &T { match self { Ref::Ref(r) => r...
true
73988940c86ddb49ab229e17b25b393c6017838d
Rust
beevans/integrated-manager-for-lustre
/iml-gui/crate/src/watch_state.rs
UTF-8
1,234
2.890625
3
[ "GPL-1.0-or-later", "MIT", "BSD-3-Clause" ]
permissive
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use std::mem; /// An abstraction over a component being open / closed /// or watching for a change. This is needed /// due to the way seed handles window events. #[de...
true
1121653c6283bfb6ae5239b08e8ba41b83f318e1
Rust
18616378431/myCode
/rust/test5-18/src/main.rs
UTF-8
257
3.46875
3
[]
no_license
//引用移动语义做为函数参数 fn foo(s : String) -> String { let w = " world".to_string(); s + &w } fn main() { let s = "hello".to_string(); let ss = foo(s); println!("{:?}", s);//s做为函数参数发生了所有权转移 }
true
b86ae2d259f0c7926657370a857574a4cca0fc79
Rust
varunsrin/debtsolver
/src/lib.rs
UTF-8
17,733
4.09375
4
[ "MIT" ]
permissive
//! Track and settle debts between parties with the fewest transactions. //! //! Debtsolver gives you two structs - Transactions, which track payments that //! have been made or need to be made, and a Ledger which can store and balance //! the current states of credits and debits between everyone. //! //! # Use //! //!...
true
8f3b31bcfd23635840c2489311f53a57f9261027
Rust
jasilven/aoc-2017-rust
/src/bin/day22.rs
UTF-8
4,420
3.390625
3
[]
no_license
use failure::{bail, Error}; use std::collections::HashMap; use std::fs::File; use std::io::BufRead; use std::io::BufReader; type Result<T> = std::result::Result<T, Error>; #[derive(Clone, Debug)] enum Direction { Up, Right, Down, Left, } #[derive(Clone, Debug)] enum Status { Clean, Weakened, ...
true
1a36ba00017ee1b3d1ca5e23693ac08a38398ff7
Rust
songlinshu/winsafe
/src/msg/hdm.rs
UTF-8
3,244
2.75
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Header control //! [messages](https://docs.microsoft.com/en-us/windows/win32/controls/bumper-header-control-reference-messages), //! whose constants have [`HDM`](crate::co::HDM) prefix. use crate::aliases::WinResult; use crate::co; use crate::msg::{MsgSend, WndMsg}; use crate::msg::macros::zero_as_err; use...
true
4191cf2f693b5efaf2d2b189a0834037fb070070
Rust
WitchcultGames/gamemath
/src/mat4.rs
UTF-8
33,691
3.359375
3
[ "MIT" ]
permissive
use quat::Quat; use std; use std::f32::consts::PI; use vec3::Vec3; use vec4::Vec4; // TODO: Consider making Mat4 of a generic type instead of forcing f32. // But would any other type than f64 ever be useful? type Row = (f32, f32, f32, f32); type InlineMat4 = ( f32, f32, f32, f32, f32, f3...
true
1398dfac1a00c887225398db5c29aa2ab3f7bad7
Rust
sonos/tract
/tensorflow/src/ops/array/pad.rs
UTF-8
3,568
2.59375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use tract_hir::internal::*; use tract_ndarray::{Array, ArrayView2}; use crate::model::ParsingContext; use crate::tfpb::tensorflow::NodeDef; #[derive(Debug, Clone, Default, new, Hash)] pub struct Pad; pub fn pad(_ctx: &ParsingContext, _pb: &NodeDef) -> TractResult<Box<dyn InferenceOp>> { Ok(Box::<Pad>::default(...
true
5fc2a7e83a9d129d34990402d71a230d329ebc99
Rust
sore0159/rust_island
/src/ui/c_term/widget/data.rs
UTF-8
4,102
2.796875
3
[]
no_license
use super::super::{output::Rect, output::Style, parts, Key}; use super::Widget; use border::BorderType; use parts::{border, text, title}; pub struct WidgetData { pub rect: Rect, pub borders: border::Borders, pub titles: Vec<title::Title>, pub texts: Vec<text::Text>, pub updates: String, pub sel...
true
102ba9903d12da90a511692f2ec98d7fc9b3f30e
Rust
fejx/comparison-of-cpp-julia-go-rust
/rust/mariani-silver/src/rectangle_splitter.rs
UTF-8
1,813
3.453125
3
[]
no_license
pub mod rectangle_splitter { use crate::rectangle::rectangle::Rectangle; pub const PART_COUNT: usize = 2; #[derive(PartialEq)] enum Direction { Horizontal, Vertical, } struct SplittingContext<'a> { split_direction: Direction, original: &'a Rectangle, } pub fn split_rectangle(rect: &Rectangle) -> [Re...
true
ae237e66a933c5f81bca178d87c5526c1460d341
Rust
sbdchd/tnetstring
/src/ser.rs
UTF-8
16,601
2.9375
3
[]
no_license
// This is based on the Serde docs JSON example with its license below. // Permission is hereby granted, free of charge, to any // person obtaining a copy of this software and associated // documentation files (the "Software"), to deal in the // Software without restriction, including without // limitation the rights ...
true
3bc8b89dfe044769f4512acb0dc32703ca6cdf73
Rust
cmccord-dev/aoc2020
/src/days/day11.rs
UTF-8
6,324
3.046875
3
[]
no_license
use crate::input_struct; use crate::DayTrait; use itertools::Itertools; use std::convert::Infallible; use std::str::FromStr; #[derive(Debug, Clone, Copy, Eq, PartialEq)] pub enum Seat { Floor, Empty, Filled, } impl From<char> for Seat { fn from(c: char) -> Self { match c { 'L' => S...
true
5756747f830cbe40dfa52c7e23a9e228093c3a8f
Rust
drataiczak/Rust
/RustV2/traits/src/lib.rs
UTF-8
1,130
3.171875
3
[]
no_license
// Traits act similarly to Java's interfaces and C's header files // If a function implements a specific trait, it must implement all methods // that trait contains pub trait Summarizable { // Implements a default behavior for the summary function that can be overriden fn summary(&self) -> String { format!("(Read m...
true
8a48bc614191e24271ebe923fffab0db8823c6c2
Rust
EFanZh/LeetCode
/src/problem_0665_non_decreasing_array/mod.rs
UTF-8
520
3.046875
3
[]
no_license
pub mod iterative; pub trait Solution { fn check_possibility(nums: Vec<i32>) -> bool; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ (&[4, 2, 3] as &[_], true), (&[4, 2, 1], false), (&[3, 4, 2, 3], false), ...
true
17531c94daac564c06a87f85eff9f8215d66f2b0
Rust
suclogger/leetcode-rust
/chapter_7/longest-palindromic-subsequence-ii/src/main.rs
UTF-8
1,245
3.03125
3
[]
no_license
fn main() { assert_eq!(longest_palindrome_subseq(String::from("bbabab")), 4); assert_eq!(longest_palindrome_subseq(String::from("dcbccacdb")), 4); } /** 构建三维DP数组 dp[i][j][0]表示从i到j,以字符c开始和结尾的的最长好回文子串长度 dp[i][j][1]表示从i到j,以字符c开始和结尾的的最长好回文子串长度的起止字符 **/ pub fn longest_palindrome_subseq(s: String) -> i32 { le...
true
4c8adcbc78ea4288cd9e3ae86109c6a459c04fea
Rust
d2718/grel
/src/proto2.rs
UTF-8
11,292
3.40625
3
[]
no_license
/*! proto2.rs A newer, simpler, more easily-extensible `grel` protocol. As of 2020-12-29, this supersedes the `grel::protocol` lib. 2020-01-23 */ use serde::{Serialize, Deserialize}; /** The `Op` enum represents one of the `Room` operator subcommands. It is used in the `Msg::Op(...)` variant of the `Msg` enum. */ #...
true
a022b027060db9f8ae06d4a61e544b20f3492b24
Rust
jeshy/vrp
/vrp-core/src/solver/mutation/recreate/recreate_with_skip_best.rs
UTF-8
3,686
2.71875
3
[ "Apache-2.0" ]
permissive
use crate::construction::heuristics::*; use crate::construction::heuristics::{InsertionContext, InsertionResult}; use crate::models::problem::Job; use crate::solver::mutation::Recreate; use crate::solver::RefinementContext; use crate::utils::parallel_collect; use std::cmp::Ordering::*; /// A recreate strategy which sk...
true
1997b6b2028d792282563c878dd39d6d53ed2891
Rust
qinxiaoguang/rs-lc
/src/solution/l057.rs
UTF-8
1,913
3.53125
4
[]
no_license
pub struct Solution {} impl Solution { #[allow(dead_code)] // 针对一个有序的区间,插入一个区间,并输出无重叠区间 // 其实就是056题,只不过是已经排过序了 // 所以其实只需要遍历一遍 pub fn insert(intervals: Vec<Vec<i32>>, new_interval: Vec<i32>) -> Vec<Vec<i32>> { let mut intervals = intervals; intervals.push(new_interval); Self:...
true
bd81e78da634bcba720ee937d09f811a28ce2092
Rust
karjonas/advent-of-code
/2020/day08/src/lib.rs
UTF-8
2,455
3.5
4
[]
no_license
extern crate common; type Instruction = (String, i64); type Program = Vec<Instruction>; fn parse_input(input: &String) -> Program { let mut program = Program::new(); for line in input.lines() { let words: Vec<_> = line.split_ascii_whitespace().collect(); let instruction = String::from(words[0]...
true
79fe420a1aac0c2fe5457397f85add5e63ac8c6a
Rust
retzkek/intcode
/tests/day2.rs
UTF-8
651
3.234375
3
[]
no_license
//! AoC 2019 day 2: https://adventofcode.com/2019/day/2 extern crate intcode; use intcode::{Input, Output, Program}; use std::fs::File; use std::io; #[test] fn main() { let f = File::open("input/day2.int").unwrap(); let reader = io::BufReader::new(f); let mut ic = Program::new(reader); // before runn...
true
2c28ef3a88a80ca219dcf69d052715eece7ab779
Rust
michd/mmpd
/mmpd-lib/src/macros/actions.rs
UTF-8
16,130
3.3125
3
[ "MIT" ]
permissive
use crate::keyboard_control::{self, KeyboardControlAdapter}; use crate::shell::{Shell, ShellImpl}; use std::{thread, time}; use regex::Regex; /// Action run in response to a MIDI event /// Any Action value can be run through ActionRunner::run. #[derive(PartialEq, Debug)] pub enum Action { /// Sends a key sequence ...
true
2f7a2b84cbed660f87f039631c26962432fc264a
Rust
wmmxk/OOP_Rust
/ownership/match_arm/iter/main.rs
UTF-8
661
3.0625
3
[]
no_license
#[derive(Debug)] pub enum Operator { Add, Sub, Mul, } #[derive(Debug)] pub enum Token { Operator(Operator), Operand(isize), } fn main() { let tokens = vec![Token::Operator(Operator::Add)]; let ref_tokens = &tokens; for token in ref_tokens.iter() { match token { &Token::Oper...
true
7dc924a62bc6588b753e43d6a270294cee00ddb5
Rust
rodoufu/rs-luar
/src/shared.rs
UTF-8
2,583
3.65625
4
[ "MIT" ]
permissive
use std::borrow::Borrow; use std::cell::RefCell; use std::iter::IntoIterator; use std::rc::Rc; /// The `Shared` object. pub struct Shared<T> { data: Rc<RefCell<T>>, } /// Implements the IntoIterator for `&'a Shared<T>` considering `T` as a `IntoIterator`. /// /// The `T` parameter adds the restriction that it needs ...
true
f0cc61013dcd80c1f30611bda5423d2c2af35bfc
Rust
keringar/path-tracer
/src/sphere.rs
UTF-8
2,511
3.421875
3
[]
no_license
use cgmath::prelude::*; use cgmath::Vector3; use hit::{HitRecord, Hittable}; use material::Material; use ray::Ray; /// The sphere is a position in space, an origin and a material. /// It implemements the Hittable trait which means that rays can interact /// with it pub struct Sphere { center: Vector3<f32>, ra...
true
8c7d385bf4bf7e3c4c6cb90f10581f3a5c63d044
Rust
markberger/aoc-2019
/aoc01/src/main.rs
UTF-8
952
3.421875
3
[]
no_license
use std::cmp; use std::error; use std::io; use std::io::prelude::*; fn parse_input() -> Result<Vec<i32>, Box<error::Error>> { let reader = io::stdin(); let mut output: Vec<i32> = Vec::new(); for line in reader.lock().lines() { let i: i32 = line?.parse()?; output.push(i) } return O...
true
e7034d9349def7734265ef66b4328a40022e6e56
Rust
quietlychris/Rust_RL
/src/network/concrete_layer/activation_layer/softmax.rs
UTF-8
1,015
2.78125
3
[]
no_license
use crate::network::layer_trait::Layer; use ndarray::{Array, ArrayD}; pub struct SoftmaxLayer { output: ArrayD<f32>, } impl SoftmaxLayer { pub fn new() -> Self { SoftmaxLayer{ output: Array::zeros(0).into_dyn(), //will be overwritten } } } impl Layer for SoftmaxLayer { fn get_type(&self) -> ...
true
5b2c7929757ce91bb48b1caa04f33bc9dfc618cc
Rust
danbruder/rustbookcode
/errors/src/main.rs
UTF-8
1,150
3.359375
3
[]
no_license
fn main() { //panic!("crash and burn!"); //let v = vec![1, 2, 3]; //v[99]; //use std::fs::File; //let file = File::open("hello.txt"); //let f = match file { //Ok(file) => file, //Err(error) => panic!("There was a problem opening the file: {:?}", error), //}; //use std::fs::Fi...
true
091b8dda33ec756f988fd49e41fc94b5a72b67a9
Rust
sagarnayak/e_com
/src/core/fairings.rs
UTF-8
642
2.796875
3
[]
no_license
use rocket::{Data, Request, Response}; use rocket::fairing::{Fairing, Info, Kind}; #[derive(Default, Clone)] pub struct CounterFairing; #[rocket::async_trait] impl Fairing for CounterFairing { // This is a request and response fairing named "GET/POST Counter". fn info(&self) -> Info { Info { ...
true
8e274210b849b6f3f623c62ca81076111f2e4f45
Rust
oloshe/draw-server
/app/src/lobby/actor.rs
UTF-8
4,399
2.78125
3
[]
no_license
use std::{collections::{HashMap, HashSet}, hash::Hash}; use actix::{Actor, Context, Handler, Recipient}; use crate::data_struct::room::RoomInfo; use crate::base::*; use utils::{error, info}; use crate::msg::{NormalResult, message::*}; type Socket = Recipient<WsMessage>; pub struct LobbyActor { /// 根据 uid 找到 地址 ...
true
7b3a3c25f727c8a5d1748ee0172a52761f68626d
Rust
sria91-rlox/rlox-52
/src/interpreter.rs
UTF-8
7,746
3.140625
3
[ "MIT" ]
permissive
use crate::parser::{ExprTy, Expr, UnaryOp, Stmt, LogicalOp}; use crate::scanner::{Literal}; use crate::parser::BinOp::{EQUAL_EQUAL, BANG_EQUAL, PLUS, SLASH, MINUS, MULT, GREATER, GREATER_EQUAL, LESS, LESS_EQUAL, AND, OR}; use crate::source_ref::SourceRef; use crate::environment::Env; use crate::scanner::Literal::{NIL, ...
true
e828515d42224fcf2d06c9c429b9a64c79c992b4
Rust
ValarDragon/kms
/src/types/heartbeat.rs
UTF-8
7,570
2.609375
3
[ "Apache-2.0" ]
permissive
use super::{TendermintSign, ValidatorAddress}; use amino::*; use bytes::{Buf, BufMut}; use hex::encode; use signatory::ed25519::{Signature, SIGNATURE_SIZE}; use std::io::Cursor; #[derive(PartialEq, Debug)] pub struct Heartbeat { validator_address: ValidatorAddress, validator_index: i64, height: i64, ro...
true
a924c6bf08e2a35b84cb7369478f58421f700d8a
Rust
petersellars/rust-workspace
/rust-gentle-intro/structs-enums-and-matching/generics.rs
UTF-8
375
3.625
4
[]
no_license
// struct Foo { // name: String // } fn dump<T> (value: &T) where T: std::fmt::Debug { println!("value is {:?}", value); } fn sqr<T> (x: T) -> T::Output where T: std::ops::Mul + Copy { x * x } fn main() { let n = 42; dump(&n); // let foo = Foo{name: "hello".to_string()}; // dump(&foo); ...
true
c29465ef37e740df0fb590e12b951382fefe82b2
Rust
zesterer/gui
/examples/test2.rs
UTF-8
2,435
3.53125
4
[]
no_license
pub trait Widget<D> { fn on<E>(mut self, f: impl FnMut(E, EventCtx<D, Self>) + 'static) -> Self where Self: Sized + Handler<D, E> { self.attach(f); self } fn finish<'a>(self) -> Element<'a, D> where Self: Sized + 'a { Element { widget: Box::new(self), ...
true
6e84d9875c7532b09473932e6416d560845a2c77
Rust
vdinovi/json_parser
/src/token/token.rs
UTF-8
1,391
3.609375
4
[]
no_license
use std::fmt; pub struct Token { pub tok_type: TokenType, pub data: TokenData, pub line_num: u32 } #[derive(Debug)] pub enum TokenType { LBrace, RBrace, LBracket, RBracket, Colon, Comma, String, Number, True, False, Null, Unknown } impl TokenType { ...
true
0c97470bc4381c8b6cc113fcbee0a0e30b54f6d8
Rust
tht-jxny/euler
/025/fibonacci.rs
UTF-8
553
3.015625
3
[]
no_license
fn main() { let mut a = vec![0]; let mut b = vec![1]; let mut n = 1; while b.len() < 1000 { let tmp = b.clone(); let mut carry = 0; for i in 0..b.len() { if i >= a.len() { a.push(0); } let mut digit = a[i]; digit = b...
true
10b370bd00e14a8245ff77bdfe75a75c5e4b15b5
Rust
fredhsu/rusteapi
/examples/shver.rs
UTF-8
1,506
2.75
3
[ "MIT" ]
permissive
extern crate hyper; use std::io::Read; use hyper::Client; use hyper::header::Basic; use hyper::header::Authorization; fn main() { // Create a client. let client = Client::new(); //let user = String.new("admin"); let basic = Basic{username: "admin".to_owned(), password: Some("admin".t...
true
03948de47f8b7b5d6af6ddc1b57732c89278bf7c
Rust
mkehrt/aoc2020
/day-6/src/main.rs
UTF-8
1,215
3.3125
3
[]
no_license
use std::{cmp::Eq, collections::HashSet, env, fs::read_to_string, hash::Hash, path::Path}; fn optional_intersection<T: Eq + Hash + Copy>( optional_left: Option<HashSet<T>>, right: HashSet<T>, ) -> Option<HashSet<T>> { optional_left .map(|left| left.intersection(&right).map(|x| *x).collect()) ...
true
de619edf897d03d0c2b0e0ec0aac65be2695f656
Rust
jeehoonkang/sparc
/src/bin/sparc.rs
UTF-8
867
2.953125
3
[]
no_license
extern crate clap; extern crate sparc; use clap::{App, Arg}; use sparc::Executor; use std::fs; fn main() { let matches = App::new("SPARC Interpreter") .version("0.1") .author("Jeehoon Kang <jeehoon.kang@sf.snu.ac.kr>") .about("Execute SPARC program") .arg( Arg::with_nam...
true
d6befcac3f47a8317f6b999c753394ba0c7dc16a
Rust
dakongyi2014/aiot-rust
/src/util/mod.rs
UTF-8
1,776
3.1875
3
[ "MIT" ]
permissive
//! 工具类 pub mod auth; pub mod error; use lazy_static::lazy_static; use rand::distributions::Alphanumeric; use rand::rngs::StdRng; use rand::Rng; use rand::SeedableRng; use std::sync::Mutex; pub const VERSION: Option<&'static str> = std::option_env!("CARGO_PKG_VERSION"); lazy_static! { pub static ref CORE_SDK_VER...
true
a3b3a98df6627e568538e056672e07c1578eb1ed
Rust
mbilker/kbinxml-rs
/kbinxml/src/encoding_type.rs
UTF-8
7,598
3.234375
3
[ "MIT" ]
permissive
use std::fmt; use std::string::FromUtf8Error; /// The `encoding_rs` crate uses the following to describe their counterparts: /// /// `SHIFT_JIS` => `WINDOWS_31J` /// `WINDOWS_1252` => `ISO-8859-1` use encoding_rs::{Encoding, EUC_JP, SHIFT_JIS, UTF_8, WINDOWS_1252}; use snafu::{ResultExt, Snafu}; #[derive(Debug, Sn...
true
3ba115d6688171cd891a5fc1b4ab50e0fcc219f8
Rust
VayuDev/red-peg
/src/code_tokenizer.rs
UTF-8
2,911
3.46875
3
[]
no_license
use regex::Regex; use std::fmt; #[derive(fmt::Debug)] pub struct CodeTokenizer { code: String, states: Vec<usize>, } impl CodeTokenizer { pub fn new(code: &str) -> CodeTokenizer { return CodeTokenizer { code: String::from(code), states: vec![0], }; } pub fn ...
true
d16f2169b841b5b777c2fb2f6b963a2a70626f88
Rust
ordovicia/atcoder
/ABC118/d/src/main.rs
UTF-8
4,378
2.65625
3
[]
no_license
#![allow(unused)] use std::{cell, cmp, collections, fmt, ops}; use cell::{Cell, RefCell}; use cmp::Ordering::{self, Equal, Greater, Less}; use collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; use fmt::{Debug, Display}; use ops::{ Add, AddAssign, Deref, DerefMut, Div, DivAssig...
true
170f5229a2e1dcdffede1c18eba0faa6dbf0d840
Rust
jidankim/rust-tdd-katas
/string-calculator/src/lib.rs
UTF-8
5,022
3.859375
4
[]
no_license
use std::num::ParseIntError; type Number = i64; type CalculatorResult = Result<Number, CalculatorError>; #[derive(Debug)] enum CalculatorError { ParseDelimiterError, ParseIntError(ParseIntError), } impl From<ParseIntError> for CalculatorError { fn from(err: ParseIntError) -> Self { CalculatorError::ParseInt...
true
4bfab6e1e15e87651d4011c8d9dd95494223d410
Rust
TimeEngineer/Graph
/dijkstra/src/structure.rs
UTF-8
9,038
2.703125
3
[]
no_license
use core::fmt::{Debug, Formatter}; use core::ops::Add; pub trait AdjencyMatrix<T: Copy + PartialOrd + Add<Output = T> + Debug> { fn inner(&self) -> &[T]; fn nb_vertex(&self) -> usize; fn infinite(&self) -> T; #[inline] fn neighbors(&self, i: usize) -> &[T] { let nb_vertex = self.nb_vertex()...
true
9c52bdee8377f3a1a0ea3615ed58abfad5aed551
Rust
eduadiez/ethereum-keys-sgx
/src/send_transaction.rs
UTF-8
1,245
2.546875
3
[ "MIT" ]
permissive
use std::result; use rlp::RlpStream; use error::AppError; use serde_json::Value; use itertools::Itertools; use utils::{get_infura_url}; use transaction::Transaction; use get_nonce::InfuraResponse; use reqwest::{Client, Response}; use sign_transaction::run as sign_transaction; type Result<T> = result::Result<T, AppErro...
true
8afe1361a84d6f635981e475781db1a0b16c6473
Rust
arthurlm/ngx-prom
/src/reader.rs
UTF-8
5,176
2.71875
3
[ "MIT" ]
permissive
use std::fmt::Display; use std::fs::File; use std::io::{self, BufRead, BufReader, Seek, SeekFrom}; use std::path::Path; use std::str::FromStr; use std::thread; use std::time::Duration; use crate::metrics::Metrics; use crate::parser::LogRow; static DURATION_NEXT_RETRY: Duration = Duration::from_millis(50); #[derive(D...
true
ff3192130fa3b58eb2981f918496864543b8a479
Rust
divvun/windivvun-service
/src/util.rs
UTF-8
3,661
2.609375
3
[]
no_license
use std::ffi::{OsStr, OsString}; use std::io; use std::mem; use std::os::windows::prelude::*; use winapi::ctypes::c_int; use winapi::shared::guiddef::GUID; use winapi::shared::wtypesbase::OLECHAR; use winapi::um::combaseapi::CoTaskMemAlloc; use winapi::um::winbase; use winapi::um::winnls::ResolveLocaleName; const LOCA...
true
0ff843bff1da473310d4612bcedcc191ef52963c
Rust
farico/openrtb2
/src/regs.rs
UTF-8
1,295
2.890625
3
[ "Apache-2.0", "MIT" ]
permissive
/// 3.2.3 Object: Regs /// /// This object contains any legal, governmental, or industry regulations that apply to the request. /// The coppa flag signals whether or not the request falls under the United States Federal Trade /// Commission’s regulations for the United States Children’s Online Privacy Protection Act //...
true
703f3350fe232c4b0c976e5c4eb86e316334b928
Rust
shioyama18/exercism
/rust/collatz-conjecture/src/lib.rs
UTF-8
272
3.078125
3
[]
no_license
pub fn collatz(mut n: u64) -> Option<u64> { let mut count = 0; loop { match n { 0 => return None, 1 => return Some(count), x if x % 2 == 0 => n /= 2, _ => n = 3 * n + 1, } count += 1; } }
true
0cdb104d42195e7470fa201484e701e21b040397
Rust
Nemo157/stylish-rs
/style/src/lib.rs
UTF-8
7,531
3.296875
3
[]
no_license
#![no_std] //! Internal implementation details of [`stylish-core`](https://docs.rs/stylish-core). //! //! Do not depend on this crate directly. #![warn(missing_copy_implementations)] #![warn(missing_debug_implementations)] #![warn(missing_docs)] #![warn(trivial_casts)] #![warn(trivial_numeric_casts)] #![warn(unused_e...
true
e2c2d324eaf90cadee7aee30326d4e09be4b446d
Rust
ruma/ruma
/crates/ruma-client-api/src/to_device/send_event_to_device.rs
UTF-8
2,809
3.015625
3
[ "MIT" ]
permissive
//! `PUT /_matrix/client/*/sendToDevice/{eventType}/{txnId}` //! //! Send an event to a device or devices. pub mod v3 { //! `/v3/` ([spec]) //! //! [spec]: https://spec.matrix.org/latest/client-server-api/#put_matrixclientv3sendtodeviceeventtypetxnid use std::collections::BTreeMap; use ruma_commo...
true
f0d31193ce9c53ef8a460614d5bb0ae924feb026
Rust
wizeman/rust-peg
/src/translate.rs
UTF-8
11,724
2.640625
3
[ "MIT" ]
permissive
use rustast; use rustast::DUMMY_SP; use rustast::AstBuilder; pub use self::RustUse::*; pub use self::Expr::*; pub struct Grammar { pub imports: Vec<RustUse>, pub rules: Vec<Rule>, } #[deriving(Clone)] pub enum RustUse { RustUseSimple(String), RustUseGlob(String), RustUseList(String, Vec<String>), } pub struct R...
true
d707220910a0ec53cde5dd379e7d32536350f5aa
Rust
astral-sh/ruff
/crates/ruff_python_literal/src/char.rs
UTF-8
541
2.90625
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use unic_ucd_category::GeneralCategory; /// According to python following categories aren't printable: /// * Cc (Other, Control) /// * Cf (Other, Format) /// * Cs (Other, Surrogate) /// * Co (Other, Private Use) /// * Cn (Other, Not Assigned) /// * Zl Separator, Line ('\u2028', LINE SEPARATOR) /// * Zp Separator, Para...
true
5cc74ca04526942e470c52b4bbff0393493fa49c
Rust
bevyengine/bevy
/crates/bevy_ecs/src/schedule/schedule.rs
UTF-8
64,814
2.75
3
[ "MIT", "Apache-2.0", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
use std::{ fmt::{Debug, Write}, result::Result, }; use bevy_utils::default; #[cfg(feature = "trace")] use bevy_utils::tracing::info_span; use bevy_utils::{ petgraph::{algo::TarjanScc, prelude::*}, thiserror::Error, tracing::{error, warn}, HashMap, HashSet, }; use fixedbitset::FixedBitSet; use...
true
4a744f1611d38b4fa0e01882c797fe61c1f48a1b
Rust
samWson/one-editor
/src/lib.rs
UTF-8
12,651
3.453125
3
[ "Unlicense", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain" ]
permissive
use std::fmt; use std::ops::Range; const DEFAULT_BUFFER_CAPACITY: usize = 10; const INITIAL_GAP_SIZE: usize = 10; /// GapBuffer is a datastructure designed for efficient local insertion and deletion operations. /// - `point`: The current index where operations are taking place. struct GapBuffer { buffer: Vec<u8>,...
true
bd405991d60b165eb2259214a1c45a8d0b78ed00
Rust
Svedrin/sunt
/src/oid.rs
UTF-8
2,332
3.109375
3
[ "MIT" ]
permissive
use snmp; use std::cmp::Ordering; use std::fmt; pub struct OID { oid_str: String, oid_vec: Vec<u32>, } impl OID { pub fn from_string(input: String) -> OID { let oid_str = input.to_owned(); let oid_vec = oid_str .split(".") .map(|i| i.parse::<u32>().unwrap()) ...
true
5736cf9b52b455b71aef8265304f5fd21d724126
Rust
jakubfijalkowski/aoc_2020
/src/bin/day17.rs
UTF-8
9,054
2.90625
3
[ "MIT" ]
permissive
#![feature(min_const_generics)] #![feature(iterator_fold_self)] #![feature(test)] extern crate test; use std::{collections::HashSet, fmt::Debug, ops::Sub}; use std::{hash::Hash, ops::Add}; trait Position: Eq + Copy + Hash + Add<isize, Output = Self> + Sub<isize, Output = Self> { type IntoIter: Iterator<Item = Se...
true
4e740fcc681e639e03f7e0a107513830e8f81da4
Rust
thallada/advent-of-code-2019
/day8/src/main.rs
UTF-8
3,635
3.328125
3
[]
no_license
use std::error::Error; use std::fmt; use std::fs::File; use std::io::{prelude::*, BufReader}; use std::result; const INPUT: &str = "input/input.txt"; type Result<T> = result::Result<T, Box<dyn Error>>; #[derive(Debug, PartialEq)] struct Image { layers: Vec<Layer>, } impl Image { fn final_layer(&self) -> Lay...
true
79c2d47587256cadf78b248b2a9318149b465b64
Rust
reinterpretcat/vrp
/vrp-core/src/algorithms/clustering/dbscan.rs
UTF-8
2,512
3.28125
3
[ "Apache-2.0" ]
permissive
//! This module contains an implementation of Density-Based Spatial Clustering of Applications with //! Noise (DBSCAN) #[cfg(test)] #[path = "../../../tests/unit/algorithms/clustering/dbscan_test.rs"] mod dbscan_test; use hashbrown::{HashMap, HashSet}; use std::hash::Hash; /// Represents a cluster of points. pub typ...
true
2ecaee3c558ede400f3737e8b9f45a5e746ebcf2
Rust
NoBugs-DMD/HotelManagementSystemBackend
/src/api/tests/account.rs
UTF-8
3,543
2.734375
3
[ "MIT" ]
permissive
use hyper; use hyper::client::request::Request; use hyper::header::{SetCookie, CookiePair}; use hyper::status::StatusCode; use rustc_serialize::json; use rand; use super::random_str; use super::response_body; use super::authorization::*; use ::proto::schema::*; use ::db::schemaext::*; use ::db::schema::*; use ::db::*;...
true
32a43151a59e2702ce3f6cfe3fa44dc8cfbdccba
Rust
mdg/leema
/src/leema/loader.rs
UTF-8
5,885
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::leema::canonical::Canonical; use crate::leema::failure::Lresult; use crate::leema::module::ModKey; use std::collections::HashMap; use std::env; use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; use std::sync::Mutex; use lazy_static::lazy_static; static mut TEXTS: Option<Vec<String>> =...
true
02ffeeda58a6cfe8ef939918389ce5565441ce10
Rust
bdalrhm/rmc
/src/test/cbmc/DynTrait/vtable_duplicate_field_override.rs
UTF-8
893
3.078125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT trait A { fn foo(&self) -> i32; } trait B { fn foo(&self) -> i32; } trait T: A + B { fn foo(&self) -> i32; } struct S { x: i32, y: i32, z: i32, } impl S { fn new(a: i32, b:...
true
405cfbd8be810c223d0d43f1d828aad986d68359
Rust
gyn/exercism
/rust/wordy/src/lib.rs
UTF-8
2,432
3.765625
4
[ "BSD-2-Clause" ]
permissive
pub struct WordProblem { cmd: String, } #[derive(PartialEq, Debug)] enum Token { CmdWhat, CmdIs, Number, Operator, OperatorBy, } enum Operator { Plus, Minus, Multiply, Divide, } impl WordProblem { pub fn new(command: &str) -> WordProblem { WordProblem { ...
true
fdf58f861c95e61662cc703768238f4dedb25ded
Rust
benjkelley/AdventOfCode-Rust-2020
/day4/src/main.rs
UTF-8
1,902
3.03125
3
[]
no_license
use std::fs; use std::collections::HashMap; fn main() { // read the input from the file let filename = "input_test.txt"; let contents = fs::read_to_string(filename) .expect("Could not read file"); let lines: Vec<&str> = contents.lines().collect(); let required_fields: [&str; 8] = ["by...
true
b086cfb681b3d9986ffe529410adf6abde9a4871
Rust
harpsword/tex-rs
/src/tex_the_program/section_0362.rs
UTF-8
3,043
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
//! ` ` // @<Read next line of file into |buffer|, or // |goto restart| if the file has ended@>= pub(crate) macro Read_next_line_of_file_into_buffer_or_goto_restart_if_the_file_has_ended($globals:expr, $lbl_restart:lifetime) {{ // begin incr(line); first:=start; incr!($globals.line); $globals.first = sta...
true
94a73b9fae638c20abc77069abf9a2e89f190c1d
Rust
4e6/bioinformatics
/examples/bioinformatics1/randomized_motif_search.rs
UTF-8
861
2.828125
3
[ "MIT" ]
permissive
extern crate bio; use std::env; use bio::data::Dataset; use bio::dna::{Dna, randomized_motif_search}; /// Code Challenge: Implement RandomizedMotifSearch. /// Input: Integers k and t, followed by a collection of strings Dna. /// Output: A collection BestMotifs resulting from running RandomizedMotifSearch(Dna, k, t) ...
true
f76210a90a0c39581c02ba7067f779ab46d7fb79
Rust
prz23/zinc
/zinc-compiler/src/semantic/scope/item/type/state.rs
UTF-8
2,228
3.125
3
[ "Apache-2.0" ]
permissive
//! //! The semantic analyzer scope type item state. //! use std::cell::RefCell; use std::rc::Rc; use crate::generator::statement::Statement as GeneratorStatement; use crate::semantic::element::r#type::Type as TypeElement; use crate::semantic::scope::item::r#type::statement::Statement as TypeStatementVariant; use cra...
true
b2332bd2214863fd7bfedc4a4e8f0a204388babe
Rust
9ary/rp2040-pac
/src/rosc/phase.rs
UTF-8
4,232
2.59375
3
[ "BSD-3-Clause" ]
permissive
#[doc = "Reader of register PHASE"] pub type R = crate::R<u32, super::PHASE>; #[doc = "Writer for register PHASE"] pub type W = crate::W<u32, super::PHASE>; #[doc = "Register PHASE `reset()`'s with value 0x08"] impl crate::ResetValue for super::PHASE { type Type = u32; #[inline(always)] fn reset_value() -> ...
true
292a72359c64564de28939425b2c69ef4d9a1550
Rust
floydawong/Dust
/src/objects/cpu_mesh.rs
UTF-8
864
2.65625
3
[ "MIT" ]
permissive
#[cfg(feature = "3d-io")] #[derive(serde::Serialize, serde::Deserialize, Debug)] pub struct CPUMesh { pub magic_number: u8, pub version: u8, pub indices: Vec<u32>, pub positions: Vec<f32>, pub normals: Vec<f32> } #[cfg(feature = "3d-io")] impl CPUMesh { pub fn new(bytes: &[u8]) -> Result<CPUMe...
true
81f33a05663e17cd6a359b9b068301975fb0bbb9
Rust
MaulingMonkey/minidl
/tests/kernel32.rs
UTF-8
1,700
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
#![cfg(windows)] #![allow(non_snake_case)] use minidl::*; use std::fmt::{self, Debug, Formatter}; use std::io::Result; use std::os::raw::*; #[allow(dead_code)] struct Example { OutputDebugStringA: unsafe extern "system" fn (_: *const c_char), Invalid_Optional: Option<unsafe extern "system" fn (_: *const c_c...
true
2cbdd6abb9508362ff421397f16a2daee1b00bb8
Rust
obeis/leetcode-rust-1
/src/string_to_integer_atoi.rs
UTF-8
3,173
3.671875
4
[]
no_license
/// @number 8 /// @title String to Integer (atoi) /// @url https://leetcode.com/problems/string-to-integer-atoi/ /// @difficulty Medium struct Solution; impl Solution { pub fn my_atoi(str_: String) -> i32 { use std::i32; let mut is_getting_number = false; let mut is_negative: Option<bool>...
true
ed0df33c4bcb0152c0a78b167e123512b5d974dc
Rust
last-Battle/do-think
/rust-main/rust-2021-3-5/Advanced/day28_advanced_traits/open_htrait3_call_method_same_name/src/main.rs
UTF-8
1,232
3.84375
4
[]
no_license
// 1 has self params // trait A { // fn print(&self); // } // struct MyType; // impl A for MyType { // fn print(&self) { // println!("A trait for MyType") // } // } // trait B { // fn print(&self); // } // impl B for MyType { // fn print(&self) { // println!("B trait for MyType")...
true
fbb32e2888508b0a5d95123ddf8dd50e7edfb182
Rust
rillrate-fossil/rillrate
/pkg-packs/basis/src/manifest/layouts/layout.rs
UTF-8
772
3.171875
3
[ "Apache-2.0" ]
permissive
use serde::{Deserialize, Serialize}; /* #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Position { pub left: i32, pub top: i32, } impl<L, T> From<(L, T)> for Position where L: Into<i32>, T: Into<i32>, { fn from((left, top): (L, T)) -> Self { Self { lef...
true
80384cc47e522dc9e198a630e7d956e410be4375
Rust
mockersf/concourse-resource-rs
/examples/simple_hello_world.rs
UTF-8
1,518
2.75
3
[ "MIT", "Apache-2.0" ]
permissive
use std::{fs::File, io::Write, path::Path}; use serde::{Deserialize, Serialize}; use concourse_resource::*; struct HelloWorld {} #[derive(Serialize, Deserialize)] struct Version { ver: String, } impl Resource for HelloWorld { type Version = Version; type Source = concourse_resource::Empty; type I...
true
492e5c0f3382aca65a7af8807101bf0559f90ab9
Rust
tomerhc/chessrust
/src/main.rs
UTF-8
4,079
2.953125
3
[]
no_license
mod pieces; mod board; mod game; use crate::pieces::Piece; fn main() { let mut board = board::Board::new(); let mut white_pawns= vec![]; for i in 0..8{ let mut pawn = pieces::Pawn::new(false); pawn.init(i, board.get_state(pieces::Pos(6,i))); white_pawns.push(pawn); } let mu...
true
b8649e68b15401210e5b83aeaa957c8608bd0388
Rust
peshwar9/warp-deadpool
/src/errors.rs
UTF-8
2,858
2.703125
3
[]
no_license
// Standard lib use std::convert::Infallible; // External crates - Primary use warp::{http::StatusCode, Rejection, Reply}; use tokio_postgres::error::Error as TokioError; use deadpool_postgres::PoolError as PoolError; // External crates - Utilities use serde::Serialize; use derive_more::{Display}; // Other internal m...
true
66bca7bb3e81ac3047d5417dd6e4b203394ba513
Rust
jojelen/sao
/src/main.rs
UTF-8
3,029
3.078125
3
[]
no_license
use crossterm::{style, Color}; use nix::unistd::execv; use regex::Regex; use std::env; use std::ffi::CString; use std::io; use std::io::Write; use subprocess::{Exec, Redirection}; fn split_line<'a>(line: &'a str, sep: &'static str) -> Option<(&'a str, &'a str)> { let sep_index: usize = line.find(sep)?; let (fi...
true
6a4fd18dc47250c05e00598de8630c93da176166
Rust
syohex/exercism
/rust/grains/src/lib.rs
UTF-8
219
3.171875
3
[ "MIT" ]
permissive
pub fn square(s: u32) -> u64 { if s == 0 || s > 64 { panic!("Square must be between 1 and 64") } 2u64.pow(s - 1) as u64 } pub fn total() -> u64 { (1u32..=64).fold(0, |acc, n| acc + square(n)) }
true
e33f7227ee8bdf5dd909765ca6f57e7d6266cf4f
Rust
ceciliacsilva/sm-rtfm
/sm/src/lib.rs
UTF-8
2,434
3.09375
3
[]
no_license
//! This is an adaptation of *SM* crate (https://docs.rs/sm/0.7.0/sm/) for embedded //! application using *RTFM* (https://github.com/japaric/cortex-m-rtfm). The main //! concepts are similar to the original crate, _states_, connected via _transitions, triggered //! by _events_, but these transitions are "guarded" by a ...
true
5185596a6e400d0fb7986d1f91feb6cd504a3d7c
Rust
msakuta/rust-gitgrep
/src/main.rs
UTF-8
12,348
2.859375
3
[]
no_license
use anyhow::{anyhow, Result}; use colored::*; use dunce::canonicalize; use git2::{Commit, ObjectType, Oid, Repository, Tree}; use regex::Regex; use std::{ collections::{HashMap, HashSet}, convert::{TryFrom, TryInto}, env, ffi::OsString, path::{Path, PathBuf}, }; use structopt::StructOpt; #[derive(D...
true
b0dedda3102fb08d802ab143f7c32e2e0f2b66c2
Rust
danieldulaney/prompt-line
/src/output.rs
UTF-8
952
2.921875
3
[ "MIT" ]
permissive
extern crate term; use std::marker::Sized; use std::boxed::Box; use term::Attr::Underline; use term::Attr::Italic; use parser; pub fn write_format<T: term::Terminal + ?Sized>(t: &mut Box<T>, format: &parser::Format, content: &str) { t.reset().unwrap(); match format.foreground { Some(color) => or_l...
true
902dacc2f89ab24434ad7f0805891769693769da
Rust
niofis/eccms
/src/main.rs
UTF-8
4,910
3
3
[]
no_license
use std::error::Error; use std::io::prelude::*; use std::io::BufReader; use std::net::{TcpListener, TcpStream}; use std::string::String; #[derive(Debug)] enum Command { Ehlo(String), Helo(String), Mail(String), Rcpt(String), Data, Rset, Noop, Quit, Vrfy, Unsupported, } #[derive...
true
760e56b312bc9c26384d41a679e4eae1b6ab5428
Rust
Lawliet-Chan/phala-pruntime
/vendor/bitvec/src/store.rs
UTF-8
35,120
3.234375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
/*! Bit management The `BitStore` trait defines constants and associated functions suitable for managing the bit patterns of a fundamental, and is the constraint for the storage type of the data structures of the rest of the crate. The other types in this module provide stronger rules about how indices map to concret...
true
ba04300c9655adfd245461006e10e6dbf8894733
Rust
zhiruchen/rust-code
/lifetime-param/src/main.rs
UTF-8
522
3.671875
4
[]
no_license
fn main() { println!("Hello, world!"); let x = String::from("longest string"); let y = "shorter str"; println!("the longest str is: {}", longest(x.as_str(), y)); let a = String::from("the long ong ong string"); { let b = String::from("the short str"); let result = longest(a.as_s...
true
bb2229c8064f8313dbf8c7c2b2a98c88e3567274
Rust
fintelia/spirq-rs
/src/parse.rs
UTF-8
2,924
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
use num_traits::FromPrimitive; use super::{Error, Result}; pub struct Instrs<'a>(&'a [u32]); impl<'a> Instrs<'a> { pub fn new(spv: &'a [u32]) -> Instrs<'a> { const HEADER_LEN: usize = 5; if spv.len() < HEADER_LEN { return Instrs(&[] as &[u32]) } Instrs(&spv[HEADER_LEN..]) } } impl<'a> I...
true
779990c45b83b3acbe162a91a9824a6c2d0e6146
Rust
hecrean/basic-webgpu-pointcloud-renderer
/src/mesh/sphere_mesh.rs
UTF-8
2,348
2.765625
3
[]
no_license
use crate::mesh::vertex::Vertex; #[repr(C)] #[derive(Copy, Clone, Debug, Default, bytemuck::Pod, bytemuck::Zeroable)] pub struct SphereMeshVertex { position: [f32; 3], // normal: [f32; 3], // tangent: [f32; 3], // bitangent: [f32; 3], // color: [f32; 4], // tex_coords_0: [f32; 2], // tex_c...
true
28411d88e72f7b3c2646e94430108dfc4e7aca6a
Rust
yehuohan/ln-os
/lnos/kernel/src/arch/x86_64/memory.rs
UTF-8
9,622
3.015625
3
[ "MIT" ]
permissive
//! 内存管理模块 //! //! bootloader在引导kernel前,已经做好分页表了; //! 并且将内存相关数据放到BootInfo,传递给kernel了。 //! //! bootloader使用Map the Complete Physical Memory对页表映射; //! 物理起始地址为0,对应的虚拟地起地址为physical_memory_offset; //! 地址本质是一个usize(CPU的地址宽度等于usize的位宽),可以作 //! 为VirtAddr或PhysAddr使用(类似于c中,将usize赋值给指针变量)。 //! memory_map保存了内存的起始地址、类型的等信息。 //! us...
true
f133597fb82433f162df34dfc189fdae269d3642
Rust
Horki/posix-intro
/rust/r_lab06.rs
UTF-8
752
3.1875
3
[]
no_license
mod semaphore; use semaphore::Semaphore; use std::sync::Arc; use std::thread; const NO_TH: usize = 5; fn main() { let mut handles = Vec::with_capacity(NO_TH); let sem = Arc::new(Semaphore::new(1)); for i in 1..=NO_TH { let sem = sem.clone(); handles.push(thread::spawn(move || { ...
true
05e17ff812fc1e75564279481982befc3ae3a6d1
Rust
kekonen/todo
/src/lib/task/mod.rs
UTF-8
1,646
3.25
3
[]
no_license
use regex::Regex; use serde::{Serialize, Deserialize}; use std::hash::{Hash, Hasher}; use std::collections::hash_map::DefaultHasher; // use rand::Rng; // const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\ // abcdefghijklmnopqrstuvwxyz\ // 0123456789"; // )(*&^%$#@!~ // fn random_string(size: usize) -> Strin...
true
5eb184ad7378947e9d3fb509e8489b19ca60b714
Rust
MarcusRainbow/pypyrust
/src/sets.rs
UTF-8
1,949
3.0625
3
[ "MIT" ]
permissive
use std::collections::HashSet; pub fn create_set(a: i64, b: i64) -> HashSet<i64> { return (a..b).collect::<HashSet<_>>(); } pub fn set_check_and_add(a: &mut HashSet<String>, item: &str) -> bool { if a.contains(item) { return true; } else { a.insert(item.to_string()); return false; ...
true
77881b86035f52a52cfcc3aaec46e9c0b65daded
Rust
emergent/ProjectEuler
/Rust/src/bin/035.rs
UTF-8
1,461
3.625
4
[ "Unlicense" ]
permissive
/// Problem 35 - Project Euler /// http://projecteuler.net/index.php?section=problems&id=35 use project_euler::prime::{is_prime, primes}; use std::collections::HashSet; fn rotate1(x: u64) -> u64 { if x / 10 == 0 { return x; } let mut xs = x.to_string().chars().collect::<Vec<char>>(); let top ...
true
9bc06c3c2a26d0a6f820bc56aad1256806f88d57
Rust
nilsys/tmc-langs-rust
/tmc-langs-core/src/tmc_core.rs
UTF-8
53,147
2.53125
3
[]
no_license
mod api; use crate::error::{CoreError, Result}; use crate::request::*; use crate::response::*; use crate::response::{Course, CourseDetails, Organization}; use crate::{Language, RunResult, ValidationResult}; use oauth2::basic::BasicClient; use oauth2::{ AuthUrl, ClientId, ClientSecret, ResourceOwnerPassword, Resou...
true
a7dd47c7d858829797ecb7874b26d08cb0cfe7c7
Rust
liuxinbo1984/Rust-Programming-in-Action
/algorithm/sort/bubble_sort/src/main.rs
UTF-8
554
3.1875
3
[ "Apache-2.0" ]
permissive
fn bubble_sort(mut nums: Vec<i32>) -> Vec<i32> { if nums.is_empty() { return vec![]; } for i in 0..nums.len() - 1 { let mut flag = false; for j in 0..nums.len() - i - 1 { if nums[j] > nums[j + 1] { let tmp = nums[j]; nums[j] = nums[j + 1]; ...
true
cbf0d2fbb85b835457f240e2bd94b7ef1ddc0221
Rust
uta8a/ant-book-rust
/library/binary_search/main.rs
UTF-8
977
3.15625
3
[]
no_license
mod vig { pub trait S { fn binary_search(&self, key: i64) -> i64; } impl S for Vec<i64> { fn binary_search(&self, key: i64) -> i64 { let mut ng: i64 = -1; let mut ok: i64 = self.len() as i64; loop { if (ok - ng).abs() <= 1 { ...
true
021bd13603cd41324df639bbb7524b6e63e31dce
Rust
KarelPeeters/unwrap-match
/src/lib.rs
UTF-8
627
3.5
4
[]
no_license
/// Like `Option::unwrap` but for arbitrary patterns. /// ``` /// # use unwrap_match::unwrap_match; /// assert_eq!(5, unwrap_match!(Some(5), Some(x) => x)); /// ``` /// ```should_panic /// # use unwrap_match::unwrap_match; /// // this will panic /// unwrap_match!(None, Some(x) => x); /// ``` #[macro_export] macro_rules...
true
1bee364eeb6935eb75fc22031e356e217dc4fb76
Rust
geofmureithi/hirola
/examples/canvas/src/tool.rs
UTF-8
2,319
2.53125
3
[ "MIT" ]
permissive
use hirola::prelude::*; use wasm_bindgen::JsCast; use wasm_bindgen::JsValue; use web_sys::Event; use web_sys::MouseEvent; #[derive(Clone)] pub struct SignTool { pub(crate) is_mouse_clicked: Mutable<bool>, pub(crate) is_mouse_in_canvas: Mutable<bool>, pub(crate) prev_x: Mutable<i32>, pub(crate) cur_x: M...
true
f9005cdab6d97a23f6f9d5047f82a633a07b2cc0
Rust
sam-plankis/config_press
/src/main.rs
UTF-8
5,453
2.84375
3
[ "MIT" ]
permissive
use std::fs; use std::io::{self, BufRead}; use std::path::Path; use clap::{App, load_yaml}; use env_logger; use indexmap::IndexMap; use log::{debug, error, log_enabled, info, Level}; use regex::Regex; fn main() { env_logger::init(); let yaml = load_yaml!("cli.yml"); let matches = App::from(yaml).get_matc...
true
915f14cbe61d3e495170dabdd632b70dd6f0d9dd
Rust
rconan/gmt-analytics
/src/ray.rs
UTF-8
6,487
3.375
3
[]
no_license
use super::{Arithmetic, Conic, Vector}; use std::fmt; /// # Ray definition /// /// A ray is defined with: /// - a point of origin: $\vec p = [x,y,z]$, /// - a direction vector: $\vec u = [k,l,m]$ such as $\| \vec u \|=1$. /// /// The ray tracing equation is given by: $$\vec{p^\prime} = \vec p + s \vec u,$$ where $s$...
true
dc7ce9c0b6de2029d9bf16adcc464f912ea26e9f
Rust
flix477/hecto
/src/core/posts/folder_entry.rs
UTF-8
1,727
3.140625
3
[ "MIT" ]
permissive
use crate::core::posts::folder::Folder; use crate::core::posts::Post; #[derive(Clone, Debug)] pub enum FolderEntry<P, F> { Post(P), Folder(F), } impl<P, F> FolderEntry<P, F> { pub fn as_ref(&self) -> FolderEntry<&P, &F> { match *self { FolderEntry::Post(ref post) => FolderEntry::Post(p...
true
b9ced18de7b83439fcbd35ff269adc7eaf1defea
Rust
bevyengine/bevy
/examples/shader/shader_defs.rs
UTF-8
3,049
2.9375
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
//! A shader that uses "shaders defs", which selectively toggle parts of a shader. use bevy::{ pbr::{MaterialPipeline, MaterialPipelineKey}, prelude::*, reflect::{TypePath, TypeUuid}, render::{ mesh::MeshVertexBufferLayout, render_resource::{ AsBindGroup, RenderPipelineDescr...
true