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
effbd63099ced137c512a3aebeab3ed5be865d4e
Rust
Strongman86/Rust-Learning
/chapter4/E4_13/src/main.rs
UTF-8
180
2.71875
3
[]
no_license
fn create_box(){ let box3=Box::new(3); } fn main(){ let box1=Box::new(1); { let box2=Box::new(2); } for _ in 0 .. 1_000{ create_box(); } }
true
838fa31f925ad6ee2af20c819e7fd17e641b741e
Rust
szhongren/leetcode
/1342/main.rs
UTF-8
539
3.46875
3
[]
no_license
fn main() { println!("{:?}", Solution::number_of_steps(8)); println!("{:?}", Solution::number_of_steps(14)); } struct Solution; impl Solution { pub fn number_of_steps(num: i32) -> i32 { let mut decrementor = num; let mut counter = 0; while decrementor != 0 { ...
true
e7ce17e3e05b2d1b54680cdae0c94879c41d5890
Rust
chasestarr/segment-chess-board
/src/cluster.rs
UTF-8
4,887
3.21875
3
[]
no_license
use std::collections::HashMap; fn dist((ax, ay): (f32, f32), (bx, by): (f32, f32)) -> f32 { let dist_squared = (ax - bx).powf(2.0) + (ay - by).powf(2.0); return dist_squared.sqrt(); } fn gaussian_kernel(distance: f32, kernel_bandwidth: f32) -> f32 { return (-1.0 / 2.0 * (distance * distance) / (kernel_bandwidth...
true
13167a1a15ab6adb880a81b19abfa9971ed34e93
Rust
elsid/CodeSide
/src/unit.rs
UTF-8
524
2.984375
3
[ "Apache-2.0" ]
permissive
use model::Unit; use crate::my_strategy::{ Positionable, Rect, Rectangular, Vec2, }; impl Positionable for Unit { fn position(&self) -> Vec2 { Vec2::from_model(&self.position) } } impl Rectangular for Unit { fn rect(&self) -> Rect { let half = Vec2::from_model(&self.size) /...
true
96599f8cda9b413033a7308b4b78f8463f45d818
Rust
plod/rustLearning
/k8s/kubia/src/main.rs
UTF-8
1,682
3.0625
3
[]
no_license
use std::net::{TcpStream, TcpListener}; use std::io::{Read, Write}; use std::thread; use whoami; fn handle_read(mut stream: &TcpStream) { let mut buf = [0u8 ;4096]; match stream.read(&mut buf) { Ok(_) => { let req_str = String::from_utf8_lossy(&buf); println!("{}", req_str); ...
true
0ee66e50969fb9b5503d523076b8ea32b12e68fc
Rust
Isaac-Lozano/pmw2-utils
/pmw2_collada/src/matrix.rs
UTF-8
2,394
3.296875
3
[ "MIT" ]
permissive
pub struct Matrix(pub [f32; 16]); impl Matrix { pub fn new() -> Matrix { Matrix( [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ] ) } pub fn mult(self, other: &Matrix)...
true
127c886f32c8c95011595c4ff9cf79f2be70dd6d
Rust
Wyverald/basic-rs
/src/lexer/mod.rs
UTF-8
6,387
3.53125
4
[ "MIT" ]
permissive
mod token; pub use lexer::token::Keyword; pub use lexer::token::Token; pub use lexer::token::TokenContent; use std::fmt; use std::str; use util::Position; pub struct Lexer<'a> { input: str::Lines<'a>, cur_line: Option<str::Chars<'a>>, cur_char: Option<char>, cur_position: Position, next_position:...
true
3422ad42690fb63dd6c86dabd850dc9acbb8900f
Rust
valtyr/asmvm
/src/instruction.rs
UTF-8
1,534
3.421875
3
[]
no_license
#[derive(Debug, PartialEq, Copy, Clone)] pub enum Opcode { HLT, LOAD, ADD, SUB, MUL, DIV, JMP, JMPB, JMPF, JMPC, EQ, NEQ, GT, LT, GTQ, LTQ, IGL, NOP, } impl From<u8> for Opcode { fn from(v: u8) -> Self { match v { 0 => retu...
true
713e52e9b1d6038aa74655e1ec29f539f30d491d
Rust
tjmonsi/cmsc129-2016-repo
/submissions/exercise3/melarpis/fl/src/parser.rs
UTF-8
1,402
3.34375
3
[ "MIT" ]
permissive
mod lex; use lex::lexeme::Lexeme; pub struct Parser<'a> { next: usize, tokens: Vec<Lexeme> } impl<'a> Parser<'a> { pub fn new(tokens: Vec<Lexeme>) -> Parser { Parser { next: 0, tokens: tokens } } pub fn parse(&self) -> Box<Expr> { let mut block: Vec...
true
cb406a29e6695aa056d2ec72f2b1d39bdd30e86f
Rust
niconicoj/pixelsort
/src/sorter.rs
UTF-8
624
2.75
3
[]
no_license
use image::RgbImage; use std::ops::Range; use crate::utils::lightness; pub fn sort(img: RgbImage, intervals: Vec<Vec<Range<usize>>>) -> RgbImage { let mut pixels: std::vec::Vec<&image::Rgb<u8>> = vec![]; for (row, row_interval) in img.rows().zip(intervals) { let mut row_pixel: Vec<_> = row.collect(); for ...
true
330b90b707e0b64de138704cc2df4c978efa3a74
Rust
devillove084/debra
/src/default.rs
UTF-8
3,166
2.5625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Thread local variables and access abstractions for *std* environments. use std::marker::PhantomData; use debra_common::reclaim; use debra_common::LocalAccess; use reclaim::{GlobalReclaim, Reclaim}; use crate::guard::Guard; use crate::local::Local; use crate::typenum::Unsigned; use crate::{Debra, Retired, Unlinke...
true
bf3079835a947888509ebacecc552eb95575275f
Rust
safwanrahman/traceroute
/sample-send-udp.rs
UTF-8
420
3.046875
3
[]
no_license
use std::io::net::udp::UdpSocket; use std::io::net::ip::{Ipv4Addr, SocketAddr}; fn main(){ let addr = SocketAddr { ip: Ipv4Addr(0, 0, 0, 0), port: 12345 }; let dest = SocketAddr { ip: Ipv4Addr(129,97,134,34), port: 12345 }; let mut socket = UdpSocket::bind(addr).unwrap(); let buf = [1,2,3,4,5,6,7,8]; for t...
true
993a589c1725e590bc37691675e51c466a816e3d
Rust
carrotflakes/silver
/src/materials/dielectric.rs
UTF-8
1,859
2.9375
3
[]
no_license
use rand::Rng; use crate::{ ray::Ray, rng, vec3::{NormVec3, Vec3}, }; use super::{Material, RayResult}; #[derive(Clone)] pub struct Dielectric { ri: f64, } impl Dielectric { pub fn new(ri: f64) -> Dielectric { Dielectric { ri } } } impl Material for Dielectric { fn ray(&self, ra...
true
57206cbd13009db9b4d973b95c34b9948854d22b
Rust
SpinlockLabs/ethernet.rs
/src/utils/linux/uio.rs
UTF-8
6,642
2.8125
3
[ "MIT" ]
permissive
use std::io; use std::io::prelude::*; use std::fs; use std::fs::{File, OpenOptions}; use std::num::ParseIntError; use std::str::FromStr; use std::usize; use memmap; pub use memmap::MmapMut; const PAGESIZE: usize = 4096; #[derive(Debug)] pub enum UioError { Address, Io(io::Error), Parse } impl From<io::E...
true
73350948725d25e644cef70e223e516ff4c86f73
Rust
chifflier/cookie-factory
/src/lib.rs
UTF-8
4,999
2.640625
3
[ "MIT" ]
permissive
//! Cookie factory #![feature(trace_macros)] //macros: //* write_vec!(vec, ...) -> Result(nb of bytes) //* write_slice!(s, ...) -> Result(nb of bytes) //* write_iterator!(it, ...) -> Result(nb of bytes) // //* config can be endianness // combinator: c!(writer, config, conbinator/serializer) #[macro_export] macro_rules...
true
0c3e667903c27ece369eacf9a5244e27d0694d23
Rust
creativeJoe007/my_rusty
/struct_example/src/main.rs
UTF-8
964
3.984375
4
[]
no_license
// add an antonation here to make this struct printable in debug mode #[derive(Debug)] struct Rectangle { width: u32, height: u32 } fn main() { let width1 = 30; let height1 = 50; println!( "The area of the rectangle is: {} square pixels", area(width1, height1) ); // refact...
true
a3d58258ea1a18620448470ed05523a5026a5606
Rust
boyuni/resctl
/resctl/below/below_derive/src/field.rs
UTF-8
15,492
2.5625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright (c) Facebook, Inc. and its affiliates. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicabl...
true
07f8f22b54f395b098f8e2f7fe80d4dfe7c66ada
Rust
nojan1/AdventOfCode
/2021/rust/day9/src/main.rs
UTF-8
3,028
3.125
3
[]
no_license
use aoc; fn main() { println!("Answer to A: {}", part_a("day9/input.txt")); println!("Answer to B: {}", part_b("day9/input.txt")); } fn is_low_spot(x: usize, y: usize, height_map: &Vec::<Vec::<i64>>) -> bool { let my_value = height_map[y][x]; (x == 0 || height_map[y][x - 1] > my_value) && (x == h...
true
b3da783aedf6a526048de74ec7fa96eaa890b6a8
Rust
massimiliano-mantione/radicle-surf
/src/lib.rs
UTF-8
2,436
3.203125
3
[]
no_license
//! Welcome to `radicle-surf`! //! //! `radicle-surf` is a system to describe a file-system in a VCS world. //! We have the concept of files and directories, but these objects can change over time while people iterate on them. //! Thus, it is a file-system within history and we, the user, are viewing the file-system at...
true
40689176ccaec225b252cc029b4244b6f5208e7f
Rust
dbolshak/veracruz
/veracruz-utils/src/platform/mod.rs
UTF-8
806
2.828125
3
[ "MIT" ]
permissive
//! Platform-specific material. //! //! Material specific to a particular platform that Veracruz supports, and which //! does not fit elsewhere. //! //! ## Authors //! //! The Veracruz Development Team. //! //! ## Licensing and copyright notice //! //! See the `LICENSE.markdown` file in the Veracruz root directory for ...
true
510405e71790112ea89f634860a780fca448299c
Rust
nushell/nushell
/crates/nu-parser/src/deparse.rs
UTF-8
2,977
3.890625
4
[ "MIT" ]
permissive
pub fn escape_quote_string(input: &str) -> String { let mut output = String::with_capacity(input.len() + 2); output.push('"'); for c in input.chars() { if c == '"' || c == '\\' { output.push('\\'); } output.push(c); } output.push('"'); output } // Escape ru...
true
cd8335e93fc83beff86c08a34d2d07b309eafb48
Rust
m4tx/lz4stego
/liblz4stego/src/tests/decompressor.rs
UTF-8
2,465
2.859375
3
[ "MIT" ]
permissive
use crate::decompressor::Decompressor; use crate::errors::DecompressResult; use std::io::Read; fn decompress(data: &[u8]) -> DecompressResult<(Vec<u8>, Vec<u8>)> { let mut output = Vec::new(); let mut decompressor = Decompressor::new(data, false); decompressor.read_to_end(&mut output).unwrap(); Ok((ou...
true
d1420bf1c835a1caba8014805aaf4f9960a2dbd6
Rust
sqrtminone/untisd
/src/request.rs
UTF-8
3,421
2.6875
3
[]
no_license
use serde::Deserialize; use anyhow::{Result,anyhow}; //TODO move to correct crates use crate::untis::RpcRespone; //representation of Room like retrived via getRooms #[derive(Deserialize)] pub struct Room { pub id: u16, //TODO can this be bigger :o ? pub name: String, pub longName: String, //TODO appar...
true
606d5a63f1caef34942b27987f8a964a88d315cd
Rust
david-sackstein/async-web-server-rust
/src/server.rs
UTF-8
909
2.984375
3
[]
no_license
use std::thread; use std::time::Duration; use async_std::task; use tide::Request; use tide::prelude::*; use super::Error; #[derive(Debug, Deserialize)] struct Animal { name: String, legs: u8, } pub(crate) fn run_blocking(port: u16) -> Result<(), Error> { Ok(task::block_on(start(port)).map_err(Error::Ser...
true
c73c40a9ede41fe4cbe35b197bac1df5e7040db2
Rust
fogti/libnar
/tests/serialize.rs
UTF-8
8,195
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::fs::{self, File, OpenOptions}; use std::io::Write; use std::os::unix::fs::OpenOptionsExt; #[test] fn serializes_regular_file() { let dir = tempfile::tempdir().unwrap(); let mut file = File::create(dir.path().join("file.txt")).unwrap(); writeln!(file, "lorem ipsum dolor sic amet").unwrap(); le...
true
7ea8a91eb41d5a9d2ee37f6cf7310a84f036f2fe
Rust
Rust-Mikrocontroller-Praktikum-2017/party-pad
/src/visuals/energy_visualizer.rs
UTF-8
2,649
2.65625
3
[]
no_license
use collections::boxed::Box; use super::STM; use visuals::constants::*; use visuals::Visualizer; use core; use audio; pub struct EnergyVisualizer { last_radius: u16, } impl Visualizer for EnergyVisualizer { fn draw(&mut self, mut stm: &mut STM) { let mode = false; let mut mic_input: [i16; 32] ...
true
a69a0888bf3230cfc3f7f294975bca0a875941f8
Rust
rubycoder/faster_path
/src/path_parsing.rs
UTF-8
1,476
3.140625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::path::MAIN_SEPARATOR; static SEP: u8 = MAIN_SEPARATOR as u8; pub fn extract_last_path_segment(path: &str) -> &str { // Works with bytes directly because MAIN_SEPARATOR is always in the ASCII 7-bit range so we can // avoid the overhead of full UTF-8 processing. // See src/benches/path_parsing.rs for ben...
true
9ddb6773f39ed4b96f108aa1085ab687c70343f4
Rust
shybyte/nlprule-web-demo
/nlprule-wasm/src/lib.rs
UTF-8
1,794
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use nlprule::{Rules, Tokenizer}; use wasm_bindgen::prelude::*; mod utils; // When the `wee_alloc` feature is enabled, use `wee_alloc` as the global // allocator. #[cfg(feature = "wee_alloc")] #[global_allocator] static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; #[wasm_bindgen] extern "C" { #[wasm_bi...
true
4bca76b5c8af1931f78b6c8e5195803778777a38
Rust
tacgomes/advent-of-code-2020
/22/main.rs
UTF-8
3,988
3.453125
3
[ "MIT" ]
permissive
use std::collections::HashSet; use std::collections::VecDeque; use std::env; use std::fs; use std::path::Path; use std::process; type Deck = VecDeque<usize>; enum Player { One, Two, } fn calculate_score(deck1: &Deck, deck2: &Deck) -> usize { let winner_hand = if !deck1.is_empty() { deck1 } else { deck2 }...
true
6374869ef70770e75f4ee5cf0aa41e980d4f39a9
Rust
tomtau/tendermint-rs
/tendermint/src/block/parts.rs
UTF-8
617
2.9375
3
[ "Apache-2.0" ]
permissive
//! Block parts use crate::Hash; use { crate::serializers, serde::{Deserialize, Serialize}, }; /// Block parts header #[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] pub struct Header { /// Number of parts in this block #[serde( serialize_with = "serialize...
true
61efcf291db1d3423182f2fd12eecd6e50c60d75
Rust
ajuvercr/alex
/src/database/models.rs
UTF-8
2,916
2.796875
3
[]
no_license
use super::schema::*; use chrono::{NaiveDateTime}; pub type ID = i32; pub type UUID = i32; #[derive(Serialize, Queryable, Identifiable, AsChangeset, Debug)] pub struct Post { pub id: ID, pub uuid: UUID, pub title: String, pub synopsis: Option<String>, pub body: String, pub created: NaiveDateTi...
true
f6c842384f2a61f5b75b8c5f6669af212acf1f21
Rust
jolestar/libra
/config/src/config/execution_config.rs
UTF-8
4,785
2.78125
3
[ "Apache-2.0" ]
permissive
// Copyright (c) The Libra Core Contributors // SPDX-License-Identifier: Apache-2.0 use crate::config::RootPath; use anyhow::Result; use libra_types::transaction::Transaction; use serde::{Deserialize, Serialize}; use std::{ fs::File, io::{Read, Write}, net::SocketAddr, path::PathBuf, }; const GENESIS_...
true
7de03c3de763bcd19f5bcabeaa9d424ac374789a
Rust
deepinthebuild/adventofcode2017
/04/src/main.rs
UTF-8
1,465
3.421875
3
[]
no_license
use std::collections::HashSet; use std::str::FromStr; fn main() { let input = include_str!("../input.txt"); println!("Part 1: {}", part1(input)); println!("Part 2: {}", part2(input)); } fn part1(input: &str) -> u32 { let mut count: u32 = 0; for line in input.lines() { if has_no_duplicate...
true
73e252df8fb431b76c422eda55eb3803c424122f
Rust
soro/hdrsample
/tests/data_access.rs
UTF-8
30,573
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Tests from HistogramDataAccessTest.java extern crate hdrsample; extern crate rand; extern crate ieee754; extern crate rug; use hdrsample::{Histogram, Counter}; use rand::Rng; use rand::distributions::range::Range; use rand::distributions::IndependentSample; use ieee754::Ieee754; use rug::{Rational, Integer}; ma...
true
72c7b1ee8bd24d6f735f20459f7a1d4be280789a
Rust
samuwen/rq_injector
/src/engine_config_tab.rs
UTF-8
5,320
2.53125
3
[]
no_license
use crate::configuration::Configuration; use crate::initializable::Initializable; use crate::locales::Locale; use gtk::prelude::*; use gtk::{Builder, Button, CheckButton, Entry, Label}; use std::cell::RefCell; use std::rc::Rc; #[derive(Clone)] pub struct EngineConfigTab { pub btn_quake_dir: Button, pub btn_qua...
true
12e45ddd2fc05bc6f2be434239e6ca177194d95c
Rust
fdenzer/chilli
/src/helpers.rs
UTF-8
10,207
3.09375
3
[ "BSD-3-Clause" ]
permissive
//! This module implements various helpers. use std::error::Error; use std::fs::File; use std::path::{Path, PathBuf}; use std::io::{Seek, Read}; use std::io::SeekFrom::{End, Start}; use hyper::header::{Location, ContentType, Range, ContentRange, ContentLength}; use hyper::header::ByteRangeSpec::{FromTo, Las...
true
1ad1d1bf203543da7a397dcf51e2ea5296dcf8a0
Rust
hdoordt/rust-lorawan
/device/src/radio.rs
UTF-8
4,267
2.921875
3
[ "MIT" ]
permissive
use heapless::consts::*; use heapless::Vec; pub enum Bandwidth { _125KHZ, _250KHZ, _500KHZ, } pub enum SpreadingFactor { _7, _8, _9, _10, _11, _12, } pub enum CodingRate { _4_5, _4_6, _4_7, _4_8, } #[derive(Copy, Clone, Debug)] pub struct RxQuality { rssi: i16...
true
7b77c70a330ea7bb49136fc752142f7e3e852d05
Rust
NeoLegends/FoSAP
/H13-first-longest-match/src/dfa.rs
UTF-8
7,206
3.234375
3
[]
no_license
use std::collections::{HashMap, HashSet}; use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; static COUNTER: AtomicUsize = ATOMIC_USIZE_INIT; /// Represents a DFA-like NFA. /// /// To simplify the implementation of the first-longest-match /// algorithm, we omit transitions instead of using sink states...
true
98d57f09f66fa8d3bfb97cd6b22fbb70a22a8a7f
Rust
AxlLind/synacor_challenge
/src/bin/teleporter_setting.rs
UTF-8
2,298
2.9375
3
[ "MIT" ]
permissive
/* 0x178b: jt $0 0x1793 # if $0 != 0 { goto 0x1793; } 0x178e: add $0 $1 0x1 # $0 = $1 + 1 0x1792: ret # return 0x1793: jt $1 0x17a0 # if $1 != 0 { goto 0x17a0; } 0x1796: add $0 $0 0x7fff # $0 -= 1 0x179a: set $1 $7 # $1 = $7 0x179d: cll 0x178b # 0x178b() ...
true
7af83b42195e5714ea892cf30171bada1f71cdb7
Rust
AndrewBregger/database
/src/sql_engine/src/query/scalar.rs
UTF-8
1,907
2.609375
3
[ "Apache-2.0" ]
permissive
// Copyright 2020 Alex Dukhno // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in ...
true
41656508f8a7bc8a7ef2c9ceb89d2604b5dfb08d
Rust
hyperium/hyper-old-types
/src/header/common/last_modified.rs
UTF-8
1,377
2.8125
3
[ "MIT" ]
permissive
use header::HttpDate; header! { /// `Last-Modified` header, defined in /// [RFC7232](http://tools.ietf.org/html/rfc7232#section-2.2) /// /// The `Last-Modified` header field in a response provides a timestamp /// indicating the date and time at which the origin server believes the /// selected ...
true
9ffd99decf2e728f28fd835f0f7897edbcfe7637
Rust
Chris--B/advent-of-code
/2018/src/day10.rs
UTF-8
2,925
3.15625
3
[]
no_license
use std::{ collections::*, env, fs, io::{ self, BufRead, }, }; use aoc_runner_derive::{aoc, aoc_generator}; use failure::bail; use lazy_static::lazy_static; use regex::Regex; #[derive(Copy, Clone)] struct Point { x: i64, y: i64, dx: i64, dy: i64, } impl Point { ...
true
393fb2816c0433e67dfee660f0b66d72c905bb43
Rust
marco-c/gecko-dev-wordified-and-comments-removed
/third_party/rust/naga/src/front/glsl/error.rs
UTF-8
2,942
2.703125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use super : : { constants : : ConstantSolvingError token : : TokenValue } ; use crate : : Span ; use pp_rs : : token : : PreprocessorError ; use std : : borrow : : Cow ; use thiserror : : Error ; fn join_with_comma ( list : & [ ExpectedToken ] ) - > String { let mut string = " " . to_string ( ) ; for ( i val ) in list ...
true
4eb3f231dc9edb4bd4ac59b381d266abea9bb7fc
Rust
sagor999/aoc2020
/day2/main2.rs
UTF-8
1,962
3.6875
4
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader, Error, ErrorKind, Read}; use std::str::FromStr; use std::num::ParseIntError; use std::fmt; struct PasswordData { first_position: u16, second_position: u16, letter: char, password: String } //example: 1-9 x: xwjgxtmrzxzmkx impl FromStr for PasswordData { t...
true
4cf0c9ed832896c6df035ea24dfd95f040ee1c38
Rust
fimbault/h3
/examples/client.rs
UTF-8
2,217
2.546875
3
[ "MIT" ]
permissive
use tokio::io::AsyncWriteExt; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL) .with_writer(std::io::stde...
true
e860ebcf5075ee5a043167423f782e75a36ebdc2
Rust
asnelling/psst
/psst-gui/src/widget/dispatcher.rs
UTF-8
4,055
2.734375
3
[ "MIT" ]
permissive
use std::{collections::HashMap, hash::Hash}; use druid::{widget::prelude::*, Data, Point, WidgetPod}; type ChildPicker<T, U> = dyn Fn(&T, &Env) -> U; type ChildBuilder<T, U> = dyn Fn(&U, &T, &Env) -> Box<dyn Widget<T>>; pub struct ViewDispatcher<T, U> { child_picker: Box<ChildPicker<T, U>>, child_builder: Bo...
true
5e66042a23c03048f38f55c44515cce1a34cd46a
Rust
faim-lab/mappy
/mappy/src/mappy/splits.rs
UTF-8
6,883
2.859375
3
[]
no_license
use super::scrolling::*; use crate::framebuffer::Framebuffer; use crate::tile::TILE_SIZE; use crate::Rect; #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)] pub struct Split { pub scanline: u8, pub scroll_x: u8, pub scroll_y: u8, } fn register_split(splits: &mut Vec<Split>, scanline: u8) { let last = ...
true
6045596c84de3b7d4d75416bd429e4874fa55cda
Rust
ParthDesai/solana
/programs/bpf/rust/param_passing_dep/src/lib.rs
UTF-8
511
2.921875
3
[ "Apache-2.0" ]
permissive
//! @brief Example Rust-based BPF program tests loop iteration extern crate solana_sdk; pub struct Data<'a> { pub twentyone: u64, pub twentytwo: u64, pub twentythree: u64, pub twentyfour: u64, pub twentyfive: u32, pub array: &'a [u8], } pub struct TestDep { pub thirty: u32, } impl<'a> Tes...
true
2a78fad88cfef35e141e60be2ec6812f7a058d75
Rust
cumt-gpf/learnRust
/hw05/src/game/room.rs
UTF-8
1,272
2.8125
3
[]
no_license
use std::rc::Rc; use std::cell::RefCell; use std::mem; use super::curio::Curio; use super::hall::Hall; pub struct Room { pub name: String, pub contents: Vec<Curio>, pub halls: Vec<Rc<Hall>>, pub wumpus: bool, } impl PartialEq for Room { fn eq(&self, other: &Self) -> bool { self.name == ot...
true
7c3da9d6d9c21158bd8088ea05d8689366b778b6
Rust
actionshrimp/raytracing-in-one-weekend-rust
/src/main.rs
UTF-8
17,220
3.140625
3
[]
no_license
use pbr::ProgressBar; use rand::Rng; use std::io::stderr; const PI: f64 = std::f64::consts::PI; #[derive(Clone)] struct Vec3 { x: f64, y: f64, z: f64, } fn clamp(x: f64, min: f64, max: f64) -> f64 { if x < min { min } else if x > max { max } else { x } } impl Vec3...
true
0aa51024e6f46132485c184fe672fd72130e4e79
Rust
BugenZhao/raytracing.rs
/src/texture/image.rs
UTF-8
1,219
2.890625
3
[]
no_license
use anyhow::Result; use std::{fs::File, path::Path}; use crate::vec3::{Coord, RelColor}; use super::Texture; #[derive(Clone)] pub struct Png { width: u32, height: u32, scale: f64, buf: Vec<u8>, } impl Png { pub fn new<P: AsRef<Path>>(path: P) -> Result<Self> { let file = File::open(&path...
true
3e56497ee8c0a92bc0376719f00a74fbd6815a7e
Rust
i-e-b/RustExperiments
/linearAccessArray/src/main.rs
UTF-8
1,900
3.46875
3
[]
no_license
//! A sorted array of arbitrary values, with a secondary index that allows linear access over the //! value distribution of the array. //! Shows `rand` crate and sorting of partial ordered values. extern crate rand; use rand::{thread_rng, Rng}; use std::cmp::{Ordering}; /// Rust tries to be truthful about sorting f...
true
13f4e6a654f7d1acbc124e0f707b980c08ca55be
Rust
bytecodealliance/wasmtime
/crates/wasmtime/src/memory.rs
UTF-8
38,978
3.03125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
use crate::store::{StoreData, StoreOpaque, Stored}; use crate::trampoline::generate_memory_export; use crate::Trap; use crate::{AsContext, AsContextMut, Engine, MemoryType, StoreContext, StoreContextMut}; use anyhow::{bail, Result}; use std::cell::UnsafeCell; use std::convert::TryFrom; use std::ops::Range; use std::sli...
true
659b1fea3d7b28779373b2d623e0a8378a5a6a82
Rust
jbalint/mysql_type_migration
/src/main.rs
UTF-8
2,680
3.078125
3
[]
no_license
use std::process::Command; use std::error::Error; #[derive(Debug)] struct Column { table_name: String, column_name: String, datatype: String, column_type: String, collation_name: String, not_null: bool, column_length: i32, } fn find_latin1_fields() -> Result<Vec<Column>, Box<dyn Error>> { ...
true
2928b3ebb3db1660324a73566c79042296cc61a3
Rust
hacmorgan/rust-by-example
/09.fuctions/closures/type-anonymity.rs
UTF-8
725
3.53125
4
[]
no_license
/* Type anonymity refers to `F` in apply() Some type must be given for `F`, as explained by the tutorial: When a closure is defined, the compiler implicitly creates a new anonymous structure to store the captured variables inside, meanwhile implementing the functionality via one of the traits: Fn, FnMut, ...
true
d44b382264201163e81440e4531cc97da96e8028
Rust
scrogson/beamcoin
/native/beamcoin/src/miner.rs
UTF-8
3,680
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::atoms; use mpsc::{Receiver, Sender}; use rustler::{Atom, Encoder, Env, Error, LocalPid, OwnedEnv, ResourceArc, Term}; use scoped_pool::Pool; use sha2::Digest; use std::mem; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::{mpsc, Arc, Mutex}; static DIFFICULTY: usize = 6; lazy_static::lazy_stat...
true
8f3e1899c642b3ef21bf504c44e6e3d074c57c78
Rust
ZoeyR/wearte
/testing/benches/fmt.rs
UTF-8
2,481
3.0625
3
[ "MIT", "Apache-2.0" ]
permissive
use criterion; use std::fmt::{Display, Formatter, Result, Write}; pub fn big_table(b: &mut criterion::Bencher, size: &usize) { let mut table = Vec::with_capacity(*size); for _ in 0..*size { let mut inner = Vec::with_capacity(*size); for i in 0..*size { inner.push(i); } ...
true
152f64f7d5dc7210fb579f5bb23ae6bdf952a578
Rust
willbeason/chaos
/src/main.rs
UTF-8
1,021
2.828125
3
[]
no_license
use std::f64::consts::PI; use rand::Rng; mod foo; mod bar; mod models; fn main() { let mut rng = rand::thread_rng(); let spring = models::Spring{ a: 1.0, b: 5.0, d: 0.02, y: 12.0, w: 0.5, }; let mut points: Vec<(f64, f64)> = Vec::new(); for x in 0..1000 { ...
true
bec1921841b58d6a127bdf459a529626d8891fa4
Rust
youngbloood/actix3
/handler/src/student.rs
UTF-8
201
2.53125
3
[ "MIT" ]
permissive
use actix_web::{get,web,Responder}; #[get("/{id}/{name}/index.html")] pub async fn index(web::Path((id, name)): web::Path<(u32, String)>) -> impl Responder { format!("Hello {}! id:{}", name, id) }
true
3e4257d7499963cefeb6b79f0d01200a7ae9a65c
Rust
feldim2425/AdventOfCode19
/day_01/main.rs
UTF-8
1,297
3.1875
3
[]
no_license
#[path = "../common/title.rs"] mod title; use std::io::BufReader; use std::io::prelude::*; use std::io::Result; use std::fs::File; use std::vec::Vec; fn read_puzzle_input() -> Result<Vec<i32>> { let file = File::open("day_01/input.txt")?; let buffer = BufReader::new(file); let mut masses = Vec::new(); ...
true
4f0b3d1b34d09f5b938be65b750a816c626f79dd
Rust
MatheusMuriel/30DaysOfRust
/Day02_Operators/Day02_Operators.rs
UTF-8
1,015
2.828125
3
[]
no_license
use std::io; fn solve(meal_cost : f64, tip_tax : i32, tax_percent : i32) { let tip_cost : f64 = (meal_cost / 100f64) * tip_tax as f64; let tax_cost : f64 = (meal_cost / 100f64) * tax_percent as f64; let total_cost = meal_cost + tip_cost + tax_cost; let output : i32 = total_cost.round() as i32; println!("{}",...
true
755e29137954fb3d6053a1ee33eb310b3dd1ee6e
Rust
masinc/nlp100-rust
/src/ch01/problem07.rs
UTF-8
656
3.59375
4
[]
no_license
use crate::problem::Problem; struct Problem07; struct Args { x: u64, y: String, z: f64, } impl Problem for Problem07 { type Args = Args; type Result = String; fn answer(args: Self::Args) -> anyhow::Result<Self::Result> { let result = format!("{}時の{}は{}", args.x, args.y, args.z); ...
true
a9c521c734e64b6c548ed59373f7cba4c11eedec
Rust
XiangQingW/rust-protobuf
/protobuf/src/error.rs
UTF-8
3,290
2.953125
3
[ "BSD-2-Clause" ]
permissive
use std::io; use std::error::Error; use std::fmt; use std::str; use wire_format::WireType; pub type ProtobufResult<T> = Result<T, ProtobufError>; /// Enum values added here for diagnostic purposes. /// Users should not depend on specific values. #[derive(Debug)] pub enum WireError { UnexpectedEof, Unexpected...
true
013ee54bb4d6f5abfb84111d77bb5f547814a755
Rust
Chronophylos/chb4
/src/commands/commands/man.rs
UTF-8
1,417
2.9375
3
[ "MIT" ]
permissive
use super::prelude::*; pub fn command() -> Arc<Command> { Command::with_name("man") .aliases(vec!["help", "whatis", "hilbe"]) .command(move |context, args, _msg, _user| { if args.is_empty() { return Ok(MessageResult::MissingArgument("page")); } l...
true
b4e25be28546bff0491a14c51a151ce0ea728c68
Rust
achalddave/rust-tree
/src/main.rs
UTF-8
383
3
3
[ "MIT" ]
permissive
use std::env; mod tree; fn usage() { println!("Usage: tree [path]"); } fn main() { let args: Vec<String> = env::args().collect(); if args.len() > 2 { return usage(); } let mut path = "."; if args.len() > 1 { path = &args[1]; } match tree::tree(path) { Ok(_) =>...
true
7ac40034ed921add3b523faaaf123aeeacf7bd85
Rust
rodchenkov-sn/gazer
/src/gazer/tar_file.rs
UTF-8
837
2.640625
3
[]
no_license
use crate::gazer::chunk_provider::ChunkProvider; use crate::gazer::chunk_consumer::ChunkConsumer; use std::io::{Read, Write}; use std::io; pub struct TarFile { archive: std::fs::File } impl TarFile { pub fn new(archive: std::fs::File) -> TarFile { TarFile{ archive } } } impl C...
true
e071021e4778a6347701a29e5f4576feb80ff028
Rust
ear7h/editor
/src/buffer/view.rs
UTF-8
4,498
3
3
[]
no_license
use std::{ collections::linked_list::CursorMut, }; use crate::{ Line, LineMut, LineConfig, Buffer, Renderer, Result, }; pub struct View<'buf> { cur : CursorMut<'buf, String>, lcfg : &'buf LineConfig, cx : usize, // x position in current line } impl<'buf> View <'buf> { pub...
true
87f5e4cf3655098ab57db6d84d802a8623bc2df8
Rust
rahul-thakoor/embedded-graphics
/tinybmp/src/lib.rs
UTF-8
8,219
3.3125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Small BMP format image parser supporting no-std environments. Specifically designed to work with //! [embedded-graphics] //! //! # Examples //! //! ## Load a BMP image and check its [`Header`] and returned pixels. //! //! ```rust //! use tinybmp::{Bmp, FileType, Header, Pixel}; //! //! let bmp = Bmp::from_slice(inc...
true
f3cb25311627eade70158a3939e115cfc5d7e80a
Rust
cuplv/iodyn.rust
/src/lib.rs
UTF-8
2,547
2.734375
3
[]
no_license
//! A collection of incremental data structures with dynamic input //! and output. //! //! Many of the structures have an exposed mutable head for fast //! updates, and an `archive` function to move the current head //! past a pointer, defining subsequences. This pointer is //! mutable, so that the changes can propagat...
true
fb507f56044c97f2f9b43c3804043d5d985ced34
Rust
chmoder/data_vault
/src/tokenizer/blake3_tokenizer.rs
UTF-8
2,216
3.578125
4
[ "MIT" ]
permissive
use credit_card::CreditCard; use crate::tokenizer::{Tokenizer}; use crate::utils::Salt; pub struct Blake3Tokenizer; impl Tokenizer for Blake3Tokenizer { fn new() -> Self { Self {} } /// creates a token for a given credit card /// # Arguments /// * `CreditCard` - a credit card object to hash...
true
c78bd2e6a44b4f2b369e8dea8dae73c01efa28ca
Rust
jhelwig/homers
/src/cli.rs
UTF-8
8,500
2.71875
3
[ "MIT" ]
permissive
use clap::{App, AppSettings, Arg, SubCommand}; use std::path::Path; pub fn app<'a, 'b>() -> App<'a, 'b> { App::new("homers") .version(crate_version!()) .author("Jacob Helwig <jacob@technosorcery.net>") .about("Manage dotfiles in your home directory.") .setting(AppSettings::Subcomman...
true
fdcec8140016c8d49c1ca03eee6287d76c1e4dee
Rust
getong/linfa
/linfa-hierarchical/src/lib.rs
UTF-8
8,225
2.921875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::collections::HashMap; use kodama::linkage; pub use kodama::Method; use ndarray::ArrayView2; use linfa::dataset::{Dataset, Targets}; use linfa::traits::Transformer; use linfa::Float; use linfa_kernel::Kernel; /// Criterion when to stop merging /// /// The criterion defines at which point the merging process ...
true
fa463dbc412ebb3ea3f4a204e7eae236bc1fc72b
Rust
konamilk/atcoder-abc190
/src/bin/a.rs
UTF-8
322
2.828125
3
[]
no_license
use proconio::input; fn main() { input! {a: i32, b: i32, c: i32 } if a > b{ println!("Takahashi") } else if a < b{ println!("Aoki") } else { if c == 0{ println!("Aoki") } else { println!("Takahashi") } } ...
true
c5955a93712622ac04f345538c2952c3c59e0934
Rust
LiquidityC/aoc
/2020/day_04/src/main.rs
UTF-8
4,279
3.4375
3
[]
no_license
use std::{collections::HashMap, str::FromStr}; use regex::Regex; struct Passport { params: HashMap<String, String>, } impl FromStr for Passport { type Err = Box<dyn std::error::Error>; fn from_str(s: &str) -> Result<Self, Self::Err> { let entries: Vec<String> = s .replace("\n", " ") ...
true
9d4b5052194e99ef0d9b3d3ce7cd98cd7a8c37ad
Rust
beber89/dapp-mine-scenario
/src/connection.rs
UTF-8
6,765
2.96875
3
[]
no_license
extern crate mio; #[macro_use] extern crate log; extern crate env_logger; use std::io; use std::io::{Error, ErrorKind}; use std::net::SocketAddr; use std::str::FromStr; use mio::*; use mio::buf::ByteBuf; use mio::tcp::*; use mio::util::Slab; /// A stateful wrapper around a non-blocking stream. This connection is no...
true
d5f78fa1f3cfc7fd6204b1e4fe0af664adc684b0
Rust
wycharry/weld
/weld/util/colors.rs
UTF-8
594
3.640625
4
[ "BSD-3-Clause" ]
permissive
//! Basic format strings for colored output. #![allow(dead_code)] const RESET: &str = "\x1b[0m"; pub enum Color { Red, BoldRed, Green, Yellow } trait Prefix { fn prefix(&self) -> &str; } impl Prefix for Color { fn prefix(&self) -> &str { match *self { Color::Red => "\...
true
0670d726472ca6ade931bcbfda8af742bd174931
Rust
xCrypt0r/Baekjoon
/src/16/16861.rs
UTF-8
690
3.3125
3
[ "MIT" ]
permissive
/** * 16861. Harshad Numbers * * 작성자: xCrypt0r * 언어: Rust 2018 * 사용 메모리: 13,028 KB * 소요 시간: 0 ms * 해결 날짜: 2020년 10월 1일 */ use std::io; fn main() { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); let mut n = s.trim().parse::<u32>().unwrap(); loop { let sum = get_s...
true
2d432d4043c5da0414097d4fc5eae27ae1d39f86
Rust
dapptips/fluence
/trust-graph/src/key_pair.rs
UTF-8
2,416
2.5625
3
[ "Apache-2.0" ]
permissive
/* * Copyright 2020 Fluence Labs Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or a...
true
bed6afcf5db820f0a3c88c282c5a571425a4822d
Rust
tshepang/gitoxide
/git-odb/src/zlib/stream/deflate/tests.rs
UTF-8
1,659
3
3
[ "Apache-2.0", "MIT" ]
permissive
mod deflate_stream { use crate::zlib::stream::DeflateWriter; use crate::zlib::stream::InflateReader; use std::io::{Read, Write}; #[test] fn all_at_once() -> Result<(), Box<dyn std::error::Error>> { let mut w = DeflateWriter::new(Vec::new()); assert_eq!(w.write(b"hello")?, 5); ...
true
7d6363788ce2ae286146a4d5c272d166f45219a2
Rust
manicmaniac/Project_Euler
/rust/Problem3.rs
UTF-8
666
3.328125
3
[]
no_license
/* * The prime factors of 13195 are 5, 7, 13 and 29. * * What is the largest prime factor of the number 600851475143 ? */ use std::collections::HashMap; fn factorize(x: i64) -> HashMap<i64, i64> { let mut map: HashMap<i64, i64> = HashMap::new(); let mut x = x; let mut divisor = 2; while x >= diviso...
true
75bf2923a66e9442ed018618c491c13bf5bdf0ca
Rust
thombles/ax25-rs
/src/linux.rs
UTF-8
8,875
2.890625
3
[ "Apache-2.0" ]
permissive
#[cfg(not(target_os = "linux"))] use std::io::ErrorKind; use std::io::{self, Error}; use std::sync::atomic::{AtomicBool, Ordering}; /// An active AX.25 network interface, e.g. "ax0" pub(crate) struct NetDev { pub name: String, pub ifindex: i32, } /// An open socket for sending and receiving AX.25 frames pub(c...
true
4a62dc49654f0fee4d912a6aeab8c7f94bb4d74c
Rust
lemonrock/context-allocator
/src/allocators/bit_set/NumberOfBitSetWords.rs
UTF-8
1,275
2.859375
3
[ "MIT" ]
permissive
// This file is part of context-allocator. It is subject to the license terms in the COPYRIGHT file found in the top-level directory of this distribution and at https://raw.githubusercontent.com/lemonrock/context-allocator/master/COPYRIGHT. No part of context-allocator, including this file, may be copied, modified, pro...
true
4a676ec9118184c7a12bbfeb3043d05ed0cb2746
Rust
fits/try_samples
/rust/graphql_parser/sample/src/main.rs
UTF-8
417
2.546875
3
[]
no_license
use graphql_parser::query::{parse_query, ParseError}; fn main() -> Result<(), ParseError> { let ast = parse_query::<String>(r#" fragment ItemInfo on Item { id name price } query { items { ...ItemInfo color ...
true
fdb389842c027acbe6a827e4728d7f1818658f82
Rust
Asi7ho/Exercism
/rust/raindrops/src/lib.rs
UTF-8
340
2.796875
3
[]
no_license
pub fn raindrops(n: u32) -> String { let mut str = String::from(""); if n % 3 == 0 { str.push_str("Pling"); } if n % 5 == 0 { str.push_str("Plang"); } if n % 7 == 0 { str.push_str("Plong"); } if str.is_empty() { return String::from(n.to_string()); ...
true
cbbcb3a43e9b868c50831ce8c3380beb4de3b890
Rust
dantepippi/bacup
/src/remotes/aws.rs
UTF-8
4,436
2.84375
3
[ "Apache-2.0" ]
permissive
use s3::bucket::Bucket; use s3::creds::Credentials; use crate::config::AWSConfig; use crate::remotes::uploader; use std::io::prelude::*; use std::fs::File; use std::path::{Path, PathBuf}; use async_trait::async_trait; use std::fmt; #[derive(Debug)] pub enum Error { InvalidCredentials(s3::creds::AwsCredsError)...
true
d88839873435ca191c979c2e2c574a7c05f263a0
Rust
TGElder/rust
/frontier/src/services/background_service.rs
UTF-8
999
2.859375
3
[ "CC-BY-4.0" ]
permissive
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use commons::log::debug; use futures::executor::ThreadPool; use futures::Future; pub struct BackgroundService { pool: ThreadPool, tasks: Arc<AtomicUsize>, } impl BackgroundService { pub fn new(pool: ThreadPool) -> Self { Backgrou...
true
3d4ee975cb84db50e84b9c2f14ab69e2a04d6cc6
Rust
r3kzi/rust-projects
/data_structures/src/tuples.rs
UTF-8
633
3.53125
4
[]
no_license
#![allow(dead_code)] #![allow(unused_variables)] fn sum_and_product(x:i32, y:i32) -> (i32, i32) { (x+y, x*y) } pub fn tuples(){ let x = 3; let y = 4; let sp = sum_and_product(x,y); println!("sp = {:?}" , sp); println!("{0} + {1} = {2}, {0} * {1} = {3}", x, y, sp.0, sp.1); //destructuring...
true
365b25ad4c3532027a70ac09c56e171b1d57ca4d
Rust
reichigo/rust_real_world
/src/use_case/src/insert_user_usecase.rs
UTF-8
835
3.015625
3
[]
no_license
use async_trait::async_trait; #[async_trait] pub trait IInsertUserUseCase { async fn execult(&self, name: &str) -> Result<(), domain::errors::Error>; } pub struct InsertUserUseCase<'a, UR: domain::repositories::IUserRepository>{ user_repository: &'a UR } impl<'a, UR: domain::repositories::IUserRepository> Ins...
true
30f824ca1724a2f0b96b1ad8cf3ab10ff6b4bd42
Rust
H4rmey/Rust-OpenCL-Tutorial
/Tutorial4-Private_Local_Global/src/main.rs
UTF-8
4,231
2.796875
3
[]
no_license
extern crate ocl; use ocl::{Result as OclResult, Platform, Device, Context, Queue, Buffer, Program, Kernel, EventList, SpatialDims}; //string for the kernel static SRC: &'static str = r#" __kernel void add(__global int *in, __global int *out, __local int *temp) { int sum; uint global_id...
true
16b55d2e537392f0f46f07ae7b85c5dcd724991b
Rust
andylokandy/elba
/src/lib/util/config.rs
UTF-8
2,770
2.84375
3
[ "MIT" ]
permissive
//! Global `elba` configuration file specification. //! //! Configuration files change the behavior of the package manager, and can be both global and local //! to a package. Whereas package files are about specifying a package, config files specify the //! behavior of the tool itself. //! //! Environment variables (.e...
true
84adc7a38e2048eb2f1e7aba5a714b94e35f804e
Rust
foxfriends/root
/src/models/connection.rs
UTF-8
1,393
2.90625
3
[]
no_license
use super::*; use sqlx::{postgres::PgConnection, query, query_as}; #[derive(Clone, serde::Serialize, serde::Deserialize)] #[serde(rename = "connection")] pub struct Connection { position_a: i16, position_b: i16, closed: bool, } impl Connection { pub fn new(position_a: &Position, position_b: &Position)...
true
2fcf163648fc7cf412cc68c85c46823fe19d5ff9
Rust
andrewhickman/lang
/src/syntax/token.rs
UTF-8
2,577
3.671875
4
[]
no_license
use std::fmt; #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub enum Token<'src> { Ident(&'src str), Num(u32), // Binary Operators Star, Slash, Percent, Plus, Minus, Shr, Shl, Le, Lt, Ge, Gt, EqEq, NotEq, And, Caret, Or, AndAnd, OrOr, // Assignment Eq, StarEq, SlashEq, PercentEq, PlusEq...
true
a8de332cd0c4f0e6227b2439aa32b41a0022905d
Rust
dkeehl/chunfen
/chunfen-sec/src/client.rs
UTF-8
5,830
2.5625
3
[ "MIT" ]
permissive
use std::io::{self, Read, Write}; use ring::constant_time; use crate::data::{PlainText, TLSError, ContentType}; use crate::session::{Session, SessionCommon, Handler}; use crate::handshake::{Handshake, extract_handshake, Hash,}; use crate::key_schedule::{SecretKind, KeySchedule,}; use crate::encryption::{MsgEn...
true
e9295de9c6c369af7ec70878d172a8c5ece4abe1
Rust
plus7wist/rust-msgpack
/rust_msgpack/src/time.rs
UTF-8
966
2.828125
3
[ "MIT" ]
permissive
use crate::binary; use std::time::SystemTime; pub fn encode_time(t: SystemTime) -> Vec<u8> { match t.duration_since(SystemTime::UNIX_EPOCH) { Ok(n) => { let secs = n.as_secs(); if secs >> 34 == 0 { let data = ((n.subsec_nanos() as u64) << 34) | secs; ...
true
dcb5fac7a8fc530015680f0bd802b5635cd0575c
Rust
cdbfoster/takkerus
/tak/src/bitmap.rs
UTF-8
16,245
3.015625
3
[]
no_license
#![allow(clippy::unusual_byte_groupings)] use std::fmt; use crate::ply::Direction; #[repr(transparent)] #[derive(Clone, Copy, Eq, PartialEq)] pub struct Bitmap<const N: usize>(u64); impl<const N: usize> Bitmap<N> { pub const fn new(value: u64) -> Self { Self(value) } pub const fn empty() -> Sel...
true
359fa6cb9f8f9ff9e564e1efd6ba9f841921ec93
Rust
johnyenter-briars/gentle_intro_to_rust
/structs_enums_matching/move1.rs
UTF-8
214
2.84375
3
[]
no_license
fn dump(s: String) { println!("{}", s); } fn main() { // let s1 = "hello world".to_string(); // let s2 = s1; // println!("s1 {}", s1); let s3 = "hello world".to_string(); dump(s3); println!("s1 {}", s3); }
true
d36f9e0049777d94ab8799e6df42ba06f220b9bb
Rust
pact-foundation/pact-reference
/rust/pact_models/src/bodies.rs
UTF-8
13,769
3.390625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Module for handling interaction content (bodies) use std::fmt::{Display, Formatter}; use std::hash::{Hash, Hasher}; use std::mem; use std::str::from_utf8; use base64::Engine; use base64::engine::general_purpose::STANDARD as BASE64; use bytes::{Bytes, BytesMut}; use serde::{Deserialize, Serialize}; use serde_json:...
true
cac30300526efddfbcc94e002782c8536a588ee6
Rust
FyroxEngine/Fyrox
/fyrox-sound/src/decoder/wav.rs
UTF-8
3,956
2.703125
3
[ "MIT" ]
permissive
use crate::{buffer::DataSource, error::SoundError}; use hound::WavReader; use std::{ fmt::{Debug, Formatter}, io::{Read, Seek, SeekFrom}, sync::{Arc, Mutex}, time::Duration, }; /// Wav decoder pub(crate) struct WavDecoder { reader: WavReader<DataSource>, } impl Debug for WavDecoder { fn fmt(&s...
true
adbe2fcf9f2569a3f979153a52c1dab531b4f523
Rust
stulentsev/russianaicup
/CodeRoyale/src/model/item.rs
UTF-8
2,262
3.21875
3
[]
no_license
use super::*; /// Lootable item #[derive(Clone, Debug)] pub enum Item { /// Weapon Weapon { /// Weapon type index (starting with 0) type_index: i32, }, /// Shield potions ShieldPotions { /// Amount of potions amount: i32, }, /// Ammo Ammo { /// We...
true
364373442aaa050a6079887b445d9d4d77242cde
Rust
texbois/salmonbot
/src/behavior/stats.rs
UTF-8
2,040
2.53125
3
[]
no_license
use crate::behavior::{Behavior, ThreadResult}; use crate::storage::Storage; use crate::vkapi::{Client, VkApi, VkMessage, VkMessagesApi}; pub struct StatsBehavior { storage: Storage, admin_ids: Vec<i64>, } impl StatsBehavior { pub fn new(storage: Storage, admin_ids: Vec<i64>) -> Self { Self { stora...
true