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
82c41734a0eee7087636d7f7083d4e04b95b1809
Rust
gurkodil/aoc-2019
/day10/src/main.rs
UTF-8
4,008
3.359375
3
[]
no_license
mod point; use std::collections::BTreeMap; use std::collections::HashSet; use std::fs; use point::Point; fn from_str(map: String) -> Vec<Point> { return map .lines() .enumerate() .map(|(y, r)| { r.chars().enumerate().filter_map(move |(x, r1)| { return if r1 == ...
true
f889af49961602095f5c6f9971b716b975d7d677
Rust
lloydmeta/rusqbin
/src/lib.rs
UTF-8
4,145
3.015625
3
[ "MIT" ]
permissive
#![doc(html_playground_url = "https://play.rust-lang.org/")] //! Rusqbin is a web server that stashes your requests for later retrieval. It is available as //! both a binary and a library. //! //! Rusqbin's web API is the following : //! //! - POST /rusqbins To create a bin and get back bin_id /...
true
28494195665111bf02965a814b62c4b8a3720d0d
Rust
winksaville/fuchsia
/src/lib/cobalt/rust/src/connector.rs
UTF-8
7,777
2.671875
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! Contains the logic for connecting to the Cobalt FIDL service, as well as setting up a worker //! thread to handle sending `CobaltEvent`s off of the mai...
true
f405224dc7ca2c08ef4a2686cd69c1eca0459a4f
Rust
namiwang/define
/src/main.rs
UTF-8
5,082
2.578125
3
[]
no_license
use std::collections::HashMap; extern crate clap; use clap::{App, Arg}; extern crate reqwest; // extern crate select; // use select::document::Document; // use select::predicate::{Predicate, Attr, Class, Name}; extern crate scraper; use scraper::{Html, Selector}; fn main() { let matches = App::new("Define") ...
true
0a4a922bd94de59952d9a2f3749290f31939c6d3
Rust
marco-c/gecko-dev-wordified
/third_party/rust/mio-extras/test/test_poll_channel.rs
UTF-8
9,241
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate : : expect_events ; use mio : : event : : Event ; use mio : : { Events Poll PollOpt Ready Token } ; use mio_extras : : channel ; use std : : sync : : mpsc : : TryRecvError ; use std : : thread ; use std : : time : : Duration ; # [ test ] pub fn test_poll_channel_edge ( ) { let poll = Poll : : new ( ) . unwrap...
true
33336302bc255819197ebf0e1cbec1d154eeee82
Rust
yarlett/bit-codes
/examples/make_bit_code_pool.rs
UTF-8
509
2.90625
3
[]
no_license
extern crate bit_codes; fn main() { // Parameters. let encoding_options = bit_codes::encoding_options::EncodingOptions::default(); let num_items = 10_000; let string_length = 25; // Initialize bit code pool. let mut bit_code_pool = bit_codes::bit_code_pool::BitCodePool::new(encoding_options); ...
true
43fbe5a8ed3a330bc068bde35efd9893da1c3ac8
Rust
nveskovic/indy-sdk
/libnullpay/src/services/config_ledger.rs
UTF-8
597
2.96875
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::sync::Mutex; lazy_static! { static ref FEES: Mutex<HashMap<String, i32>> = Default::default(); } pub fn set_fees(txn_name: String, txn_fee: i32) { let mut fees = FEES.lock().unwrap(); fees.insert(txn_name, txn_fee); } pub fn get_fee(txn_name: String) -> Option<i32>...
true
a0913e9641702338817e99770cc00afb21d536be
Rust
AliusEquinox/digit-rs
/src/operator.rs
UTF-8
3,347
3.5
4
[]
no_license
use digit::Digit; use std::cmp; type Carry = Digit; #[derive(Copy, Clone, Debug)] struct AdderResult(Digit, Carry); impl cmp::PartialEq for AdderResult { fn eq(&self, other: &AdderResult) -> bool { self.0 == other.0 && self.1 == other.1 } } fn single_digit_half_adder(a: &Digit, b: &Digit) -> AdderRe...
true
d7572ec2c7382301177701a1fe750acc8a0b0c12
Rust
KadoBOT/exercism-rust
/dot-dsl/src/graph_items/edge.rs
UTF-8
498
2.90625
3
[]
no_license
use super::attrs::Attributes; use std::collections::HashMap; #[derive(Debug, Clone, Eq, PartialEq)] pub struct Edge { left: String, right: String, attrs: HashMap<String, String>, } impl Edge { pub fn new(a: &str, b: &str) -> Self { Edge { left: a.to_string(), right: b.to_string(), attrs:...
true
aa86290a17aa5455d463040da12834699f8269ef
Rust
oxidecomputer/progenitor
/progenitor-impl/src/to_schema.rs
UTF-8
27,397
2.703125
3
[]
no_license
// Copyright 2023 Oxide Computer Company use indexmap::IndexMap; use openapiv3::AnySchema; use serde_json::Value; pub trait ToSchema { fn to_schema(&self) -> schemars::schema::Schema; } trait Convert<T> { fn convert(&self) -> T; } impl ToSchema for openapiv3::Schema { fn to_schema(&self) -> schemars::sc...
true
52b3a66b4471a687f37a5b3b44fd697667793a0b
Rust
kbernst30/rust-interpreter
/src/main.rs
UTF-8
678
2.828125
3
[]
no_license
pub mod interpreter; use interpreter::intr::Interpreter; use interpreter::lexer::Lexer; use interpreter::parser::Parser; use std::env; use std::fs; fn main() { // TODO file might not be present, if so drop to REPL let args: Vec<String> = env::args().collect(); let filename = &args[1]; println!("Runn...
true
c767ef68d9659e2755b437a2c96392c3255074a2
Rust
neodes-h/design-pattern-rust
/src/observer/main.rs
UTF-8
2,439
3.921875
4
[]
no_license
trait Observer { fn new(id: i32) -> Self; fn update(&self, data: u8); } trait Observable<'a, T: Observer> { fn attach(&mut self, observer: &'a T); fn detach(&mut self, observer: &'a T); fn notify(&self); } #[derive(PartialEq)] struct BinaryObserver { id: i32, } impl Observer for BinaryObserve...
true
9ef07f8bb3dc49d4bcbe2feaf8272f75b767dbfd
Rust
hoodielive/rust
/2021/recursive-fibonacci/src/main.rs
UTF-8
377
3.4375
3
[]
no_license
// fn+1 = fn + fn-1 // starting with f(1) = 1 and f(2) = 1 const FIB_ZERO: u64 = 1; const FIB_ONE: u64 = 1; fn fib(n: u64) -> u64 { if n == 0 { FIB_ZERO } else if n == 1 { FIB_ONE } else { fib(n - 1) + fib(n - 2) } } fn main() { for i in 1..41 { println!("{}: {}", i...
true
21e7eefabb0528774e97f7ee17300a306a6c9fa3
Rust
0x7CFE/cortex
/src/sound.rs
UTF-8
22,231
2.53125
3
[]
no_license
use std::sync::Arc; use std::f32::consts::PI; use std::collections::BTreeMap; use dft; use hound; use sample::*; use sample::window::Type; use num_traits::Float; use itertools::Itertools; use iter::CollectChunksExt; use rayon::prelude::*; use memory::*; use bit_vec::BitVec; // TODO Move to the Detector as indiv...
true
3c1382a652af4a64a3d0a3c995e29a2866b22c18
Rust
mikialex/rendiation
/scene/webgpu/src/shadow/allocator.rs
UTF-8
6,412
2.734375
3
[]
no_license
use crate::*; /// In shader, we want a single texture binding for all shadowmap with same format. /// All shadowmap are allocated in one texture with multi layers. #[derive(Clone)] pub struct ShadowMapAllocator { inner: Rc<RefCell<ShadowMapAllocatorImpl>>, } impl ShadowMapAllocator { pub fn new(gpu: ResourceGPUCt...
true
7a232c5d5f6ff7a54290e3f422cb877e0e2083a1
Rust
sempervictus/tunneler
/src/client/tunnel.rs
UTF-8
4,116
3
3
[ "MIT" ]
permissive
use std::error::Error; use std::net::IpAddr; use async_trait::async_trait; use tokio::net::TcpStream; use common::io::{copy, Stream}; #[async_trait] pub(crate) trait Tunneler: Send { async fn tunnel(&mut self, mut client: Stream) -> Result<(), Box<dyn Error>>; } pub(crate) struct TcpTunneler { tunneled: Str...
true
d474c01abd0e7999f032c0eb660d49b27fda1f4e
Rust
gengteng/impl-leetcode-for-rust
/src/integer_to_roman.rs
UTF-8
2,808
4.21875
4
[ "MIT" ]
permissive
/// # 12. Integer to Roman /// /// Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. /// /// Symbol Value /// I 1 /// V 5 /// X 10 /// L 50 /// C 100 /// D 500 /// M 1000 /// For example, two is wr...
true
76d42f8244e709973f2bd21602896ff21d5829da
Rust
marco-c/gecko-dev-wordified
/third_party/rust/rustc-demangle/src/legacy.rs
UTF-8
12,182
3.265625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core : : char ; use core : : fmt ; / / / Representation of a demangled symbol name . pub struct Demangle < ' a > { inner : & ' a str / / / The number of : : - separated elements in the original name . elements : usize } / / / De - mangles a Rust symbol into a more readable version / / / / / / All Rust symbols by de...
true
47dd63baf78725c86aff18bdb5fb08b7847be2b0
Rust
royswale/leetcode
/src/bin/best-time-to-buy-and-sell-stock.rs
UTF-8
287
2.875
3
[ "MIT" ]
permissive
fn main() {} struct Solution; impl Solution { pub fn max_profit(prices: Vec<i32>) -> i32 { let (mut r, mut min) = (0, prices[0]); for i in 1..prices.len() { r = r.max(prices[i] - min); min = min.min(prices[i]); } r } }
true
b30ff2cf54389611bb146b4aa686dc8ef3cbb15e
Rust
starcrossedRadio/ClearVM
/src/vm/code.rs
UTF-8
891
2.890625
3
[ "MIT" ]
permissive
use chashmap::CHashMap; use std::sync::Arc; use std::collections::HashMap; #[derive(Debug,PartialEq)] pub struct Module { pub code: Vec<u8>, pub jump_table: HashMap<u32,usize>, pub start_ip: usize } impl Module{ pub fn new(code: Vec<u8>,jump_table: HashMap<u32,usize>,start_ip: usize) -> Module { ...
true
76078c3dd47d3610d9c19d7d0314da21b4634722
Rust
naari3/unhonor
/src/main.rs
UTF-8
1,721
2.53125
3
[]
no_license
use std::io::Write; use std::fs::File; use regex::Regex; mod link_resource; use link_resource::{read_file, read_link_resources}; mod sed; use sed::link_resource_to_seds; use std::process::Command; fn main() -> Result<(), Box<dyn std::error::Error>> { let data = read_file("res_snd.bin"); let (_, link_resou...
true
0cff6bedb3bf5e911552319235cee7279e7f0f2a
Rust
MatthewSBarnes/metrix
/metrix/src/app.rs
UTF-8
3,117
2.875
3
[]
no_license
// "Re-exports important traits and types. // Meant to be glob imported when using Diesel." use diesel::prelude::*; use crate::lib::establish_connection; use crate::schema::metrics; use crate::models::*; use rocket_contrib::json::Json; use rocket::http::RawStr; use chrono::naive::NaiveDateTime; use diesel::sql_query;...
true
554f1e8137989d8201b64505598f3d89a2f38df8
Rust
scurest/apicula
/src/nds/texture_formats.rs
UTF-8
3,016
3.5
4
[ "0BSD" ]
permissive
//! NDS texture formats info. use super::TextureParams; #[derive(Copy, Clone)] pub struct TextureFormat(pub u8); pub enum Alpha { // Alpha = 1 Opaque, // Alpha = 0 or 1 Transparent, // 0 <= Alpha <= 1 Translucent, } impl TextureFormat { pub fn desc(self) -> &'static FormatDesc { ...
true
5acb52862bc77559805e7b966e71a05185875bae
Rust
dfinity-lab/agent-rs
/ic-agent/src/request_id/error.rs
UTF-8
3,179
3.28125
3
[ "Apache-2.0" ]
permissive
//! Error type for the RequestId calculation. use thiserror::Error; /// Errors from reading a RequestId from a string. This is not the same as /// deserialization. #[derive(Error, Debug)] pub enum RequestIdFromStringError { #[error("Invalid string size: {0}. Must be even.")] InvalidSize(usize), #[error("E...
true
46d710a1e89cecd76e054ab2f19eab8fa688e6c4
Rust
ashtneoi/hoot
/src/lib.rs
UTF-8
10,771
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
use http::{ Method, StatusCode, Uri, Version, }; use http::header::{ HeaderMap, HeaderName, HeaderValue, InvalidHeaderName, InvalidHeaderValue, }; use http::method::InvalidMethod; use http::uri::InvalidUriBytes; use lazy_static::lazy_static; use regex::bytes::Regex; use std::io; use ...
true
2e946517a8ac6c6e01149cf3602ad509b8ae7830
Rust
Pyxxil/rust-lc3-as
/src/token/tokens/stringz.rs
UTF-8
2,981
2.796875
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use crate::{ listing, token::{ tokens::{ expected, too_few_operands, traits::{Assemble, Requirements}, }, Token, }, types::{Listings, SymbolTable}, }; token!(Stringz); impl Assemble for Stringz { fn assembled( ...
true
e8feda6008c7a95e44e0e5b2fb6e0d90a5ded51e
Rust
socialdash/notifications
/src/models/sendgrid.rs
UTF-8
1,768
2.859375
3
[]
no_license
use mime::Mime; use stq_static_resources::*; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct SendGridPayload { pub personalizations: Vec<Personalization>, pub from: Address, pub subject: String, pub content: Vec<Content>, } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Personal...
true
b282558ac50073572ad7a96fccb8e61ebeedbd7e
Rust
MarcoIeni/svd
/src/parse.rs
UTF-8
923
3.59375
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Parse traits. //! These support parsing of SVD types from XML use xmltree::Element; /// Parse trait allows SVD objects to be parsed from XML elements. pub trait Parse { /// Object returned by parse method type Object; /// Parsing error type Error; /// Parse an XML/SVD element into it's corresp...
true
ab0f409ad004c149bd0a8095cf8e60a851a26a28
Rust
decentral-inc/nyc-blockchain-workshop
/Topic1/01_simple_web_server/src/main.rs
UTF-8
506
2.578125
3
[ "MIT" ]
permissive
use jsonrpc_core::*; use jsonrpc_http_server::*; use serde_derive::{Deserialize}; #[derive(Deserialize)] struct HelloParams { name:String, } fn main() { let mut io = IoHandler::new(); io.add_method("say_hello", |params: Params| { let parsed: HelloParams = params.parse().unwrap(); Ok(Value::String(format!("h...
true
6b3364586129125d99205f167c4cc2b00121a978
Rust
rapilab/jvm.rust
/src/rtda/jvm_stack.rs
UTF-8
481
2.671875
3
[]
no_license
use crate::rtda::frame::Frame; #[derive(Debug, Clone)] pub struct JVMStack { max_size: usize, size: usize, top: Option<Frame>, } impl JVMStack { pub fn new(_max_size: usize) -> JVMStack { JVMStack { max_size: 0, size: 0, top: None, } } pub f...
true
1bc15815716f4bad227782f79dcd2b3d66f025a6
Rust
siku2/AoC2018
/src/puzzles/mod.rs
UTF-8
1,492
2.96875
3
[ "MIT" ]
permissive
use std::io::BufRead; mod day1; mod day2; mod day3; mod day4; mod day5; mod day6; mod day7; mod day8; mod day9; mod day10; mod day11; mod day12; mod day13; mod day14; mod day15; mod day16; mod day17; mod day18; mod day19; mod day20; mod day21; mod day22; mod day23; mod day24; mod day25; pub fn solve<T>(day: u8, part:...
true
cf20a5a739eec187007930ed17f0d4172db4aadf
Rust
nyari/rtrace
/src/core/material.rs
UTF-8
8,557
2.984375
3
[ "MIT" ]
permissive
use core::{Color, ColorComponent, FresnelIndex, RayIntersection, LightIntersection}; use defs::FloatType; use tools::CompareWithTolerance; #[derive(Debug, Copy, Clone)] struct FresnelData { pub n: FresnelIndex, pub n_inverse: FresnelIndex, pub n_avg: FloatType, pub n_imaginary: FresnelIndex, pub n...
true
051bda546eed66d7b53dc2d49e78b214bd366cd6
Rust
Emre-Kul/rust-minesweeper
/src/core/game.rs
UTF-8
2,652
2.96875
3
[]
no_license
use std::io; use std::io::stdin; use std::ops::Add; use rand::Rng; use crate::core::terrain::{Terrain, BlockType}; use crate::core::level::Level; use std::borrow::Borrow; pub struct Game { pub is_bomb_found: bool, pub terrain: Terrain, } impl Game { pub fn create() -> Game { Game { i...
true
4ff61aa36db9de553c8f8e103caf565b322685c4
Rust
Zoxc/rust-clippy
/tests/ui/mem_discriminant.rs
UTF-8
1,437
2.6875
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>,...
true
43cf5f0e61c9c2a77279fafd97f33e7b85d2285d
Rust
suhanyujie/rust-repl
/src/command.rs
UTF-8
3,056
3.03125
3
[]
no_license
extern crate clap; use std::process::Command; use std::{collections::HashMap, io::Error}; use crate::statement::{self, Statement}; static CLI_NAME: &str = "simpleREPL"; /// 打印提示信息 fn print_prompt() { println!("{} >", CLI_NAME); } // 元指令匹配结果 #[derive(PartialEq, Eq)] pub enum MetaCmdResEnum { MetaCmdSuccess...
true
d3e22d400c04566bbd3c296bf5f612ed0796c75d
Rust
ntegan/project_euler
/zzz_print_problem_header/src/lib.rs
UTF-8
297
3.09375
3
[]
no_license
#[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } } pub mod header { // print the header for problem number pub fn problem(number: u64) { eprintln!("\ Problem {} ===========", number); eprint!("The answer is: "); } }
true
03b28630fdd57f9c83187d6f909abfce111e63c1
Rust
marot/nakama-rs
/tests/accounts.rs
UTF-8
1,671
2.75
3
[ "Apache-2.0" ]
permissive
use futures::executor::block_on; use nakama_rs::client::Client; use nakama_rs::default_client::DefaultClient; use std::collections::HashMap; #[test] fn test_get_account() { let client = DefaultClient::new_with_adapter(); let result = block_on(async { let mut session = client .authenticate_...
true
598c7c0c3b8d0ed95eff4033f882fb7d2e5af918
Rust
ktanaka101/monkey.rs
/src/parser/ast/mlet.rs
UTF-8
595
3.265625
3
[ "MIT" ]
permissive
use super::prelude::*; #[derive(Debug, Clone, PartialEq)] pub struct Let { pub name: Identifier, pub value: Expr, } impl Display for Let { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let out = format!("{} {} = {};", self.name, self.name, self.value); write!(f, "{}", out) } }...
true
b600b7f6fe60ac2734e660c2f4c995917b1ae7b3
Rust
ryanmt95/adventOfCode
/src/problems/day_four.rs
UTF-8
6,143
2.875
3
[]
no_license
pub mod passport_processing { use std::collections::{HashMap, HashSet}; use std::io::BufReader; use std::fs::File; use std::io::BufRead; use regex::Regex; pub fn part_one() -> i32 { let file_path = "./resources/day_four.txt"; let required_fields: HashSet<&str> = ["byr", "iyr", "...
true
ab382889a22b80bf75facb75a21344a97ae624ec
Rust
rroberts1990/Exercism
/rust/nth-prime/src/lib.rs
UTF-8
556
3.671875
4
[]
no_license
pub fn nth(n: u32) -> u32 { let mut counter = 0; let mut prime = 0; loop { if is_prime(prime) { if counter == n { return prime } counter += 1 } prime += 1; } } pub fn is_prime(n: u32) -> bool { if n <= 3 { return n > ...
true
6b646b3d1d08249eaf94e15d1500cff6ecb38013
Rust
quick-dom/quick-dom
/src/error.rs
UTF-8
1,534
2.921875
3
[ "Apache-2.0" ]
permissive
//! Provides an error type for this crate. //! copy from minidom create use std::convert::From; /// Our main error type. #[derive(Debug, Fail)] pub enum Error { /// An error from quick_xml. #[fail(display = "XML error: {}", _0)] XmlError(#[cause] ::quick_xml::Error), /// An UTF-8 conversion error. ...
true
7695e6e912b302e6c08fda8079e702a26cbab337
Rust
qiongtubao/search_index_test
/tantivy-0.10.2/src/query/query_parser/query_grammar.rs
UTF-8
9,859
2.53125
3
[ "MIT" ]
permissive
use super::query_grammar; use super::user_input_ast::*; use crate::query::occur::Occur; use crate::query::query_parser::user_input_ast::UserInputBound; use combine::char::*; use combine::error::StreamError; use combine::stream::StreamErrorFor; use combine::*; parser! { fn field[I]()(I) -> String where [I: Stre...
true
3bb309d2cf81fc5bcaac3a93531b1f7d291e5242
Rust
vnd/capstone-rs
/src/handle.rs
UTF-8
3,696
2.96875
3
[ "MIT" ]
permissive
use libc; use std; use std::ptr; use ffi; /// Handle to Capstone Engine instance pub struct Handle(ffi::CsHandle); impl Handle { /// Disassemble all instructions into a buffer pub fn disasm(&self, code: &[u8], addr: u64, count: isize) -> Result<Instructions, ::CsError> { let mut ptr: *const ffi::Insn ...
true
9ddd6f10bab66d61eb683ffad4878a0a29a411de
Rust
DelSkayn/rquickjs
/core/src/value/object/property.rs
UTF-8
13,359
2.875
3
[ "MIT" ]
permissive
use crate::{ function::IntoJsFunc, qjs, Ctx, Function, IntoAtom, IntoJs, Object, Result, Undefined, Value, }; impl<'js> Object<'js> { /// Define a property of an object /// /// ``` /// # use rquickjs::{Runtime, Context, Object, object::{Property, Accessor}}; /// # let rt = Runtime::new().unwrap...
true
eb5b82acd3a1acd84b8698f0fdd52476c281776f
Rust
defgenx/adventofcode
/2020/3/b/b.rs
UTF-8
1,536
2.96875
3
[]
no_license
use std::collections::HashMap; fn main() { b(); } fn b() { let list = advent_of_code::file::read_stream(); let mut total_trees: i64 = 1; let vec_rows: Vec<String> = list.map(|line| { line.unwrap() }).collect(); let mut slopes: Vec<HashMap<&str, i32>> = Vec::new(); s...
true
ceec21611140d2aad72ef695433f7414a2dcee0b
Rust
futile/ncollide
/ncollide_queries/point/point_bounding_sphere.rs
UTF-8
1,021
2.640625
3
[ "BSD-2-Clause" ]
permissive
use na::{Identity, Transform}; use point::PointQuery; use entities::shape::Ball; use entities::bounding_volume::BoundingSphere; use math::{Point, Vect}; impl<P, M> PointQuery<P, M> for BoundingSphere<P> where P: Point, M: Transform<P> { #[inline] fn project_point(&self, m: &M, pt: &P, solid: bool...
true
e61a7f450f990f0e523217ba1c9591db81ec53b2
Rust
berkowski/time
/src/format_description/well_known/rfc3339.rs
UTF-8
806
3.1875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! The format described in RFC 3339. /// The format described in [RFC 3339](https://tools.ietf.org/html/rfc3339#section-5.6). /// /// Format example: 1985-04-12T23:20:50.52Z /// /// # Examples /// /// ```rust /// # use time::{format_description::well_known::Rfc3339, macros::datetime, OffsetDateTime}; /// assert_eq!( ...
true
810efeccf2304d7389f2df5fb1288db9ea6272ac
Rust
ric2b/Vivaldi-browser
/chromium/third_party/rust/smawk/v0_3/crate/src/lib.rs
UTF-8
16,734
3.671875
4
[ "MIT", "BSD-3-Clause", "Apache-2.0", "LGPL-2.0-or-later", "GPL-1.0-or-later" ]
permissive
//! This crate implements various functions that help speed up dynamic //! programming, most importantly the SMAWK algorithm for finding row //! or column minima in a totally monotone matrix with *m* rows and //! *n* columns in time O(*m* + *n*). This is much better than the //! brute force solution which would take O(...
true
9509e377fe1596186df1f9d44cb714df6b8da9a0
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/hyper-0.14.19/src/client/mod.rs
UTF-8
2,137
3.140625
3
[ "BSD-2-Clause", "MIT" ]
permissive
//! HTTP Client //! //! There are two levels of APIs provided for construct HTTP clients: //! //! - The higher-level [`Client`](Client) type. //! - The lower-level [`conn`](conn) module. //! //! # Client //! //! The [`Client`](Client) is the main way to send HTTP requests to a server. //! The default `Client` provides ...
true
b8e695b9f785f6526ca5ba089c9de86331ec3d23
Rust
likr/atcoder
/arc003/src/bin/a.rs
UTF-8
618
2.703125
3
[]
no_license
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn...
true
a01fd96f7e75411e9d9e9fbe31c4f3a38dba868d
Rust
adamaho/tallii-backend
/src/services/events/comments/models.rs
UTF-8
1,146
2.625
3
[]
no_license
use serde::{Deserialize, Serialize}; use crate::services::users::models::PublicUser; /// Representation of a comment on an event #[derive(sqlx::FromRow, Deserialize, Serialize, Debug)] pub struct EventComment { pub comment_id: i32, pub event_id: i32, pub user_id: i32, pub comment: String, pub creat...
true
6570344cff9594dc38cc1843a05d6d137dfbe6f9
Rust
mdcg/a-tour-of-rust
/5-propriedade-e-emprestimo-de-dados/1-propriedade.rs
UTF-8
408
3.53125
4
[ "MIT" ]
permissive
// Instanciar um tipo e vinculá-lo a um nome de variável cria um // recurso de memória que o compilador Rust validará por toda sua // vida útil. A variável vinculada é chamada de proprietária do recurso. struct Foo { x: i32, } fn main() { // Instanciamos structs e vinculamos a variáveis // para criar rec...
true
dc9997874eeab63bdd94ef0c4e9e2d122c14ab59
Rust
m4b/goblin
/src/mach/relocation.rs
UTF-8
9,924
2.890625
3
[ "MIT", "BSD-3-Clause" ]
permissive
// Format of a relocation entry of a Mach-O file. Modified from the 4.3BSD // format. The modifications from the original format were changing the value // of the r_symbolnum field for "local" (r_extern == 0) relocation entries. // This modification is required to support symbols in an arbitrary number of // sections...
true
a5583e8f3a72c007b6635b8151c498c26f35f5b5
Rust
chorddown/chordr
/libchordr/src/models/meta/b_notation.rs
UTF-8
1,962
3.609375
4
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use serde::{Deserialize, Serialize}; use std::convert::TryFrom; use std::fmt; use std::fmt::{Display, Formatter}; use std::str::FromStr; /// Enum defining how the `B` is defined /// /// In some european countries the `B` chord is written as `H` #[derive(Deserialize, Serialize, PartialEq, PartialOrd, Clone, Copy, Debug...
true
0fc2c8527de2afc208d9ef369e80e4646f64b911
Rust
keithnoguchi/books-rs
/tokio/src/combinator.rs
UTF-8
809
3.046875
3
[]
no_license
// SPDX-License-Identifier: GPL-2.0 use futures::{self, Future}; // https://tokio.rs/docs/futures/combinators/ pub struct HelloWorld; impl Future for HelloWorld { type Item = String; type Error = (); fn poll(&mut self) -> futures::Poll<Self::Item, Self::Error> { const NAME: &str = "combinator::Hel...
true
6df11ce4bba7de9fcde086b38557b80748c542d4
Rust
placrosse/rust-kv
/src/lib.rs
UTF-8
2,577
3.046875
3
[ "ISC" ]
permissive
#![deny(missing_docs)] //! `kv` is a simple way to embed a key/value store in Rust applications. It is build on LMDB and //! aims to be as lightweight as possible, while still providing a nice high level interface. //! //! ## Getting started //! //! ```rust //! use kv::{Config, Error, Manager, ValueRef}; //! //! fn ru...
true
49b178b67a2da306988655bf3932002fb28f13cd
Rust
volodg/Algo2
/rust/algo/src/arrays/balanced_parenthes.rs
UTF-8
2,042
3.359375
3
[ "MIT" ]
permissive
//https://tproger.ru/problems/algorithm-that-displays-all-valid-combinations-of-pairs-of-brackets/ #[derive(Debug)] pub struct Solution { data: Vec<bool>, state: i16, capacity: i16 } impl Solution { fn initial(capacity: i16) -> Solution { Solution { data: vec![], state:...
true
cc29bf443599274eb608d788f9797887e53ed112
Rust
ClementTsang/bottom
/src/app/data_harvester/disks/unix/usage.rs
UTF-8
1,127
3.0625
3
[ "MIT" ]
permissive
pub struct Usage(libc::statvfs); // Note that x86 returns `u32` values while x86-64 returns `u64`s, so we convert everything // to `u64` for consistency. #[allow(clippy::useless_conversion)] impl Usage { pub(crate) fn new(vfs: libc::statvfs) -> Self { Self(vfs) } /// Returns the total number of by...
true
e67e7cc0b7d058710e54fa2c36a858a625d25dd7
Rust
digitalbitbox/bitbox02-firmware
/src/rust/vendor/num-bigint/src/biguint/monty.rs
UTF-8
6,874
3
3
[ "Apache-2.0", "MIT", "LGPL-3.0-or-later", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::std_alloc::Vec; use core::mem; use core::ops::Shl; use num_traits::{One, Zero}; use crate::big_digit::{self, BigDigit, DoubleBigDigit, SignedDoubleBigDigit}; use crate::biguint::BigUint; struct MontyReducer { n0inv: BigDigit, } // k0 = -m**-1 mod 2**BITS. Algorithm from: Dumas, J.G. "On Newton–Raphson...
true
ea4f3529f7ac2b447ece2818df216e474d28a228
Rust
cryptomental/lighthouse
/eth2/utils/bls/src/aggregate_public_key.rs
UTF-8
1,207
2.65625
3
[ "Apache-2.0" ]
permissive
use super::PublicKey; use milagro_bls::{AggregatePublicKey as RawAggregatePublicKey, G1Point}; /// A BLS aggregate public key. /// /// This struct is a wrapper upon a base type and provides helper functions (e.g., SSZ /// serialization). #[derive(Debug, Clone, Default)] pub struct AggregatePublicKey(RawAggregatePublic...
true
38f1c515b1a9612173b9a8e447a3a6d45ea9fd3e
Rust
konn/groebner-rs
/src/polynomial/unipol.rs
UTF-8
6,125
3.015625
3
[]
no_license
use crate::monomial::*; use crate::polynomial::Polynomial; use crate::ring::*; use crate::scalar::*; use num_traits::*; use std::collections::BTreeMap; use std::iter; use std::ops::*; use std::slice; use std::vec; #[derive(Clone, Debug, Eq, PartialEq)] pub struct Unipol<R> { coeffs: Vec<R>, } impl<R: Zero> Unipol...
true
925429668e91698b3e02cf273747608e4f99dbb0
Rust
ekhall/computationbook-rust
/src/universality_is_everywhere/iota/to_iota.rs
UTF-8
933
2.515625
3
[]
no_license
use universality_is_everywhere::ski_calculus::ski::{SKI}; use universality_is_everywhere::ski_calculus::skicombinator::{SKICombinator}; use super::iota::{iota}; pub fn to_iota(node: &Box<SKI>) -> Box<SKI> { match **node { SKI::SKISymbol(_) => node.clone(), SKI::SKICall(ref l, ref r) => SKI::skicall...
true
723b3bb1c9e637f8993153174827b5f3e6f13943
Rust
IThawk/rust-project
/rust-master/src/test/ui/issues/issue-64732.rs
UTF-8
359
2.890625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
#![allow(unused)] fn main() { let _foo = b'hello\0'; //~^ ERROR character literal may only contain one codepoint //~| HELP if you meant to write a byte string literal, use double quotes let _bar = 'hello'; //~^ ERROR character literal may only contain one codepoint //~| HELP if you meant to writ...
true
364fe6bae8dfa1e5088f801d2a13a5428fcc910f
Rust
vangroan/vuur
/crates/vuur_parse/src/func.rs
UTF-8
2,568
3.03125
3
[ "MIT" ]
permissive
//! Function declarations. use std::cell::Cell; use vuur_lexer::{Keyword, TokenKind}; use crate::block::Block; use crate::delim::Delimited; use crate::ident::Ident; use crate::stream::TokenStream; use crate::ty::Type; use crate::{Parse, ParseResult}; /// Function definition statement. #[derive(Debug)] pub struct Fun...
true
bbb5a8f41bb296ccce98fe88201b93aee8f07d25
Rust
jdatcmd/pgx
/pgrx-examples/arrays/src/lib.rs
UTF-8
5,128
2.5625
3
[ "MIT" ]
permissive
/* Portions Copyright 2019-2021 ZomboDB, LLC. Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <support@tcdi.com> All rights reserved. Use of this source code is governed by the MIT license that can be found in the LICENSE file. */ use pgrx::prelude::*; use pgrx::Array; use serde::*; pgrx::pg_module_...
true
142717149c9910dec99be426f78b5fd4f60bb4e2
Rust
artifice-network/manager
/ferrisvm/src/lib.rs
UTF-8
3,518
3.0625
3
[]
no_license
/*! # Purpose this crate is intended to be used as a pure rust cross platform virtual machine, for not only the purposes of security, but also extensibility !*/ #![feature(vec_into_raw_parts)] #[macro_use]extern crate err_derive; #[macro_use]extern crate serde_derive; pub mod error; pub mod opcode; use error::FerrisE...
true
83f5bab94b47d7aa8ab2d74b665ab4d0a5636878
Rust
unrust/gamepad-rs
/examples/test.rs
UTF-8
1,610
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate gamepad_rs; use std::thread; use std::time::Duration; use gamepad_rs::*; pub fn main() { let mut controller = ControllerContext::new().unwrap(); loop { println!("{} devices", controller.scan_controllers()); for i in 0..MAX_DEVICES { controller.update(i); ...
true
28597822c49ab41af210ce1fca3bc6293cf38c6a
Rust
podo-os/symengine.rs
/tests/expr.rs
UTF-8
318
3.109375
3
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
use symengine::Expression; #[test] fn simple_canonical() { let expr = Expression::new("a + b + 3"); assert_eq!(expr.as_str(), "3 + a + b"); } #[test] fn equal() { let expr1 = Expression::new("(a + 3) * (a - 3)"); let expr2 = Expression::new("a ** 2 - 9".to_string()); assert_eq!(expr1, expr2); }
true
c5cf173ec97cf6486ee4e2a42260dccc3413b700
Rust
luteberget/quoridor
/model/src/parser.rs
UTF-8
3,521
3.828125
4
[]
no_license
/// Get a move from a string on the form /// /// From wikipedia/quoriodor: /// The notation proposed is similar to algebraic chess notation. Each square /// gets a unique letter-number designation. Columns are labeled a through i /// from player 1's left and rows are numbered 1 through 9 from player 2's /// side to...
true
e151246abce3e528c6e918892423a187c068f1fc
Rust
dennisss/dacha
/pkg/automata/src/regexp/vm/compiler.rs
UTF-8
13,773
2.8125
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::fmt::Write; use std::iter::Iterator; use common::errors::*; use crate::regexp::node::*; use crate::regexp::symbol::invert_symbols; use crate::regexp::vm::instruction::*; pub struct Compilation { pub program: VecProgram, /// For each captured group in the original expr...
true
a3d7aa555310599c4925df2b8c4612bd1b2d841a
Rust
simpledomjs/quasar
/src/components/mod.rs
UTF-8
725
3.015625
3
[]
no_license
use std::collections::HashMap; #[cfg(feature = "mustache")] mod mustache; pub type Properties = HashMap<&'static str, String>; pub trait Renderable { /// Register interest in specific element properties /// /// Any property names returned will be queried for /// there value and added to `props` befor...
true
b3be48db58eb98c38f1fa52e2581d233c411d245
Rust
ashfordneil/class-queue
/backend/src/connection.rs
UTF-8
4,350
2.84375
3
[ "MIT" ]
permissive
use mio::net::TcpStream; use rustls::{ServerSession, Session}; use tungstenite::{self, Error, Message, WebSocket}; use tungstenite::handshake::{HandshakeError, MidHandshake}; use tungstenite::handshake::server::{NoCallback, ServerHandshake}; use std::io::{self, Read, Write}; use std::mem; use error::Result; /// TL...
true
eb332c709415273e73c21437e6e36b9577db135b
Rust
hsqlu/rust-iost
/chain/src/signature.rs
UTF-8
3,137
2.90625
3
[]
no_license
#![allow(unconditional_recursion)] use serde::{Serialize, Deserialize, Serializer}; use iost_derive::{Read, Write}; use std::str::FromStr; use crate::Error; #[derive(Clone ,Default, Debug, Write, Read)] #[iost_root_path = "crate"] pub struct Signature { /// Encryption algorithm. Currently only "ed25519"...
true
5862ab70b357a7240d4bdaeb7ffde4c7a8a5ffee
Rust
mmmpa/rust_simple_bbs
/src/data_gateway_adapter.rs
UTF-8
1,666
2.78125
3
[]
no_license
use std::ops::Range; use crate::common_error::BoxedError; pub trait DataGatewayAdapter: Send + Sync { fn show_board(&self, board_id: &str) -> Result<RawBoard, BoxedError>; fn show_thread(&self, board_id: &str, thread_id: &str, range: Range<usize>) -> Result<RawThread, BoxedError>; fn create_board(&self, p...
true
76c10510b333ec28233344d295fcea8ab3ba1465
Rust
wolf4ood/gremlin-rs
/gremlin-client/src/process/traversal/scope.rs
UTF-8
163
2.59375
3
[ "Apache-2.0" ]
permissive
#[derive(Debug, PartialEq, Clone)] pub enum Scope { Global, Local, } impl Into<Scope> for () { fn into(self) -> Scope { Scope::Global } }
true
7c64ebdb5dafb5c5481290a31146039388fbac6a
Rust
magiclen/educe
/tests/hash_struct.rs
UTF-8
11,422
2.765625
3
[ "MIT" ]
permissive
#![allow(clippy::trivially_copy_pass_by_ref)] #![cfg(feature = "Hash")] #[macro_use] extern crate educe; use core::hash::{Hash, Hasher}; use std::collections::hash_map::DefaultHasher; #[test] fn basic() { #[derive(Educe)] #[educe(Hash)] struct Unit; #[derive(Educe)] #[educe(Hash)] struct Str...
true
46f9a7ee090076ef61d4271a9030b40bd7fa1b2e
Rust
zct/rust_primer
/src/drop.rs
UTF-8
298
3.125
3
[]
no_license
struct CustomSmartPointer { data: String, } impl Drop for CustomSmartPointer { fn drop(&mut self) { println!("Dropping CustomSmartPointer with data {} !", self.data); } } fn main() { let c = CustomSmartPointer{ data : String::from("hello"), }; drop(c); }
true
786925cdbdd056f333a6b4d255b97f705933e009
Rust
vtavernier/tinygl
/tinygl-compiler/src/shader_kind.rs
UTF-8
1,396
3.3125
3
[ "MIT" ]
permissive
use std::path::Path; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub enum ShaderKind { Vertex, Fragment, Compute, } #[cfg(feature = "shaderc")] impl Into<shaderc::ShaderKind> for ShaderKind { fn into(self) -> shaderc::ShaderKind { match self { Self::Vertex => shaderc::Shader...
true
c377fc69dc9a08489341314c849695eed01b2f73
Rust
joshuaclayton/fnd
/src/path_check.rs
UTF-8
3,897
3.21875
3
[ "MIT" ]
permissive
use crate::Flags; use regex::{Regex, RegexBuilder}; use std::{fs::Metadata, path::Path}; pub struct Check<'a> { check: PathCheck<'a>, flags: &'a Flags, } impl<'a> Check<'a> { pub fn check(&self, path: &Path, metadata: Option<Metadata>) -> bool { match (&self.flags.size, metadata) { (So...
true
05013a61511fef23b0d09af6e7321976eb6d2dab
Rust
alexanderkjall/adventofcode2017
/src/day_12.rs
UTF-8
1,999
3.15625
3
[]
no_license
extern crate regex; use regex::Regex; use std::collections::HashMap; use std::collections::HashSet; mod input; struct Pipe { from: String, to: String } fn connections(pipes:&Vec<Pipe>, name:&String) -> Vec<String> { let mut to_ret:Vec<String> = Vec::new(); for p in pipes { if p.from == *nam...
true
b0e5c9ecc1dcae8853dd674fd0a2469974e823ad
Rust
jwilm/redis-rs
/tests/test_basic.rs
UTF-8
14,295
2.6875
3
[ "BSD-3-Clause" ]
permissive
extern crate redis; extern crate rustc_serialize as serialize; use redis::{Commands, PipelineCommands}; use std::process; use std::thread::spawn; use std::thread::sleep_ms; use std::collections::{HashMap, HashSet}; #[cfg(feature="unix_socket")] use std::path::PathBuf; pub static SERVER_PORT: u16 = 38991; pub static...
true
638a20a6b3cfa6bb8d9bf77b75ea4f64dde8b5f1
Rust
lytharn/rosalind
/src/config/tests.rs
UTF-8
1,628
2.5625
3
[]
no_license
use super::*; use std::path::Path; #[test] fn no_args_x_error() { let args = vec!["rosalind".to_string()]; let c = Config::new(args.into_iter()); assert!(c.is_err()); } #[test] fn one_arg_x_error() { let args = vec!["rosalind".to_string(), "file_path".to_string()]; let c = Config::new(args.into_i...
true
0f97bd9c20d367298a6bc901fe33798fb41d9520
Rust
wawuta/wzCore
/src/task/thread.rs
UTF-8
1,150
2.78125
3
[ "Apache-2.0" ]
permissive
use super::process::Process; use super::*; use crate::object::KObjectBase; use alloc::string::String; use alloc::sync::Arc; pub struct Thread { base: KObjectBase, name: String, proc: Arc<Process>, } impl Thread { pub fn create(proc: Arc<Process>, name: &str, options: u32) -> ZxResult<Self> { /...
true
da33d650e23e8e4dc09c96c3489d3921b65762db
Rust
wathiede/pbrt
/src/filters/box.rs
UTF-8
2,347
3.296875
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 Google LLC // // 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 // // https://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
ce8d99ff53757ec3ef7da55b128185cf975b1041
Rust
kawashige/aoj-rust
/ALDS/alds_1_7_c/src/main.rs
UTF-8
1,969
3.0625
3
[]
no_license
use std::io::Read; pub fn find_root(nodes: &Vec<Vec<i32>>) -> usize { (0..nodes.len()) .find(|i| nodes.iter().all(|n| !n.contains(&(*i as i32)))) .unwrap() } pub fn preorder_traversal(nodes: &Vec<Vec<i32>>, i: usize) { print!(" {}", i); if nodes[i][0] != -1 { preorder_traversal(nod...
true
8b8b70491eb173b7ebe0ab2e72297da1dc2c492f
Rust
shantanugoel/raytracer-rs
/src/lib/color.rs
UTF-8
2,949
3.546875
4
[]
no_license
use num::ToPrimitive; use crate::utils::is_eq_float; use std::ops::{Add, Mul, Sub}; // Common Colors pub enum CommonColor { Red, Green, Blue, Black, White, } impl CommonColor { pub fn value(&self) -> Color { match *self { CommonColor::Red => Color::new(1.0, 0.0, 0.0), ...
true
43fe722551fce9e5ab87f40b92f3e1c1ed94158b
Rust
greenladiesadmin/clonerio
/src/renderer/shader.rs
UTF-8
4,702
2.828125
3
[]
no_license
use cgmath::{Matrix, Matrix2, Matrix4, Vector3, Vector4}; use gl::types::*; use std::{ ffi::{CStr, CString}, fs, ptr, str, }; pub struct Shader { id: GLuint, } impl Shader { pub fn from_file(vs_path: &str, fs_path: &str) -> Self { let vs_source = fs::read_to_string(format!("assets/shaders/{}",...
true
1a7d9cb5370993998abff50d90d62037db85d45b
Rust
tzaeru/ANN-Digit-Recognizer
/src/network/network.rs
UTF-8
2,718
3.03125
3
[ "MIT" ]
permissive
use std::vec::Vec; use super::neuron; pub struct FeedFoward { inputs: Vec<neuron::Sigmoid>, hidden: Vec<neuron::Sigmoid>, outputs: Vec<neuron::Sigmoid>, } impl FeedFoward { pub fn new() -> FeedFoward { let mut feed = FeedFoward { inputs: Vec::with_capacity(::INPUT_N as usize), hidden: V...
true
00ef8d857e6568ed56a3fc1fa2ebf0af3d78d115
Rust
jiyilanzhou/chw
/book/tao_video/9_base_data_type.rs
UTF-8
9,991
3.5625
4
[]
no_license
/* 0. 类型系统 类型系统将表达式的值归类为具有特定意义的类型,机器码(由"0、1"组成)层面无法分清数据是字符还是整数,所以 需要使用类型赋予这些字节特定的意义。方便开发者开发,不同的类型有着不同的内存布局,类型间相互作用则可能 出现错误,造成内存不安全问题,所以一门语言拥有类型系统还不够,还必须做到类型安全。故需梳理类型系统。 1. 类型安全 Rust 类型系统承载的目标主要包括"保证内存安全、保证一致性、表达明确的语义及零成本抽象表达能力"。为达到 这四个目标,Rust 类型系统使用了两个相辅相成的概念:" 类型 "( Rust 中一切皆类型:针对不同场景精致地划分 不同...
true
cbbfa9dcd18e8d8b0a32522b50b1bb16ce10cefa
Rust
extrawurst/gitui
/asyncgit/src/sync/tags.rs
UTF-8
5,615
2.609375
3
[ "MIT" ]
permissive
use super::{get_commits_info, CommitId, RepoPath}; use crate::{ error::Result, sync::{repository::repo, utils::bytes2string}, }; use scopetime::scope_time; use std::{ collections::{BTreeMap, HashMap, HashSet}, ops::Not, }; /// #[derive(Clone, Hash, PartialEq, Eq, Debug)] pub struct Tag { /// tag name pub name: S...
true
4263809d702d6b4af09a46ea7690df6a4f95ffee
Rust
qoh/heightmap2brs
/src/util.rs
UTF-8
2,143
2.5625
3
[]
no_license
extern crate brs; use brs::*; use brs::{chrono::DateTime, uuid::Uuid}; type Pos = (i32, i32, i32); type Col = [u8; 3]; pub struct GenOptions { pub size: u32, pub scale: u32, pub cull: bool, pub tile: bool, pub snap: bool, } // Open an image file pub fn image_from_file(file: String...
true
5f04bc5fbffa5826486d9b53cec19dced125a6e9
Rust
Furl0w/cryptopals-rust
/src/set_1.rs
UTF-8
7,562
3.140625
3
[]
no_license
use base64; use hex; use std::fs::File; use std::io::{BufRead, BufReader, Read}; fn hex_to_64(hex: &String) -> String { let v = hex::decode(hex).unwrap(); println!("{}", String::from_utf8_lossy(&*v)); base64::encode(&v) } #[test] fn test_chall1() { let hex = String::from("49276d206b696c6c696e6720796f7...
true
4f5a7f8e036d3bf0d16a6fc03c5827cf334b2963
Rust
SfietKonstantin/qt-binding-generator
/src/gen/cpp/header/definition/accessor.rs
UTF-8
1,436
2.65625
3
[]
no_license
use def::{AccessKind, ObjectDefinition, Property}; use gen::core::{apply, Generate, ListGenerator}; use gen::cpp::utils::{camel_to_pascal, object_properties, return_type, setter_type}; use std::io::{Result, Write}; pub(super) fn gen_accessors<W>(write: &mut W, definition: &ObjectDefinition) -> Result<()> where W: ...
true
7fcfa92f44b747ce8cec136557c0154254acabfc
Rust
rick68/Cplusplus-Primer-Plus-6thE-Code-Example-With-Rust
/Chapter 4/assgn_st.rs
UTF-8
670
3.640625
4
[]
no_license
// assgn_st.rs -- assigning structures use std::io; use std::io::prelude::*; struct Inflatable { name: &'static str, #[allow(unused)] volume: f32, price: f64, } fn main() -> io::Result<()> { let mut stdout: io::Stdout = io::stdout(); let bouquet: Inflatable = Inflatable { name: "sunfl...
true
8e87a66dcc52563182bc103b5e3cdd8075b3455c
Rust
f-masche/advent-of-code-rust
/src/day_06.rs
UTF-8
1,175
3.15625
3
[]
no_license
use crate::puzzle::Puzzle; use itertools::Itertools; use std::collections::HashMap; pub fn run() { let a = Puzzle { name: "06-a", solution: solution_a, }; a.run_test("11"); a.run(); let b = Puzzle { name: "06-b", solution: solution_b, }; b.run_test("6"); b.run(); } fn solution_a(input...
true
70b160aa49a3dea5a2fab7cdaf3a5aab853f5083
Rust
itewqq/raytracer-rust
/raytracer/src/sphere.rs
UTF-8
1,855
2.984375
3
[ "MIT" ]
permissive
use crate::{HitRecord, Hittable, Material, Ray, Vec3}; use std::sync::Arc; pub struct Sphere { pub center: Vec3, pub radius: f64, pub material: Arc<dyn Material>, } impl Hittable for Sphere { fn hit(&self, ray: &Ray, t_min: f64, t_max: f64) -> Option<HitRecord> { let oc = ray.origin - self.cen...
true
93f95e6bfb05a93fe615ba35f8bba494359bb305
Rust
neuring/mpv_video_sync
/src/client/mpv/mod.rs
UTF-8
14,684
2.625
3
[ "MIT" ]
permissive
use std::{ collections::{HashMap, HashSet}, fmt, time::{Duration, Instant}, }; use anyhow::{anyhow, bail, Context, Result}; use async_std::{ io::BufReader, os::unix::net::UnixStream, prelude::*, sync::Mutex, task, }; use futures::{ channel::{mpsc::UnboundedSender as Sender, oneshot}, future, Fu...
true
1e62eb811ed199f02d1b619763df7e33709605d6
Rust
chibby0ne/exercism
/rust/luhn-from/src/lib.rs
UTF-8
2,263
3.96875
4
[ "MIT" ]
permissive
use std::fmt::Display; pub struct Luhn { value: String, } impl Luhn { pub fn is_valid(&self) -> bool { let length = self.value.len(); // Length <= 1 are invalid if length <= 1 { return false; } // Allocate a vector with as much capacity as there are chars ...
true
85737dc6241e788d0fe1444fed6f46845f273532
Rust
lsunsi/molde
/src/case.rs
UTF-8
152
2.5625
3
[ "MIT" ]
permissive
pub fn pascal(s: &str) -> String { let mut s = s.to_owned(); if let Some(c) = s.get_mut(0..1) { c.make_ascii_uppercase(); } s }
true
a4a062044348d945c3b03bb0286606e21e821098
Rust
garretthunyadi/rust_scratchpad
/src/scans4_.rs
UTF-8
714
3.203125
3
[]
no_license
use std::io::{Error, ErrorKind}; // domain = Domain::from("google.com"); pub fn main() -> Result<()> { println!("Scans4"); Ok(()) // Err(ScanError::Other(String::from("Bogus Error"))) // Err(ScanError::Unreachable) } // ensure valid domain pub enum ScanError { Unreachable, Other(String), } im...
true