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
bbe027452a0d02412bfbe7615c13fd74a91dc8ed
Rust
aydrian/og_image_writer
/og_image_writer/src/layout.rs
UTF-8
6,961
2.71875
3
[ "MIT" ]
permissive
mod container; mod img; mod text; use super::element::Element; use super::style::{AlignItems, JustifyContent, Margin, TextAlign}; use super::writer::OGImageWriter; use super::Error; impl<'a> OGImageWriter<'a> { pub(super) fn process(&mut self) { let total_height = if self.content.height > self.window.heig...
true
e08a6b0847014d27068b788d0178ecf388ca0ee5
Rust
linshaoyong/leetcode
/rust/src/easy/e1566_detect_pattern_of_length_m_repeated_k_or_more_times.rs
UTF-8
1,441
3.515625
4
[ "MIT" ]
permissive
struct Solution; impl Solution { pub fn contains_pattern(arr: Vec<i32>, m: i32, k: i32) -> bool { let mut count = 1; let m = m as usize; for i in 0..m { for j in (i + m..arr.len()).step_by(m) { if j + m > arr.len() { break; } ...
true
8ab0f7c6fe2a72640547113cfcfdb7f18483e021
Rust
FreeCX/advent-of-code
/2020/day05/src/seat.rs
UTF-8
574
3.484375
3
[ "CC0-1.0" ]
permissive
pub struct Seat { pub row: u8, pub col: u8, } impl Seat { pub fn identify(item: &str) -> Seat { let (l, r) = item.split_at(7); let mut row = 0; for i in l.chars() { row <<= 1; if i == 'B' { row += 1; } } let mut c...
true
8ba9813c598b3fdb9ff6c9eadb8fb5e02fbd5e42
Rust
roynalnaruto/core
/crates/sol-types/src/types/struct.rs
UTF-8
6,020
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module contains the [`SolStruct`] trait, which is used to implement //! Solidity structs logic, particularly for EIP-712 encoding/decoding. use super::{r#type::Encodable, SolType}; use crate::{token::TokenSeq, Eip712Domain, TokenType, Word}; use alloc::{borrow::Cow, string::String, vec::Vec}; use alloy_primit...
true
9d25ae082b27cd03245c4f447d1f35c407ab2101
Rust
andy-hanson/rs
/crates/check/src/inferrer.rs
UTF-8
3,658
2.71875
3
[]
no_license
use util::arena::Arena; use util::iter::KnownLen; use util::late::Late; use util::up::Up; use model::class::InstClass; use model::method::{MethodOrImplOrAbstract, MethodWithBody}; use model::ty::{Ty, TypeParameter}; use super::instantiator::InstantiatorLike; pub enum InferResult<'res, 'model: 'res> { AlreadyHave(&'...
true
b0b08d32c0fe19fb411f921d5069e98680bbe2db
Rust
boomshroom/Neos
/src/module.rs
UTF-8
3,071
2.8125
3
[ "MIT" ]
permissive
use spin::Mutex; //use mopa::Any; use core::ops::DerefMut; use core::any::{Any, TypeId}; use core::sync::atomic::{AtomicUsize, Ordering}; use terminal::vga::FrameBuffer; use terminal::Terminal; use terminal::serial::SerialPort; pub trait Module: Any + Send { fn receive_message(&mut self, op: u32, data: &[u8], ou...
true
d96f7d2e2a55722fded0c9cbc5375fe3a9ce8a97
Rust
JamieCrisman/monkey-rust
/src/parser/ast.rs
UTF-8
5,655
3.34375
3
[]
no_license
use crate::token::Token; use std::fmt; #[derive(PartialEq, Clone, Debug)] pub struct Ident(pub String); impl From<Token> for Ident { fn from(t: Token) -> Self { match t { Token::IDENT(a) => Self(a), _ => Self(String::from("unknown")), } } } #[derive(PartialEq, Debug, ...
true
7e86f7a16956c438ed5b70d87975a54b46d1d24f
Rust
bryanhelms/exercism-io
/rust/nth-prime/src/lib.rs
UTF-8
1,171
4.0625
4
[]
no_license
pub fn nth(n: u32) -> Option<u32> { // Okay, time to try this again match n { // Some easy wins first n if n == 0 => None, n if n == 1 => Option::from(2), n if n == 2 => Option::from(3), // Just start going through all the numbers and pull the nth prime. Really inefficien...
true
0fbad359f7ee0a16db0dc8e331014d492b60abaa
Rust
cj-greenhouse/aws-push-code
/src/submit.rs
UTF-8
8,995
2.75
3
[]
no_license
use crate::effect::file::{FileSystem, FileSystemTypes, ToFile, ToPath}; use crate::effect::repo::{Git, GitTypes}; use crate::effect::s3::{S3Types, S3}; use crate::effect::zip::{Zip, ZipTypes}; pub trait SubmitTypes { type Error; } pub trait Submit: SubmitTypes { fn submit_to_pipeline( &self, _...
true
78889424cb5b8d7d47c51b193917829864c56323
Rust
dpzmick/rust_img_dsl
/src/inputbuilder.rs
UTF-8
1,168
2.90625
3
[]
no_license
pub struct InputBuilder { id: usize } impl InputBuilder { pub fn build<E1: Expr + 'static, E2: Expr + 'static>(&self) -> fn(E1, E2) -> InputExpr { match self.id { 0 => { make_input!(input, 0); input }, ...
true
44d301684a444d69d014f603ed7ef463123f0f09
Rust
KanoczTomas/parse_bitcoin
/src/parsers/parse_tx_outputs.rs
UTF-8
1,917
2.875
3
[ "MIT" ]
permissive
use crate::{ parsers::parse_var_int, types::{TxOutput, TxOutputBuilder} }; use nom::{ multi::length_data, number::complete::le_u64, sequence::tuple, IResult }; pub fn parse_tx_outputs(input: &[u8]) -> IResult<&[u8], (Vec<TxOutput>, usize)> { let len_start = input.len(); let (mut input, ...
true
2126594e6df7c104b482e4ddc37e82d2c20736eb
Rust
shsandro/predecessor
/src/util.rs
UTF-8
1,696
3.109375
3
[ "Apache-2.0" ]
permissive
use fera::fun::vec; use fera::graph::algs::Kruskal; use fera::graph::prelude::*; use rand::prelude::*; use rand::XorShiftRng; pub fn new_rng_with_seed(x: u32) -> XorShiftRng { let b1: u8 = ((x >> 24) & 0xff) as u8; let b2: u8 = ((x >> 16) & 0xff) as u8; let b3: u8 = ((x >> 8) & 0xff) as u8; let b4: u8 ...
true
70b18c2f089e053b3f0778bc3680fa7f581f3e90
Rust
alanding1989/rust-demos
/rust_learn/src/io_example.rs
UTF-8
2,440
3.484375
3
[]
no_license
use std::fs::File; use std::io; use std::io::{ErrorKind, Read, Write}; use std::path::Path; #[allow(unused_must_use)] pub fn stdio_in() { let mut input = String::new(); io::stdin().read_line(&mut input).expect("WTF!"); println!("You typed: {}", input.trim()) } #[allow(unused_must_use)] pub fn stdio_out() ...
true
81bcb69eeefffab95e29872c0690b0eaba498aed
Rust
LukasKalbertodt/cantucci
/src/camera.rs
UTF-8
6,365
3.359375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops::Range; use cgmath::{Matrix4, Point3, Rad, Vector3, prelude::*}; /// This camera implementation always uses (0, 0, 1) as up-vector. Because the /// direction vector must never be linear dependent to the up-vector, we have /// limit the possible values theta can take. This is the "safe zone" that theta /...
true
9a40736d550fcc802968dfb8c0bc62ae081f85a0
Rust
clinuxrulz/int_fact
/src/circuit.rs
UTF-8
29,514
2.75
3
[]
no_license
use crate::{Anf, Sat, _3Sat, CNF}; use std::cmp::min; use std::collections::HashMap; use std::fmt; pub struct Circuit { pub gates: Vec<CircuitGate>, pub next_var_id: usize, pub var_names: HashMap<usize, String>, } pub struct CircuitAdderResult { pub out: CircuitVar, pub carry: CircuitVar, } impl ...
true
b6fb33bced6483ad117ace6641b16f403c307292
Rust
ijanos/euler-rust
/src/euler52.rs
UTF-8
580
3.328125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::collections::HashSet; fn same_digits(a: u64, b: u64) -> bool { let astr = a.to_string(); let bstr = b.to_string(); if astr.len() != bstr.len() { return false; } let aset: HashSet<char> = astr.chars().collect(); let bset: HashSet<char> = bstr.chars().collect(); aset == bs...
true
ebc7be8c13c1d226e08bd0f611c58f8f4af8b012
Rust
lazear/types-and-programming-languages
/07_system_fw/src/macros.rs
UTF-8
4,164
2.53125
3
[ "MIT" ]
permissive
#![allow(unused_macros)] /// Boolean term macro_rules! bool { ($x:expr) => { crate::terms::Term::new( crate::terms::Kind::Const(crate::terms::Constant::Bool($x)), util::span::Span::dummy(), ) }; } /// Integer term macro_rules! nat { ($x:expr) => { crate::term...
true
3fb745e74d1b39339ff6877db39fca47050f8417
Rust
didrikmunther/rust-lang-2
/src/error/mod.rs
UTF-8
3,762
3.34375
3
[]
no_license
use std::fmt; #[derive(Debug)] pub enum LexerErrorType { UnexpectedEndOfString, UnknownToken } #[derive(Debug)] pub enum ParserErrorType { Unknown, ExpectedSemiColon, UnexpectedToken, UnclosedParenthesis, UnclosedBrace, UnclosedBracket } #[derive(Debug)] pub enum CompilerErrorTyp...
true
6d94ac93fb9cdf8d0d8e952e781217061ce3f15c
Rust
Steelbirdy/poise
/src/prefix/argument/key_value_args.rs
UTF-8
3,646
3.578125
4
[ "MIT" ]
permissive
use super::*; /// A command parameter type for key-value args /// /// For example `key1=value1 key2="value2 with spaces"`. /// /// ```rust /// use poise::PopArgument; /// /// let string = r#"key1=value key2="value with spaces" "key with spaces"="value with \"quotes\"""#; /// let key_value_args = poise::KeyValueArgs::p...
true
f6c08fd1a306237f56e6ddc7db62abca247bd5d4
Rust
maciejhirsz/DEC64
/src/macros.rs
UTF-8
459
2.953125
3
[]
no_license
/// Shorthand for constructing Dec64 from raw value. macro_rules! dec64_raw { ( $value:expr ) => ( Dec64 { value: $value } ) } /// Shorthand for constructing Dec64 from raw parts. macro_rules! dec64_parts { ( $coefficient:expr, $exponent:expr ) => ( // Double casting on exponent so we don't end up w...
true
3c7cf1b16dd26009dbb7a263501b1d965a12d729
Rust
mattiast/aoc2019
/src/day10.rs
UTF-8
2,022
3.40625
3
[]
no_license
use num::complex::Complex; use num::integer::gcd; use std::collections::HashSet; use std::f64; use std::fs::File; use std::io::{self, prelude::BufRead, BufReader}; type Point = (i32, i32); pub fn read_input() -> io::Result<Vec<Point>> { let file = File::open("data/input10.txt")?; let reader = BufReader::new(fi...
true
12f8d230045694ad1bb650dca8829ed7bab7efa5
Rust
jinlf/yawa
/src/lexer.rs
UTF-8
16,094
3.21875
3
[]
no_license
use crate::token::*; #[derive(Debug)] pub enum LexError { LexError, ParseIntError(std::num::ParseIntError), } impl From<std::num::ParseIntError> for LexError { fn from(e: std::num::ParseIntError) -> Self { Self::ParseIntError(e) } } pub struct Lexer { input: String, pos: usize, rea...
true
da589274a1a731657fdd2edcea06281e3a405f86
Rust
BrainWiggans/Ellie-Language
/parser/src/syntax/function.rs
UTF-8
2,318
2.765625
3
[ "MIT" ]
permissive
use crate::parser::Collecting; use crate::syntax::definers; use alloc::string::String; use alloc::vec::Vec; use ellie_core::defs; use serde::{Deserialize, Serialize}; #[derive(PartialEq, Debug, Clone, Serialize, Deserialize, Default)] pub struct FunctionParameter { pub name: String, pub rtype: definers::Define...
true
0a3dc67b8bab3956023fa3d728b082126d524ad7
Rust
jiyilanzhou/chw
/book/tao_of_rust/chp3/0_concept_type_infer.rs
UTF-8
14,486
3.515625
4
[]
no_license
/* 类型系统 计算机以二进制形式存储信息,故无论何种数据对计算机而言皆为字节序列(即" 0 和 1 "的排列),若使用 " 0 和 1 "来存储、表示及处理各种信息则必然会产生过大的心智负担故类型应运而生。 3.1 通用概念 a. 所谓类型即是对数据进行细粒度的区分(如整数、小数、文本等(更细粒度为布尔值、有无符号整形、单双 精度浮点数、字符与字符串及自定义类型等) b. 不同类型占用的内存不同,与直接操作比特位相比,直接操作类型可更安全、更有效利用内存如创建一个 u32 类型则 Rust 会自动分配 4 个字节来存储该值 c. 类型系统是编程语言的基础和核...
true
93eb79e57a60ce3c5104b21e2eb0fe746ab081d7
Rust
pragmatrix/emergent
/src/lib/libtest.rs
UTF-8
8,825
2.75
3
[]
no_license
// https://github.com/rust-lang/libtest/blob/master/libtest/formatters/json.rs use failure::Fail; use serde_json::Value; use std::convert::TryInto; use std::io; use std::io::{BufRead, BufReader, Read}; // TODO: make that Vec private. // TODO: Use some kind of a newtype macro here? #[derive(Clone, PartialEq, Eq, Defau...
true
6155b7fa0a705eb33ef2d7b015ae4a2522023003
Rust
fveilly/rink-runtime
/src/error.rs
UTF-8
1,882
3.109375
3
[ "MIT" ]
permissive
use std::error; use std::fmt::{self, Debug, Display}; use std::io; use std::result; use serde_json; #[doc(hidden)] #[derive(Debug)] pub enum InkErrorCode { Message(String), Io(io::Error), Json(serde_json::Error), } #[derive(Debug)] pub struct InkError { code: InkErrorCode } impl InkError { pub f...
true
58ef857cb5923081d1c19a87a7abbd3123d2d538
Rust
pondodev/advent-of-code-2020
/day2/src/main.rs
UTF-8
2,241
3.3125
3
[]
no_license
use std::fs::File; use std::io::{self, BufRead}; fn main() { let f = File::open("input").expect("failed to open file"); let lines = io::BufReader::new(f).lines(); let mut input: Vec<String> = vec![]; for line in lines { input.push(line.expect("failed to read line")); } solve_one(&inpu...
true
248d788b5029aa80965147170d77b24bae49f0e7
Rust
sammyne/encoding-rs
/crates/base64/tests/decode.rs
UTF-8
7,718
2.78125
3
[]
no_license
use std::{ io::{self, Read}, sync::mpsc::{self, Receiver}, thread, time::Duration, }; use base64::{Encoding, RAW_STD_ENCODING, STD_ENCODING}; mod testbot; #[test] fn decode() { for (i, p) in testbot::PAIRS.iter().enumerate() { for tt in testbot::ENCODING_TESTS.iter() { let enc...
true
97c13b6be7ba1fc4ca5b3d100e94ac92ceaf6f44
Rust
boxdot/osmflat-rs
/osmflat/examples/count.rs
UTF-8
607
2.9375
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "LGPL-3.0-only", "LicenseRef-scancode-public-domain" ]
permissive
//! Counts the number of nodes, ways, and relations in the input archive. //! //! LICENSE //! //! The code in this example file is released into the Public Domain. use osmflat::{FileResourceStorage, Osm}; fn main() -> Result<(), Box<dyn std::error::Error>> { let archive_dir = std::env::args() .nth(1) ...
true
791f2adadf876f33b48f8e0e650bd3e8b3e5660b
Rust
tmsdev82/rust-jwt-tutorial
/src/main.rs
UTF-8
1,377
2.859375
3
[]
no_license
use chrono::{Duration, Utc}; use jsonwebtoken::{decode, encode, DecodingKey, EncodingKey, Header, Validation}; use serde::{Deserialize, Serialize}; use std::{thread, time}; #[derive(Deserialize, Serialize, Debug)] struct Claims { sub: String, iat: usize, exp: usize, test: String, } fn main() { let...
true
37983db7a8abc65f76f15eda8a2528ab4ba0ebc7
Rust
matemagyari/rust-examples
/tests/enums_test.rs
UTF-8
761
3.21875
3
[]
no_license
#[cfg(test)] mod tests { // Note this useful idiom: importing names from outer (for mod tests) scope. use super::*; #[test] fn test_enums() { enum Event { Login { user: i32, pw: i32 }, Shutdown, Misc(i32), } fn translate(e: Event) -> i32 { ...
true
4e1c8bfe3be45aa11dcf1300ff835206dd79586e
Rust
casey/intermodal
/bin/gen/src/bin.rs
UTF-8
719
2.71875
3
[ "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
use crate::common::*; pub(crate) struct Bin { path: PathBuf, pub(crate) subcommands: Vec<BinSubcommand>, } impl Bin { #[throws] pub(crate) fn new(path: &Path) -> Bin { let mut bin = Bin { path: path.into(), subcommands: Vec::new(), }; bin.add_subcommands(&mut Vec::new())?; bin.su...
true
34733a003abca99b1cc243d7d0b3d74615076f16
Rust
aQaTL/advent_of_code_2019
/day_10/src/main.rs
UTF-8
1,708
3.203125
3
[]
no_license
use std::collections::HashMap; fn main() { let input = std::fs::read_to_string("day_10/input.txt") .unwrap() .lines() .map(|line| line.chars().collect::<Vec<_>>()) .collect::<Vec<Vec<char>>>(); let mut points = Vec::new(); for (j, line) in input.iter().enumerate() { for (i, &point) in line.iter().enumera...
true
3c625cc99fd23d7e6453f27d1104800171d2f362
Rust
dougreichard/artemis_python
/modules/sbs_tools/src/www/mod.rs
UTF-8
2,035
3.078125
3
[]
no_license
use std::net::{TcpStream, TcpListener}; use std::io::{Read, Write}; use std::thread; use pyo3::prelude::*; use std::sync::Arc; use std::time::{Duration, SystemTime}; #[pyclass] pub struct HttpServer { } struct HttpConnectedClient { stream: TcpStream } impl HttpConnectedClient { fn handle_read(&mut self...
true
a1606a8c840fb6b4696c125331066448005e08db
Rust
danshiovitz/adventofcode
/2020/day09/src/main.rs
UTF-8
2,237
3.390625
3
[ "LicenseRef-scancode-public-domain" ]
permissive
use failure::Error; use std::collections::HashSet; use std::io::{BufReader,BufRead}; use std::fs::File; fn parse_int(val: &str) -> Result<i64, Error> { return Ok(val.parse::<i64>()?); } fn read_input(file: &str) -> Result<Vec<i64>, Error> { let f = File::open(file)?; let br = BufReader::new(f); return...
true
a89b7809b72abe8181e7e561d9c152f3228ba00d
Rust
luk036/luk036.github.io
/rust_by_examples/vdc.rs
UTF-8
328
2.890625
3
[]
no_license
fn vdc(mut k: u32, base: u32) -> f64 { let mut vdc = 0.0; let mut denom = 1.0; while k != 0 { denom *= base as f64; let rem = k % base; k /= base; vdc += (rem as f64) / denom; } vdc // <- note! } fn main() { for k in 1..11 { println!("{}", vdc(k, 2)); ...
true
3f9ce9f0e26217871eb534f826bbbc546c1e83c1
Rust
oOBoomberOo/ribozyme
/src/workspace.rs
UTF-8
2,997
2.765625
3
[ "MIT" ]
permissive
use super::{Asset, Resourcepack}; use anyhow::Result; use glob::Pattern; use lazy_static::lazy_static; use log::*; use std::{ fs::DirEntry, io, path::{Path, PathBuf}, }; use superfusion::criteria::Composite; use superfusion::prelude::{Index, Pid, Strategy}; fn criteria() -> Composite { Composite::new() .with(|pa...
true
b104a2d1864cda628e712464062c3f2541d1e92e
Rust
mesainner/crates-io
/vendor/standback/build.rs
UTF-8
1,518
3.046875
3
[ "Apache-2.0", "MIT", "Unlicense", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{env, process::Command, time::SystemTime}; /// Return the minor version of the compiler currently in use. /// `None` is returned if a version cannot be determined. fn compiler_in_use() -> Option<usize> { let raw_output = Command::new("rustc") .args(&["--version", "--verbose"]) .output() ...
true
fcc956f271d6a780a89bd25226906f585e6d1d90
Rust
chyyuu/minidecaf-rv64
/src/compiler/native_code_generator.rs
UTF-8
4,866
2.96875
3
[]
no_license
// use crate::compiler::*; use std::collections::HashMap; pub fn generate_native_code(mid_commands: &Vec<String>) -> Vec<String> { let mut native_commands = Vec::new(); native_commands.push(String::from(".global main")); native_commands.push(String::from("main:")); native_commands.push(format!("\tmv s0...
true
96329f43ffdb9f4f516487ab59f9dffbf2719049
Rust
chinanf-boy/gentle-intro
/code/life3.rs
UTF-8
185
3.375
3
[ "MIT" ]
permissive
// life3.rs #[derive(Debug)] struct A <'a> { s: &'a str } fn main() { let string = "I'm a little string".to_string(); let a = A { s: &string }; println!("{:?}",a); }
true
ba13ac2b28eefa974d2dd298937ecde96d5917d4
Rust
nambrosini/adventofcode
/2017/src/day11.rs
UTF-8
2,245
3.65625
4
[]
no_license
use itertools::Itertools; use std::convert::{From, Into}; use std::ops::Add; #[aoc_generator(day11)] pub fn generator(input: &str) -> Vec<Direction> { input.split(',').map(|x| x.into()).collect_vec() } #[aoc(day11, part1)] pub fn part1(input: &[Direction]) -> i32 { let mut position = Position::new(0, 0); ...
true
19d151447b45e80aff12e120a0e9ab77820e4f32
Rust
19870213/matasano-crypto-rust
/src/set1/exercise1.rs
UTF-8
2,303
3.21875
3
[]
no_license
pub fn from_hex(hex_input: &str) -> Vec<u8> { static HEX_0:u8 = ('0' as u8); static HEX_A:u8 = ('a' as u8); let mut output:Vec<u8> = vec![]; let mut buffer:u8 = 0; let mut count:u8 = 1; for c in hex_input.chars() { let lower_c = c.to_lowercase().next().unwrap(); let ic:u8 = ((lower_c as u32) & ...
true
f5167070c6cd6c6240bf94a83395b494e1815dc2
Rust
doyoubi/Blastoise
/src/test/parser/test_sem_check.rs
UTF-8
15,111
2.65625
3
[]
no_license
use ::store::table::{TableSet, Table, Attr, AttrType}; use ::parser::condition::ConditionExpr; use ::parser::compile_error::CompileErrorType; use ::parser::select::SelectStatement; use ::parser::update::UpdateStatement; use ::parser::insert::InsertStatement; use ::parser::delete::DeleteStatement; use ::parser::c...
true
9252ab4cd00fee97c30c4c37d28f6013310f1370
Rust
omegablitz/gluon-bug
/src/main.rs
UTF-8
2,219
2.78125
3
[]
no_license
use gluon::ThreadExt; use serde_state::ser::SerializeState; use serde_state::de::DeserializeState; fn serialize_value(value: gluon::vm::Variants, ser_state: &gluon::vm::serialization::SeSeed) -> Box<[u8]> { let mut buffer = Vec::new(); { let mut ser = serde_json::Serializer::pretty(&mut buffer); ...
true
c4d640fe88a6775b8a081aa56140a99c6e0231dc
Rust
DouglasOrr/Snippets
/rustdojo/src/main.rs
UTF-8
2,508
2.984375
3
[ "MIT" ]
permissive
/// Some basic image helper utilities for the Mandelbrot rendering Dojo. pub mod util; /// Our custom, beautiful, Mandelbrot rendering. pub mod mandelbrot; extern crate image; extern crate num; extern crate argparse; fn main() { // Parameters let mut iterations = 20; let mut width_px = 500u32; let (m...
true
40a60d9f238645058ddf77642d89d44492b16072
Rust
PurpleMyst/aoc-2020
/day23/src/lib.rs
UTF-8
4,627
3.171875
3
[ "MIT" ]
permissive
#![feature(new_uninit)] use std::fmt::Display; /// How many cups do we pick up? const PICKUP_NUM: usize = 3; const MOVES_PART1: usize = 100; const CARDS_PART1: usize = 10; const CARDS_PART2: usize = 1_000_001; const MOVES_PART2: usize = 10_000_000; pub struct CupsDisplay { successors: [u8; CARDS_PART1], } im...
true
62b32e4e74433b73933ce5e090cb3a3fc5c03133
Rust
wulu90/leetcode
/src/convert_bst_to_greater_tree.rs
UTF-8
1,483
3.71875
4
[]
no_license
/** * 538. Convert BST to Greater Tree * * Given a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original * BST is changed to the original key plus sum of all keys greater than the original key in BST. * * Example: * * Input: The root of a Binary Search Tree like this: * ...
true
ba0adeaa0a8802ddb8d2166bce1dc18d4698b3f7
Rust
enso-org/enso
/lib/rust/ensogl/core/src/display/render/passes/cache_shapes.rs
UTF-8
6,594
2.703125
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
//! Pass where we check what shapes created with [`cached_shape!`](crate::cached_shape) macro are //! ready to being rendered to the texture. use crate::prelude::*; use crate::display; use crate::display::render::pass; use crate::display::render::pass::Instance; use crate::display::scene::Layer; use crate::display::s...
true
bf824ba7ba49e7f31420d45b093de2c964b64a23
Rust
svmk/fund-watch-bot
/src/market/common/model/original_volume.rs
UTF-8
763
2.9375
3
[]
no_license
use crate::prelude::*; #[derive(Debug, Clone, PartialEq, PartialOrd, ValueObject)] #[value_object(error_type = "Failure", load_fn = "OriginalVolume::from_f64")] pub struct OriginalVolume(f64); impl OriginalVolume { pub fn from_f64(value: f64) -> Result<OriginalVolume, Failure> { return Ok(OriginalVolume(v...
true
e8359a23843defa752e93cda69a1052f36aa0dec
Rust
C4K3/nbted
/src/unstable/tests/mod.rs
UTF-8
5,419
3.046875
3
[ "LicenseRef-scancode-unknown-license-reference", "CC0-1.0" ]
permissive
use std::io::Cursor; use crate::data::{Compression, NBTFile}; mod iter_replacer; mod string_read; mod tests_data; /// Given some NBT data in original format, loops it around by converting it /// in the following way: Read NBT -> Write String -> Read String -> Write NBT /// and checks that the resulting NBT data is i...
true
c2d1854c895b96cf8b849ce3e0295132ec1ea253
Rust
oresk/mandel
/src/main.rs
UTF-8
2,923
3.171875
3
[]
no_license
// https://hardmath123.github.io/scratch-mandelbrot.html #[macro_use] extern crate clap; use clap::{Arg, App}; use num::complex::Complex; use image; fn main() { println!("Welcome to mandelbrot set display!"); let config = parse_config(); let img = image::ImageBuffer::from_fn(config.size.re, config.size.i...
true
56a22016101004c541595ab39999f6ceb05ce972
Rust
WestfalNamur/rust
/basics/05_ownership/src/main.rs
UTF-8
4,179
4.34375
4
[]
no_license
fn main() { // ************************************************************************ // Ownership // - Memory in Rust is managed through a system of ownership with a set of // rules that the compiler checks at compile time; // - Stack and Heap // - Stack: last in, first out; fast; data mu...
true
eb4ce3ffa8b14f2809137541ac87a4b1e4e1a303
Rust
Feilkin/mela
/src/asset/tilemap/object.rs
UTF-8
1,181
2.90625
3
[]
no_license
//! Tilemap objects use crate::asset::tilemap::data; use crate::asset::tilemap::data::DrawOrder; use crate::debug::DebugDrawable; #[derive(Debug, Clone)] pub struct Object { id: usize, pub x: f32, pub y: f32, pub width: f32, pub height: f32, pub _type: String, } impl DebugDrawable for Object ...
true
bb15939055eecc2ca792e736cf9c08cdc00aa990
Rust
mskw/mskw-microservice
/core/src/utils.rs
UTF-8
1,825
2.578125
3
[]
no_license
use std::sync::Arc; use std::error::Error; use futures::sync::oneshot; use std::{thread, io, env}; use std::io::Read; use futures::Future; use log::{info, warn}; use std::str::FromStr; use grpcio::{RpcContext, UnarySink, EnvBuilder, ChannelBuilder}; pub fn start_grpc_server(services: Vec<grpcio::Service>, port: u16)...
true
819265cdaf07da6cc60e752355491415e5b0f98a
Rust
mcapo88/Rustpa3
/zhttpto.rs
UTF-8
5,227
3.078125
3
[ "MIT" ]
permissive
// // zhttpto.rs // // Starting code for PA1 // Running on Rust 1.0.0-nightly build 2015-02-21 // // Note that this code has serious security risks! You should not run it // on any system with access to sensitive files. // // Brandeis University - cs146a - Spring 2015 use std::old_io::{Acceptor, Listener, TcpListener...
true
85d26f0532db0776addb276f79ab3b68f4908d6d
Rust
londey/gbce
/src/machine.rs
UTF-8
1,293
2.78125
3
[]
no_license
pub use cart::Cart; mod bus; mod cart; mod cpu; mod ram; use bus::memory_map; /// The state of the machine at one moment #[derive(Clone)] pub struct MachineState { cart: Cart, cpu: cpu::CpuState, system_ram: ram::Ram, video_ram: ram::Ram, high_ram: ram::Ram, bus: bus::Bus, } /// A reversible...
true
6ec369dcba3edb83102f1f8695778180a4cbe012
Rust
resnidar/eln2
/logcollector/src/main.rs
UTF-8
1,232
2.640625
3
[ "MIT", "LicenseRef-scancode-public-domain", "CC0-1.0" ]
permissive
extern crate chrono; use std::net::{TcpListener, TcpStream, IpAddr, Ipv4Addr}; use std::io::{Read, Write}; use std::fs::File; use std::time::Duration; use chrono::Utc; fn main() { try_start_server() } fn try_start_server() { const TCP_PORT: u16 = 4329; //const THREAD_POOL_SIZE: u16 = 12; let listener ...
true
c5b543b50002afacd9a68eb157ed7ae4496ad208
Rust
tuzymandias/yugioh_prices_csv
/src/lib.rs
UTF-8
4,552
3.15625
3
[]
no_license
use csv::{ReaderBuilder, StringRecord, Trim}; use serde::export::Formatter; use serde::Deserialize; use serde::Serialize; use std::collections::hash_map::Entry; use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; #[derive(Debug, Serialize, Deserialize)] pub struct Record { pub name...
true
730523825f13019d6b4cd33be96b4b8199eb724f
Rust
MarkMcCaskey/aoc-2020
/src/day7.rs
UTF-8
3,039
3.015625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; #[aoc_generator(day7)] pub fn parse_input(input: &str) -> HashMap<String, HashMap<String, usize>> { input.lines().map(parse_line).collect() } fn parse_line(line: &str) -> (String, HashMap<String, usize>) { let (name, expr) = { let mut i = line.split(" bags contain "); ...
true
8c4f780b7f33fa17bbe268d6ea57f07d99201417
Rust
jtojnar/sman
/src/main.rs
UTF-8
3,683
2.53125
3
[ "MIT" ]
permissive
extern crate cursive; extern crate glob; extern crate regex; extern crate pretty_env_logger; #[macro_use] extern crate log; use cursive::Cursive; use cursive::traits::Scrollable; use cursive::views::Dialog; use cursive::views::SelectView; use glob::glob; use regex::Regex; use std::env; use std::collections::HashSet; u...
true
55cdb6c13cb31ddb848bcb5e8d34f2d18e2205e2
Rust
nilvxingren/srt-rs
/srt-protocol/src/protocol/sender/buffer.rs
UTF-8
17,766
2.53125
3
[ "Apache-2.0" ]
permissive
use crate::packet::CompressedLossList; use crate::protocol::encryption::Cipher; use crate::protocol::sender::encapsulate::Encapsulate; use crate::protocol::TimeStamp; use crate::{ConnectionSettings, DataPacket, MsgNumber, SeqNumber}; use bytes::Bytes; use std::cmp::max; use std::collections::{BTreeSet, VecDeque}; use s...
true
cf06dd2521a32331c1c05ab53288d4ed63cadccd
Rust
SpaceEraser/evolutionary_regression
/src/evolve/expression/exp_tree.rs
UTF-8
1,355
2.984375
3
[]
no_license
use crate::evolve::{ evolution_params::EvolutionParams, expression::{random_expression, ExpNode}, float, }; #[derive(Debug, Clone)] pub struct ExpTree { root: ExpNode, } impl ExpTree { pub fn new(root: ExpNode) -> Self { Self { root } } pub fn new_random(size: u32, params: &Evolut...
true
1a47103ac482ef6429b0c110030c31708ca024fb
Rust
netromdk/carapace.rs
/src/command/mod.rs
UTF-8
6,352
3.125
3
[ "MIT" ]
permissive
use std::any::Any; use std::process; use super::prompt::{EofError, Prompt, PromptResult}; pub mod exit_command; use self::exit_command::ExitCommand; pub mod quit_command; use self::quit_command::QuitCommand; pub mod cd_command; use self::cd_command::CdCommand; pub mod general_command; use self::general_command::Ge...
true
2c627a9d13eff6320ee895b29b9d203975530907
Rust
dholroyd/mpeg4-audio-const
/src/lib.rs
UTF-8
5,014
3.421875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Definitions of types and constants for values defined by //! [ISO/IEC 14496 part 3 (Audio)](https://en.wikipedia.org/wiki/MPEG-4_Part_3). //! //! Currently supported, //! //! - [`AudioObjectType`](struct.AudioObjectType.html) use std::convert::TryFrom; use std::fmt; /// Represents an error converting a `u8` into...
true
00824ee4dc0ab25e8b637a780270609ca9164947
Rust
zayenz/advent-of-code-2018
/aoc2018/src/union_find.rs
UTF-8
2,084
3.4375
3
[ "MIT" ]
permissive
#[derive(Debug, Clone)] pub struct UnionFind { nodes: Vec<i32>, } impl UnionFind { /// Create new UnionFind disjoint set that has nodes in [0..size) pub fn new(size: i32) -> UnionFind { let mut nodes = Vec::with_capacity(size as usize); for _ in 1..=size { nodes.push(-1); ...
true
9e4ac03a8afbe5a23043950b1c2fa53cff28bae6
Rust
openbsd/xenocara
/lib/mesa/src/gallium/frontends/rusticl/mesa/util/disk_cache.rs
UTF-8
2,660
2.6875
3
[]
no_license
use mesa_rust_gen::*; use std::ffi::CString; use std::ops::Deref; use std::ptr; use std::ptr::NonNull; use std::slice; pub struct DiskCacheBorrowed { cache: NonNull<disk_cache>, } pub struct DiskCache { inner: DiskCacheBorrowed, } // disk_cache is thread safe unsafe impl Sync for DiskCacheBorrowed {} impl ...
true
3444dde5051933ab3a7acd3b7a3c79cfa39ba381
Rust
Aimnos/Dcoder-Challenges
/Easy/Rust/Valid Quadrilateral.rs
UTF-8
528
2.921875
3
[ "MIT" ]
permissive
use std::io::{self, BufRead}; fn main() { let stdin = io::stdin(); let mut lines = stdin.lock().lines(); let T: u8 = lines.next().unwrap().unwrap().trim().parse().unwrap(); for _ in 0..T { match lines .next() .unwrap() .unwrap() .split_whitespace(...
true
65c29b5df8f72797ee96d5e27351e731ca822d8e
Rust
fossabot/rundeck
/cli/src/commands/project.rs
UTF-8
1,127
2.546875
3
[]
no_license
use ResultExt; use super::*; use super::Processable; use prettytable::format; use prettytable::row::Row; use prettytable::cell::Cell; use api::Project; use api::ProjectService; pub struct ListProjectsCommand {} impl Processable for ListProjectsCommand { fn new() -> Self { Self {} } fn proceed<'a...
true
be1411c10103d906778d8945d5e9a5c61762b1cc
Rust
awakecoding/rbac-sim
/src/lib.rs
UTF-8
10,103
2.921875
3
[ "MIT", "Apache-2.0" ]
permissive
#![allow(dead_code)] #![allow(unused_doc_comments)] extern crate regex; extern crate indexmap; extern crate uuid; extern crate serde; extern crate serde_json; use std::fs::File; use std::path::{Path}; use uuid::Uuid; use serde::{Serialize, Deserialize}; #[derive(Debug)] pub enum Error { Internal, InvalidFor...
true
7b9ed3810e479189c7d7593655c1b0a25483982c
Rust
kingoflolz/tokio-ping
/src/lib.rs
UTF-8
1,411
2.640625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! tokio-ping is an asynchronous ICMP pinging library. //! //! The repository is located at <https://github.com/knsd/tokio-ping/>. //! //! # Usage example //! //! Note, sending and receiving ICMP packets requires privileges. //! //! ```rust,no_run //! extern crate futures; //! extern crate tokio; //! //! extern crate ...
true
52eb47c7792ccfa5dc3f8634c587b3d30a4e5dec
Rust
finafisken/adventofcode2018
/day6/src/main.rs
UTF-8
2,730
3.5
4
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::cmp; fn main() { let mut file = File::open("input.txt").unwrap(); let mut input = String::new(); file.read_to_string(&mut input).unwrap(); println!("Part 1: {}", part1(&input)); println!("Part 2: {}", part2(&input, 10000)); } fn prepare(input: ...
true
0823b5b8696a689dfa5ec5650ab43466d54afe86
Rust
laysakura/mockall-example-rs
/infra/src/repository_impls/user_repository_impl.rs
UTF-8
1,966
3.0625
3
[]
no_license
use std::cell::RefCell; use domain::{MyError, MyErrorType, MyResult, User, UserRepository}; use crate::persistence::yaml::user_yaml_storage::UserYamlStorage; #[derive(Clone, Debug)] pub(crate) struct UserRepositoryImpl { // UserRepository の関数は (`&mut self` ではなく) `&self` を取るため、 // 更新処理のために内部可変性 (RefCell) を使う。...
true
beb118c90953194bfa5f8ee20ccce1d81faf31e1
Rust
brucemc/go
/examples/gui/next_shader.rs
UTF-8
3,722
2.703125
3
[]
no_license
#[cfg(dev)] use glium; use glium::{implement_vertex, uniform, Surface}; use sgf_parser::*; #[derive(Copy, Clone)] struct Vertex { position: [f32; 2], tex_coords: [f32; 2], } implement_vertex!(Vertex, position, tex_coords); pub struct Shader { vertex_buffer: glium::VertexBuffer<Vertex>, indicies: gliu...
true
777a09fe962777928835b1caed3506bb652b90e9
Rust
Tim-Zhang/rust-protobuf
/protobuf/src/well_known_types_util/any.rs
UTF-8
3,374
3.1875
3
[ "MIT" ]
permissive
use crate::message_dyn::MessageDyn; use crate::reflect::MessageDescriptor; use crate::well_known_types::any::Any; use crate::MessageFull; impl Any { fn type_url(type_url_prefix: &str, descriptor: &MessageDescriptor) -> String { format!("{}/{}", type_url_prefix, descriptor.full_name()) } fn type_na...
true
4a86faac5b76b4189366374ccdf0176ec67c2409
Rust
balena-os/os-config
/src/fs.rs
UTF-8
961
2.609375
3
[ "Apache-2.0" ]
permissive
use std::path::Path; use std::u32; use fatrw::read::read_file as fatrw_read_file; use fatrw::write::write_file as fatrw_write_file; use anyhow::{Context, Result}; pub fn read_file(path: &Path) -> Result<String> { Ok(String::from_utf8(fatrw_read_file(path, false).context( format!("Reading {:?} failed", pa...
true
a3aed2633f7e89b4087157418e20792eda5e6861
Rust
ElijahWoelbing/coinbase_client
/src/error.rs
UTF-8
1,420
3.171875
3
[]
no_license
use serde::Deserialize; use serde_json; use std::error::Error as StdError; use std::fmt; #[derive(Debug)] pub struct Error { pub kind: ErrorKind, } impl StdError for Error {} impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match &self.kind { ErrorKind::...
true
e2aadd0fc112fd94a66eb9fe1a35383f971cbf7a
Rust
darakian/projecteuler
/pe0022/src/main.rs
UTF-8
1,082
3.53125
4
[]
no_license
use std::fs::File; use std::io::Read; fn main() { let mut file = File::open("p022_names.txt").unwrap(); let mut s = String::new(); file.read_to_string(&mut s).unwrap(); s.retain(|c| c!='(' && c != '\"'); let mut names: Vec<_> = s.split(",").collect(); names.sort(); let mut scores: Vec<_> = ...
true
dcd4af67f43fe38e086dae05fd053cdbcd45b303
Rust
AndrewRademacher/compose
/src/main.rs
UTF-8
2,990
2.640625
3
[]
no_license
use std::fs::File; use std::io::Read; use std::thread::sleep; use std::time::{Duration, Instant}; use anyhow::Result; use ndarray::{Array1, ArrayView1}; use rodio::Source; use crate::instrument::SineGenerator; mod instrument; mod parse; mod sheet; mod synth; const SAMPLE_RATE: u32 = 96000; fn main() -> Result<()> ...
true
f373af9cda43e8bca4fdbeca6c5b592eeb8b5258
Rust
whoisjg/alone_in_dark
/lib/raylib/src/structs/vec2.rs
UTF-8
4,094
3.546875
4
[]
no_license
use crate::Vector2; use std::ops::*; impl Vector2 { /// Dot product of two vectors. #[inline] pub fn dot(&self, other: Vector2) -> f32 { self.x * other.x + self.y * other.y } /// Cross product of two vectors. /// /// This is signed so that (0, 1) × (1, 0) = 1. #[inline] pu...
true
2871c849942e037534d7c9c6daefe1d161addb15
Rust
TheLeonsver1/sprite_editor
/src/data/tile_entity.rs
UTF-8
3,067
3.140625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use bevy::prelude::*; use bevy::render::pipeline::RenderPipeline; use super::shared_components::Uninitiated; //A visual representation of a single tile/sprite #[derive(Bundle, Clone)] pub struct TileBundle { #[bundle] pub sprite: SpriteBundle, //This is the visualizing part, not the data, there's a transaction...
true
1e7b9c92f0a2ca9fcec91dcd89cfd9f291491a94
Rust
ivfranco/notes
/AI/minimax/src/main.rs
UTF-8
501
3.015625
3
[ "LicenseRef-scancode-warranty-disclaimer" ]
no_license
use minimax::tic_tac_toe::TicTacToe; fn main() { exercise_5_9(); } fn exercise_5_9() { println!("5.9"); for expr in &[ "xo.......", "x.o......", "x...o....", "x....o...", "x.......o", "ox.......", ".x.o.....", ".x..o....", ".x....o.....
true
72b9fcde122093eadf9f9e096988c97ade3ba638
Rust
motoyang/sf315
/rust/elog/examples/ex1/main.rs
UTF-8
674
2.8125
3
[ "MIT" ]
permissive
// -- main.rs -- #[macro_use] extern crate elog; // -- fn main() { init_scroped_logger!(); log::debug!("this is a debug {}", "message"); log::error!("this is printed by default"); if log::log_enabled!(log::Level::Info) { let x = 3 * 4; // expensive computation log::info!("the answer...
true
850efcdf85bba86f7dcf1dd4547fcedb5bf78d43
Rust
paritytech/substrate
/bin/node/bench/src/common.rs
UTF-8
1,446
2.578125
3
[ "Apache-2.0", "GPL-3.0-or-later", "Classpath-exception-2.0", "GPL-1.0-or-later", "GPL-3.0-only" ]
permissive
// This file is part of Substrate. // Copyright (C) Parity Technologies (UK) Ltd. // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Softwa...
true
7c58f8432eb1ad47b9030853daaa239da4a4cfbd
Rust
pbzweihander/async-h1
/src/client/encode.rs
UTF-8
4,180
2.6875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use std::io::Write; use std::pin::Pin; use async_std::io::{self, Cursor, Read}; use async_std::task::{Context, Poll}; use http_types::headers::{CONTENT_LENGTH, HOST, TRANSFER_ENCODING}; use http_types::{Method, Request}; use crate::body_encoder::BodyEncoder; use crate::read_to_end; use crate::EncoderState; /// An HT...
true
88068017f5f82c16771337adb7d7ec71dc9c55d1
Rust
dalalsunil1986/FOMOSv2-CL
/fomos/src/cl/help.rs
UTF-8
1,643
2.578125
3
[]
no_license
/* fomos/src/cl/help.rs * * Build/compile: * cargo build * * Description: * The help command for FOMOS */ use fk_std::{c_char, libc::printf}; #[no_mangle] pub extern "C" fn help_main(arg: i32) { if arg == 0 { unsafe { printf(ASKU.as_ptr() as *const c_char); } unsafe { printf(PRINT.as_ptr() ...
true
80fa654d21df2711697cdba462e8a5f8e339076f
Rust
eggmunkee/suri-sprint
/src/resources/shaders.rs
UTF-8
5,128
2.609375
3
[]
no_license
// use std::fmt; // use std::fmt::{Display}; use std::collections::{HashMap}; use std::collections::hash_map::{Entry}; use gfx::{self, *}; use ggez::graphics::{Shader,EmptyConst,BlendMode}; use ggez::graphics::{Image,Font}; use ggez::{Context,GameResult,GameError}; use ggez::conf::{WindowMode}; use specs::{World}; // ...
true
2530defadc2c6f324178884bf60491b3ca4628c7
Rust
Muzuwi/bst-des
/src/des/mod.rs
UTF-8
20,115
3.359375
3
[]
no_license
mod constants; use std::borrow::{BorrowMut, Borrow}; use bitvec::order::Msb0; use bitvec::slice::BitSlice; #[derive(Copy, Clone, Debug)] pub struct Key { key: u64, round_keys: [u64; 16], } impl Key { fn shifts_for_round(rounds: u32) -> u8 { return match rounds { 1 | 2 | 9 | 16 => 1,...
true
32cd4ae5fe0606aff62cd0059b4d38440ec37dc0
Rust
AlkenePan/elfio-rs
/src/array.rs
UTF-8
4,652
2.984375
3
[ "Apache-2.0", "MIT" ]
permissive
/* Copyright (C) 2021-present by Serge Lamikhov-Center 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 to use, copy, modify, merge, pub...
true
c23bf5320ac5161879bc6a11e7a6e3a2286d4fcb
Rust
alexandre-lavoie/COMP371-rust
/src/render/buffer.rs
UTF-8
2,450
3.4375
3
[ "MIT" ]
permissive
use web_sys::{WebGlBuffer, WebGl2RenderingContext}; #[derive(Clone, Debug)] pub struct Buffers { pub vertex: Option<WebGlBuffer>, pub index: Option<WebGlBuffer>, pub normal: Option<WebGlBuffer> } impl Buffers { pub fn new(gl: &WebGl2RenderingContext, verticies: &[f32], indicies: &[u16], normals: &[f32...
true
d31985c8bdfcd857bcc6a5d095734ac802e196eb
Rust
lotabout/skim
/src/lib.rs
UTF-8
11,524
2.609375
3
[ "MIT" ]
permissive
#[macro_use] extern crate lazy_static; #[macro_use] extern crate log; use std::any::Any; use std::borrow::Cow; use std::fmt::Display; use std::sync::mpsc::channel; use std::sync::Arc; use std::thread; use crossbeam::channel::{Receiver, Sender}; use tuikit::prelude::{Event as TermEvent, *}; pub use crate::ansi::AnsiS...
true
10d1acd569a0ba870f1c8151bd0ed55edfa0e56e
Rust
Sevaarcen/HeatedWords
/src/parser.rs
UTF-8
3,813
3.359375
3
[]
no_license
use regex::Regex; pub fn parse(response_text: &mut String) -> (Vec<String>, Vec<String>) { //removes junk text remove_scripts(response_text); // remove JavaScript elements remove_style(response_text); // remove CSS remove_html_nodes(response_text); // remove HTML nodes remove_html_text(response_te...
true
17baa9bb1f20a542efdb80a9e4e4a6a92d99dfc2
Rust
jazzfool/reclutch
/event/src/streaming/direct.rs
UTF-8
3,787
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::*; #[derive(Debug)] pub struct Queue<T> { eq: crate::ts::Queue<T>, wakers: Arc<Mutex<Vec<Waker>>>, } #[derive(Debug)] pub struct Listener<T> { inner: Arc<crate::ts::Listener<T>>, wakers: std::sync::Weak<Mutex<Vec<Waker>>>, } #[derive(Debug)] pub struct IndirectRef<T>(Arc<crate::ts::Listene...
true
ee93d9674e9c634fc60635fc566db42612d0a42c
Rust
hugoaguirre/viking_dodgeaxe
/src/utils.rs
UTF-8
1,237
2.5625
3
[]
no_license
use ggez::graphics; use ggez::{Context, GameResult}; use ggez::timer; use std::time::Duration; use arena::Arena; use assets::Assets; use animation::ArenaAnimation; pub fn map_animation(ctx: &mut Context) -> GameResult<ArenaAnimation> { let arena_anim = ArenaAnimation { standby: [ sprite(ctx, ...
true
2966d7e602360cd357df4e3340582ca9da409e26
Rust
jcranmer/llstrata
/src/mcsema.rs
UTF-8
20,541
2.546875
3
[]
no_license
use llvm::*; use llvmmc::*; use llvm_sys::LLVMModule; use sema::*; use state::{InstructionInfo, InstructionState, State}; use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::path::Path; use std::slice; #[repr(C)] struct StringRef { data: *const u8, len: usize } impl <'a> PartialEq<&'...
true
0d3a5f78ad986e5d1954689f4e2a8412c4d736f9
Rust
ayaromenok/rustEvaluation
/platform_test/vk_vulkano_test0/src/main.rs
UTF-8
1,017
2.578125
3
[ "MIT" ]
permissive
use vulkano::instance::Instance; use vulkano::instance::InstanceExtensions; use vulkano::instance::PhysicalDevice; use vulkano::device::Device; use vulkano::device::DeviceExtensions; use vulkano::device::Features; fn main() { println!("Hello, Vulkano!"); let instance = Instance::new(None, &InstanceExtensions...
true
5dcfd5a4c6ca989627a502844c66c44cf95bc46f
Rust
jsperafico/learn-rust
/5.1_defining_structs/src/main.rs
UTF-8
2,036
3.640625
4
[ "MIT" ]
permissive
//Access in tuples requred a specif order, access on structs no. // Entity can't be partially mutable struct User { username: String, email: String, sign_in_account: u64, active: bool, } // tuple structs - a way to name tuples to diferentiate from the rest. struct Color(u8, u8, u8); // unit-like stru...
true
97314a410e02ce0a785548141e5d28fc5218ad43
Rust
danieldg/futures-rs
/futures-util/src/future/chain.rs
UTF-8
2,340
3
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::mem; use core::pin::Pin; use core::ptr; use futures_core::future::Future; use futures_core::task::{Context, Poll}; #[must_use = "futures do nothing unless you `.await` or poll them"] #[derive(Debug)] pub(crate) enum Chain<Fut1, Fut2, Data> { First(Fut1, Data), Second(Fut2), Empty, } impl<Fut1: U...
true
337588971ae23103322013ae1d9286093168c34b
Rust
1aim/state_machine_future
/tests/context_start_in_method.rs
UTF-8
882
2.796875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Test that we can access context type. #![feature(futures_api, pin, arbitary_self_types)] extern crate futures; #[macro_use] extern crate state_machine_future; use futures::Poll; use state_machine_future::RentToOwn; pub struct Context { } #[derive(StateMachineFuture)] #[state_machine_future(context = "Context")]...
true
0879826c2605f05953fe46639e8e63d745b2faa0
Rust
SolarLiner/rs-evasm
/src/parse.rs
UTF-8
4,077
2.703125
3
[]
no_license
use std::collections::hash_map::RandomState; use std::collections::HashMap; use std::fmt::{self, Display, Formatter}; #[derive(Copy, Clone, Eq, PartialEq, Debug)] pub enum Instruction<'a> { Label(&'a str), Reg(&'a str, u8), RegReg(&'a str, u8, u8), RegPtr(&'a str, u8, u8), RegCst(&'a str, u8, u16), RegLabel(&'a ...
true
139289de792ef1631a5247bcb9d818756c32619e
Rust
mhallin/dsp_microbench
/src/one_frame_per_call.rs
UTF-8
4,907
2.765625
3
[]
no_license
use crate::fastmath::{exp2, parabolic_sine, wrap01}; const OSC_MAX_FREQ: f64 = 20480.0; struct OscillatorHelper { pub sample_rate: f64, pub input_frequency: f64, pub octave_offset: f64, pub semitone_offset: f64, pub cent_offset: f64, pub amplitude: f64, pub input_frequency_mod_ratio: f64,...
true