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
a1fca17b32dab496b7e9e40dce825f73d5a1f843
Rust
su225/rust
/src/test/ui/resolve/token-error-correct-3.rs
UTF-8
1,052
2.546875
3
[ "MIT", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
// ignore-cloudabi no std::fs support // Test that we do some basic error correction in the tokeniser (and don't spew // too many bogus errors). pub mod raw { use std::{io, fs}; use std::path::Path; pub fn ensure_dir_exists<P: AsRef<Path>, F: FnOnce(&Path)>(path: P, ...
true
0995ca5ff9ee657620a1da3f0d8e23b1d9874284
Rust
haaawk/advent_of_code
/2021/day1/1a.rs
UTF-8
309
2.6875
3
[]
no_license
use std::io::{self, BufRead}; fn main() { let mut res = 0; let mut prev = None; let stdin = io::stdin(); let lines = stdin.lock().lines().map(|l| l.unwrap().parse::<i32>().unwrap()); for line in lines { if line > prev.unwrap_or(line) { res += 1; } prev = Some(line); } println!("{}", res); }
true
2eec83a8e28083e72b7b36b62c80aa79a384438c
Rust
Emerentius/ProjectEuler
/p259_reachable_numbers/src/main.rs
UTF-8
2,052
3.0625
3
[]
no_license
extern crate smallvec; // v0.3 extern crate num; // v0.1 use smallvec::SmallVec; // small optimization use num::rational::Ratio; use std::collections::HashSet; use std::ops::{Add, Sub, Div, Mul}; type DigitVec = SmallVec<[Ratio<i32>; 9]>; fn walk_concatenations(pos: usize, mut digits: DigitVec, reachable_nums: &mut H...
true
4415dbf9a7f763345077efed4c36a95a5ba179f9
Rust
1submarine/neutron
/src/ident.rs
UTF-8
822
3.140625
3
[]
no_license
use serde::{Deserialize, Serialize}; use uuid::Uuid; #[derive(Serialize, Deserialize, Debug, Clone, Eq)] pub struct Ident { name: String, refer: String, pub uuidv4: Uuid, } impl PartialEq for Ident { fn eq(&self, other: &Self) -> bool { self.uuidv4 == other.uuidv4 } } impl Ident { pub f...
true
ba0c9b80b93dd5391cad15129c50d4bcc4806581
Rust
wfraser/esedb-rs
/examples/groove-music.rs
UTF-8
8,720
2.78125
3
[]
no_license
//! This program is an example demonstrating how to use the ESEDB Rust library: //! https://github.com/wfraser/esedb-rs //! It reads the database used by the Groove Music app on Windows and outputs a list of all tracks //! in the collection of all profiles used by the current user. //! //! Copyright 2019 by William...
true
16133c9f789e8ebbb00cfc64e51b86b0a4f4fe08
Rust
positronicarts/advent-of-code-19-2pt1
/src/main.rs
UTF-8
836
3.203125
3
[]
no_license
fn main() { let mut computer : Vec<u64> = std::fs::read_to_string("inputs.txt").unwrap().split(",").map(|input| input.clone().parse::<u64>().unwrap()).collect(); let mut index = 0; computer[1] = 12; computer[2] = 2; loop { let clone = computer.clone(); match computer[index] { ...
true
1db16926e935f42806b8e795e85e75abc8d02309
Rust
AndWass/workops
/src/db/projects.rs
UTF-8
2,171
3.125
3
[]
no_license
use serde::Serialize; use sqlx::FromRow; #[derive(Serialize, FromRow, PartialEq, Eq, Debug)] pub struct Project { pub id: i64, pub name: String, pub description: String, pub created_at: crate::db::DateTime, owner: i64, } impl Project { pub async fn all(e: crate::db::Executor<'_>) -> sqlx::Resu...
true
76fbb19e2d134a661de3e72e34400fd64b5b90a9
Rust
PSeitz/rust_measure_time
/src/formatted_duration.rs
UTF-8
4,983
3.671875
4
[ "MIT" ]
permissive
use std::{fmt, time::Duration}; /// A wrapper type that allows you to Display a Duration #[derive(Debug, Clone)] pub struct FormattedDuration(Duration); pub fn format_duration(val: Duration) -> FormattedDuration { FormattedDuration(val) } fn item_plural(f: &mut fmt::Formatter, started: &mut bool, name: &str, val...
true
9140e3283236077a491fdb5aee588822e1f338e3
Rust
Kollode/RustByExample
/1-hello_world/src/main.rs
UTF-8
255
2.96875
3
[]
no_license
fn main() { println!("Hello, world!"); println!("I'm awesome"); // println!("Hello, world!") without ; will work // but only if there is no second println!. // Probably because the println is a expression and can // be returned }
true
b36436d6b88432d04e73ef3631ec3b99ba397422
Rust
KillingSpark/librdbus
/src/message_iter.rs
UTF-8
20,271
2.625
3
[]
no_license
use rustbus::params; use rustbus::signature; use std::ffi::CStr; pub struct SubAppendIter<'a> { params: Vec<params::Param<'a, 'a>>, typ: rustbus::signature::Container, } enum MessageIterInternal<'a> { // pushes contents into message MainAppendIter(*mut crate::DBusMessage<'a>), // pushes contents i...
true
a7436f7040221dd88f5509b2948fde71361b23cc
Rust
ronniec95/xladd-derive
/src/lib.rs
UTF-8
24,376
2.59375
3
[ "MIT" ]
permissive
use proc_macro::*; use std::collections::BTreeMap; use quote::quote; use syn::{FnArg, ItemFn}; #[proc_macro_attribute] pub fn xl_func(attr: TokenStream, input: TokenStream) -> TokenStream { // println!("{:?}", attr); // println!("{:?}", input); // println!("{:?}", input); let item = syn::parse::<It...
true
b5314e059d6f67bd47ed64b7dcde0fded6d6c7b4
Rust
biaoma-ty/arrow-datafusion
/datafusion/common/src/config.rs
UTF-8
31,222
2.96875
3
[ "Apache-2.0", "MIT", "BSD-3-Clause", "BSD-2-Clause" ]
permissive
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may...
true
3f50c7ec10a58cce14da79df5175a1546bd08e15
Rust
raaavioli/GraphicsPlayground
/src/renderer/event.rs
UTF-8
3,853
3.5
4
[]
no_license
use std::collections::HashMap; use glutin::event::{VirtualKeyCode, MouseButton, ElementState}; /* * https://github.com/rust-windowing/glutin/issues/708 * Code for polling events */ /// Keeps track of which keys have been pressed. pub struct EventState { state: HashMap<KeyCode, ElementState>, } impl EventState { ...
true
056872db09b8caf1290c94dd03cb40f6748b4d50
Rust
mooware/adventofcode2015
/src/day3_2.rs
UTF-8
834
3.21875
3
[]
no_license
use std::collections::HashSet; use std::io; use std::io::BufRead; fn main() { let mut santa = (0, 0); let mut robosanta = (0, 0); let mut is_robo = false; let mut set : HashSet<(i32, i32)> = HashSet::new(); set.insert(santa); let stdin = io::stdin(); for l in stdin.lock().lines() { ...
true
6f0624f5203192c55ea172827e5dcefffa50116f
Rust
cschaible/actix-web-security
/src/authentication/scheme/bearer/jwt/authentication_provider.rs
UTF-8
1,873
2.953125
3
[ "MIT", "Apache-2.0" ]
permissive
//! A default implementation of an `AuthenticationProvider` for a JWT based OAuth2 authentication. use async_trait::async_trait; use crate::authentication::error::error_type::AuthenticationError; use crate::authentication::scheme::authentication::Authentication; use crate::authentication::scheme::authentication_provi...
true
35bd9b9290ecab24889cb01e80e8ec443ba780e5
Rust
CYBAI/verticalize-text-rs
/src/args.rs
UTF-8
746
2.96875
3
[]
no_license
use app; #[derive(Debug)] pub struct Args { pub separator: String, pub line_direction: String, pub word_direction: String, pub no_rotate: bool, pub filepath: Option<String> } impl Args { pub fn parse() -> Result<Args, &'static str> { let matches = app::app().get_matches(); let filepath = match ma...
true
c238fe699d68bdefdae9a0c045a099ee8fba4e71
Rust
jiangzhe/mudterm
/src/runtime/model.rs
UTF-8
9,892
3.015625
3
[ "MIT" ]
permissive
use crate::error::{Error, Result}; use mlua::ToLua; use regex::Regex; use std::collections::HashMap; use lazy_static::lazy_static; /// 持有模型的基本属性 #[derive(Debug, Clone)] pub struct Model<X> { pub name: String, pub group: String, pub pattern: String, pub enabled: bool, pub extra: X, pub(super) re...
true
6be761e2dd213d79421dfe141bc03d550287bbab
Rust
Th3Whit3Wolf/fetch
/lib_fetch/lib/shell.rs
UTF-8
1,737
3.140625
3
[ "Unlicense" ]
permissive
use std::env::var_os; pub enum Shell { Windows, Bash, Tcsh, Zsh, Ksh, Unknown, } pub fn shell() -> Shell { if cfg!(windows) { Shell::Windows } else { if let Some(shell) = var_os("BASH") { if shell.to_string_lossy().ends_with("/bash") { return...
true
d466ee2f30339cb72c6ac1c7f7d25053b0ed8c55
Rust
three-rs/three
/examples/shapes.rs
UTF-8
2,121
2.515625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
extern crate cgmath; extern crate mint; extern crate three; use cgmath::prelude::*; use three::Object; fn main() { let mut win = three::Window::new("Three-rs shapes example"); let cam = win.factory.perspective_camera(75.0, 1.0 .. 50.0); cam.set_position([0.0, 0.0, 10.0]); let mbox = { let geo...
true
58e71ffb22534fe4efe21434378b10291433a407
Rust
brandur/umbrella-rust
/main.rs
UTF-8
2,622
2.671875
3
[]
no_license
#[crate_id = "umbrella"]; extern mod extra; extern mod http; use std::io::net::ip::{SocketAddr, Ipv4Addr, Port}; use std::io::Writer; use std::os; use http::client::{RequestWriter, ResponseReader}; use http::server::{Config, Server, Request, ResponseWriter}; use http::server::request::{AbsolutePath, AbsoluteUri}; #...
true
b5b55736e6fcc8ba9d71c1bb7f893bf835624b30
Rust
Katoven/rust
/tutorial/rusttut.rs
UTF-8
7,997
3.390625
3
[]
no_license
use std::{ i8, i16, i32, i64, u8, u32, u64, isize, usize, f32, f64 }; use std::io::stdin; fn main() { println!("Hello world!"); let _num = 10; let mut _age: i32 = 40; println!("Max i8 {}", i8::MAX); println!("Min i8 {}", i8::MIN); println!("Max i16 {}", i16::...
true
88fcdbbe3c676ebf928f5cb1401c8389dcb05b3a
Rust
noreflection/rst
/algs/src/fibonacci.rs
UTF-8
313
3.421875
3
[]
no_license
//The Fibonacci numbers are the numbers in the following integer sequence. //0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ... //In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation #![allow(dead_code)] pub fn fibonacci_naive_imperative() { println!("hey") }
true
03bd052549e4bd1e3cbc196044df953510bc7de0
Rust
Godspower-Eze/Learning-Rust-Programming
/src/pointer_ref.rs
UTF-8
501
4.4375
4
[]
no_license
// Reference Pointer: Points to a resource in the memory pub fn run(){ // Primitive Array let arr1 = [1,2,3]; let arr2 = arr1; println!("Arrays: {:?}", (arr1, arr2)); // With non-primitives, if you assign number another variable to a piece of data, the first variable // will no longer hold tha...
true
016e3f6f85498fce89c81d455e1facbbdd13c572
Rust
wking/cincinnati
/vendor/sha-1/src/lib.rs
UTF-8
2,690
2.765625
3
[ "MIT", "Apache-2.0" ]
permissive
//! An implementation of the [SHA-1][1] cryptographic hash algorithm. //! //! # Usage //! //! ```rust //! use hex_literal::hex; //! use sha1::{Sha1, Digest}; //! //! // create a Sha1 object //! let mut hasher = Sha1::new(); //! //! // process input message //! hasher.update(b"hello world"); //! //! // acquire hash dige...
true
be257e3d8101f504f370308d3da7867f06306ccb
Rust
HerbertHe/learn-rust
/src/main.rs
UTF-8
2,708
4.15625
4
[]
no_license
/// 变量 /// rust 是强类型语言并且默认数据不可变 /// 可变数据需要加上 mut, 得考虑精度问题 fn variable() { let a = 123; let mut a = 123; a = 456; // 不可变变量和常量不同, 不可变变量可以重影, 但是常量的值不可以重影 (标识符重名) // 重影是指用同一个标识符代表另一个变量实体 } /// 数据类型 fn data_type() { // 8, 16, 32, 64, 128 有符号, 无符号 int // arch, isize, usize 位长度取决于处理器架构 // 十进制 ...
true
39ce634e68d3526f63bb9b4505b54044decbe0ff
Rust
Ltei/cubrain
/src/training/genetic.rs
UTF-8
4,036
2.578125
3
[]
no_license
use std; use CudaHandleHolder; use CloneStructure; use GetParams; use VectorUtils; use error_calculator::*; use training::magnitude_manager::*; struct TrainingTrainable<T: GetParams + CloneStructure> { error: f32, trainable: T, } struct ChildsRatios { ratios: Vec<f32>, } impl ChildsRatios { fn new(...
true
501833d0670a3d8dda3faa9000de7381a1fe98c8
Rust
metaview-org/mlib
/src/lib.rs
UTF-8
3,546
2.71875
3
[]
no_license
use ammolite_math::{Mat4, Vec3}; use serde::{Serialize, Deserialize}; pub mod event; pub use event::*; pub use proc_macro_mapp::mapp; pub mod mlib { pub use super::*; } #[mapp(interface)] struct MappInterface {} #[derive(Default, Debug, Clone, Serialize, Deserialize)] pub struct IO { pub out: Vec<u8>, ...
true
92e3403a5415ffc67546cbf1481ae10f0c154c01
Rust
schungx/rhai
/examples/simple_fn.rs
UTF-8
379
3.609375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! An example showing how to register a simple Rust function. use rhai::{Engine, EvalAltResult}; fn add(x: i64, y: i64) -> i64 { x + y } fn main() -> Result<(), Box<EvalAltResult>> { let mut engine = Engine::new(); engine.register_fn("add", add); let result = engine.eval::<i64>("add(40, 2)")?; ...
true
a1bc41bf517203c2577024a76938cef7f6f37585
Rust
tomhoule/prisma-query
/src/connector/sqlite/conversion.rs
UTF-8
1,534
2.59375
3
[ "Apache-2.0" ]
permissive
use crate::{ ast::ParameterizedValue, connector::queryable::{ToColumnNames, ToRow}, }; use rusqlite::{types::ValueRef, Row as SqliteRow, Rows as SqliteRows}; impl<'a> ToRow for SqliteRow<'a> { fn to_result_row<'b>(&'b self) -> crate::Result<Vec<ParameterizedValue<'static>>> { let mut row = Vec::new...
true
73057b511853eed9e6b0ea13de4de6c9569d3e0a
Rust
ivardb/AdventOfCode2020
/src/days/day20/mod.rs
UTF-8
1,652
2.953125
3
[]
no_license
use grid::Grid; use std::collections::HashMap; pub mod part1; pub mod part2; pub fn run() { part1::run(); part2::run(); } pub fn default_input() -> &'static str { include_str!("input") } pub fn parse_input(input : &str) -> HashMap<i64, Picture>{ input.split("\n\n").map(|t| { let mut lines = ...
true
92413df6f25b132214d47ca7f35871278e524059
Rust
strogo/frontend-3
/src/application/graph/signal.rs
UTF-8
297
2.65625
3
[ "MIT" ]
permissive
#[derive(Clone)] pub enum Signal { Draw, Level(String, i32), } impl ::relm::DisplayVariant for Signal { fn display_variant(&self) -> &'static str { match *self { Signal::Draw => "Signal::Draw", Signal::Level(_, _) => "Signal::Level", } } }
true
dfde80ac46f00c1b5497aac39fa51ac1a8f01a87
Rust
plazma-tool/plazma-tool
/plazma/src/utils.rs
UTF-8
736
3.5
4
[ "MIT" ]
permissive
use std::error::Error; use std::fs::File; use std::io::Read; use std::path::PathBuf; /// Takes a path to a file and try to read the file into a String pub fn file_to_string(path: &PathBuf) -> Result<String, Box<dyn Error>> { let mut file = match File::open(path) { Ok(f) => f, Err(e) => { ...
true
804bad91c5b3c37e502cd7d50c0756aa89d1f3d2
Rust
yordivad/Rust
/src/logic.rs
UTF-8
235
2.828125
3
[ "MIT" ]
permissive
pub fn and(a: bool, b: bool) -> bool { match (a, b) { (true, true) => true, _ => false, } } pub fn xor(a: bool, b: bool) -> bool { match (a, b) { (false, false) => false, _ => true, } }
true
304b1841de9f1940d610fa0e445e6f7cad7a40ed
Rust
warcraft-iii/MopaqPack-rs
/src/main.rs
UTF-8
6,974
2.625
3
[ "MIT" ]
permissive
extern crate clap; use clap::{Arg, App, SubCommand}; use failure::{Error}; use std::collections::HashMap; use std::fs; use ceres_mpq as mpq; type FileList = HashMap<String, String>; fn main() -> Result<(), Error> { let matches = App::new("MopaqPack-rs") .version("1.0") .author("Jai <814683@qq.c...
true
d6c8de86704445d67c706c85b6397fa06aca1851
Rust
ganmacs/rlisp
/src/error.rs
UTF-8
2,002
3
3
[ "MIT" ]
permissive
use std::error; use std::fmt; pub type RResult<T, E> where E: error::Error = Result<T, E>; #[derive(Debug, PartialEq)] pub enum RLispError { EvalError(EvalError), ParseError(ParseError), } impl fmt::Display for RLispError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ...
true
396d5951ff17584fde1b3d14c1361c20989efe27
Rust
sdroege/grimoire
/src/config.rs
UTF-8
12,695
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use std::collections::BTreeMap; use error::{Error, Result}; use regex::Regex; use toml; #[derive(Debug, Default, Deserialize, PartialEq, Clone)] pub struct EffectConfig { #[serde(rename = "pass", default)] pub passes: Vec<PassConfig>, #[serde(flatten, default)] pub resources: BTreeMap<String, Resource...
true
1b6cdb9b1be8abff7f39aa742f27c4231df9616d
Rust
danifujii/rbranchsearch
/src/gui.rs
UTF-8
1,348
2.765625
3
[]
no_license
use crossterm::{cursor, execute, queue, style, style::Color, terminal, Result}; use std::io::{Stdout, Write}; pub fn display_closing_error(mut stdout: &Stdout, err: String) -> Result<()> { terminal::disable_raw_mode()?; execute!( stdout, terminal::Clear(terminal::ClearType::All), cursor...
true
9773d23c40d3ac9a00c3f3c9f9b5cc05f8d507d3
Rust
Tristan1075/crawler_rust
/src/main.rs
UTF-8
3,070
3
3
[]
no_license
use html5ever::tokenizer::{ BufferQueue, Tag, TagKind, TagToken, Token, TokenSink, TokenSinkResult, Tokenizer, TokenizerOpts, }; use std::borrow::Borrow; use url::{ParseError, Url}; use async_std::task; use surf; use std::error::Error; use std::io; use std::fs::{OpenOptions}; use std::io::Write; type CrawlResult...
true
3d1d33a4941b3fa14c6788c1e4033899c95c5504
Rust
anupvarghese/rust-docker
/primitive-types/src/main.rs
UTF-8
741
3.78125
4
[]
no_license
fn main() { // arrays let a = [1, 2, 3, 4]; println!("Array[0] is {}", a[0]); let mut b = ['a', 'b']; println!("Char array, b[0], {}", b[0]); b = ['c', 'd']; println!("Char array, b[0] {} and length of b is {}", b[0], b.len()); // Slices let all = &a[..]; println!("Copied a into...
true
1b3906b4c82ad380c389903d7be1df4b6f04d262
Rust
Azure/azure-sdk-for-rust
/sdk/core/src/models/etag.rs
UTF-8
632
3.046875
3
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use serde::{Deserialize, Serialize}; use std::{fmt, str::FromStr}; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct Etag(String); impl<T> From<T> for Etag where T: Into<String>, { fn from(t: T) -> Self { Self(t.into()) } } impl AsRef<str> for Etag { fn as_ref(&self) -...
true
d9fb7934bd37bce578896490b850d4078720e8b5
Rust
daniel5151/iotedge
/containrs/docker-reference/tests/reference_test.rs
UTF-8
8,296
2.78125
3
[ "MIT" ]
permissive
//! Extended from github.com/docker/distribution/reference/reference_test.go use docker_reference::*; mod common; use common::ExpectedRawReference; // TODO: look into using `proptest` to iron-out parsing issues #[test] fn bare() { assert_eq!( "test_com".parse::<RawReference>().unwrap(), Expected...
true
bab5a477cd810b92d05ad5702282e755a08b674e
Rust
jazzfool/Qglif
/src/renderer/guidelines.rs
UTF-8
1,874
2.609375
3
[ "MIT" ]
permissive
use super::constants::*; use super::points::calc::*; use crate::state; use reclutch::skia::{Canvas, Color, Paint, PaintStyle, Path}; use state::State; enum GuidelineType { Horizontal, Vertical, } fn draw_guideline(color: Color, where_: f32, gtype: GuidelineType, canvas: &mut Canvas) { let mut paint = Pain...
true
fa87a3d1f2d6359e55ad59249fea77b1bae1e3ba
Rust
j-rock/fortress
/fortress/src/lib/render/bloom/bloom_ping_pong_buffer.rs
UTF-8
786
2.546875
3
[ "MIT" ]
permissive
use crate::{ app::StatusOr, render::{ FrameBuffer, FrameBufferTexture, } }; use gl; use glm; pub struct BloomPingPongBuffer { frame_buffer: FrameBuffer, color_texture: FrameBufferTexture, } impl BloomPingPongBuffer { pub fn new(screen_size: glm::IVec2) -> StatusOr<Self> { ...
true
ab872aef6414a19f5d6d8a4991d34af87629db6c
Rust
FindoraNetwork/merk
/src/tree/ops.rs
UTF-8
16,910
3.171875
3
[]
no_license
use super::{Fetch, Link, Tree, Walker}; use crate::error::Result; use failure::bail; use std::collections::LinkedList; use std::fmt; use Op::*; /// An operation to be applied to a key in the store. pub enum Op { Put(Vec<u8>), Delete, } impl fmt::Debug for Op { fn fmt(&self, f: &mut fmt::Formatter) -> fmt:...
true
ef0a2efd161ad6953ca5c9650dfe5f7c83c6bad9
Rust
Talw3g/gcode_timer
/src/gcode_lexer.rs
UTF-8
4,488
2.859375
3
[]
no_license
use super::errors::*; use super::objects_def::*; use super::lineparser::*; impl Machine { pub fn line_depacker(&mut self, line: Vec<Codes>) -> Result<(ModalGroup, &Option<u8>)> { let mut dest = Coord::new(); let mut speed = None; for item in line { match item { C...
true
29c000b09485de8651e3d92dc1f6a5e40352975e
Rust
nvim-treesitter/nvim-treesitter
/tests/indent/rust/comment.rs
UTF-8
185
3.03125
3
[ "Apache-2.0" ]
permissive
/// Function foo /// /// Description of /// function foo. fn foo(x: i32, y: i32) -> i32 { x + y } impl A { /// Do some stuff!! (put cursor here and press enter) fn a(); }
true
1223115d895e7eafd5e16c0d8680262c7278c7c0
Rust
Azure/azure-sdk-for-rust
/sdk/data_cosmos/src/resources/document/query.rs
UTF-8
2,161
3.6875
4
[ "MIT", "LicenseRef-scancode-generic-cla", "LGPL-2.1-or-later" ]
permissive
use serde_json::Value; /// A SQL Query /// /// You can learn more about how SQL queries work in Cosmos [here](https://docs.microsoft.com/azure/cosmos-db/sql-query-getting-started). #[derive(Debug, Serialize, Clone)] pub struct Query { query: String, parameters: Vec<Param>, } impl Query { /// A new SQL que...
true
f8e64616abe4fb29a2315ce8c8356ca1b4c68646
Rust
wao/android_system_bt
/gd/rust/topshim/macros/src/lib.rs
UTF-8
3,309
2.96875
3
[ "Apache-2.0" ]
permissive
//! Macro for topshim extern crate proc_macro; use proc_macro::TokenStream; use quote::{format_ident, quote}; use syn::parse::{Parse, ParseStream, Result}; use syn::{parse_macro_input, Block, Ident, Path, Stmt, Token, Type}; /// Parsed structure for callback variant struct CbVariant { dispatcher: Type, fn_pa...
true
05f0e2501657056617a8b09b69c58df986950f8a
Rust
juicycleff/guardian-rust
/backend/src/api/rest/account/session_controller.rs
UTF-8
1,562
2.625
3
[]
no_license
use actix_guardian_identity::Identity; use actix_web::web::{Data, Json}; use crate::api::services; use crate::common::auth::utils::{create_jwt, PrivateClaim}; use crate::common::helpers::{respond_json, AppResult}; use crate::common::validate::validate; use crate::data::dtos::account_dto::PostAccountResponse; use crate...
true
ab25035bfdfa0794c2f804b19292cb79538054c5
Rust
dashed/grokdb2
/src/context.rs
UTF-8
6,872
2.78125
3
[]
no_license
/* rust lib imports */ use std::collections::HashMap; use std::sync::{Arc, RwLock}; use std::rc::Rc; use std::cell::RefCell; /* 3rd-party imports */ use guardian::{ArcRwLockReadGuardian, ArcRwLockWriteGuardian}; /* local imports */ use types::{DeckID, ItemCount, UserID}; use api::decks::Deck; use api::cards::Card;...
true
780fd0705f6cffaf2890ffe93b0ef3f797a936b6
Rust
17cupsofcoffee/tetra-template
/src/main.rs
UTF-8
1,000
2.625
3
[ "MIT" ]
permissive
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] use std::panic; use std::process; use std::thread; fn main() { panic::set_hook(Box::new(|e| { // This should work on desktop, at least. if let Some("main") = thread::current().name() { let msg = e.to_string(); ...
true
58436b1f0cbd455a5899a82b4131d731617a7fd3
Rust
PoorlyDefinedBehaviour/introduction_to_type_systems
/simply_typed_lambda_calculus/src/ast.rs
UTF-8
2,563
4.1875
4
[]
no_license
// The simply typed lambda calculus has two different // sorts of types: // // Function types // // We write the type of a function that accepts a parameter // of type τ and returns a value of type τ' as τ -> τ'. // // The identity function on booleans, for example, accepts a // parameter of type Bool and returns a val...
true
7786824a74943dbc2f2df04991da9543d291e6a6
Rust
Tenjin0/rust-leetcode
/add_binary/src/lib.rs
UTF-8
1,192
3.375
3
[]
no_license
use std::cmp; pub fn add(a: String, b: String) -> String { let max = cmp::max(a.len(), b.len()); let rev_a: Vec<char> = format!("{:0>width$}", a, width=max).chars().rev().collect(); let rev_b: Vec<char> = format!("{:0>width$}", b, width=max).chars().rev().collect(); let mut res = String::from(""); ...
true
ac81d56ba1941738b35afa2e6a477b2f02ebcfd7
Rust
p0lunin/teloxide-core
/src/types/mask_position.rs
UTF-8
1,682
3.484375
3
[ "MIT" ]
permissive
use serde::{Deserialize, Serialize}; /// This object describes the position on faces where a mask should be placed by /// default. /// /// [The official docs](https://core.telegram.org/bots/api#maskposition). #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub struct MaskPosition { /// The part of the f...
true
ce30607e302f84f2722c96d4e7f98e9ddbd9ae3a
Rust
EFanZh/LeetCode
/src/problem_0648_replace_words/mod.rs
UTF-8
1,356
3.09375
3
[]
no_license
pub mod trie; pub trait Solution { fn replace_words(dictionary: Vec<String>, sentence: String) -> String; } #[cfg(test)] mod tests { use super::Solution; pub fn run<S: Solution>() { let test_cases = [ ( (&["cat", "bat", "rat"] as &[_], "the cattle was rattled by the ba...
true
982fdcc6293457bd0d6e01c4a461423d8f1f07e9
Rust
mrkgnao/abseil
/src/patch.rs
UTF-8
728
3.046875
3
[]
no_license
pub struct Delta<T: ?Sized + Patch>(pub <T as Patch>::Delta); pub trait Patch { type Delta; fn patch(&self, delta: Delta<Self>) -> Self; fn patch_mut(&mut self, delta: Delta<Self>) where Self: Sized, { *self = self.patch(delta); } } impl Patch for () { type Delta = (); fn patch(&self, _delta: ...
true
ce6a494f0432e06aeed219462705974d46fca11a
Rust
Elinvynia/shortener
/src/utils.rs
UTF-8
2,217
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::ctx; use crate::data::User; use crate::state::State; use nanoid::nanoid; use tide::http::mime; use tide::sessions::Session; use tide::{Request, Response}; const ALPHABET: [char; 57] = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', ...
true
53bd4be81ac46601e9ba978a3f3281b689d686a1
Rust
simonThiele/rust_tutorial
/04_testing/testing/tests/lib.rs
UTF-8
86
2.546875
3
[]
no_license
extern crate adder; #[test] fn should_add() { assert_eq!(adder::add(3, 2), 5); }
true
1d64d09dac0115705b45aded4dd19587f688977e
Rust
teloxide/teloxide
/crates/teloxide-core/src/payloads/hide_general_forum_topic.rs
UTF-8
754
2.515625
3
[ "MIT" ]
permissive
//! Generated by `codegen_payloads`, do not edit by hand. use serde::Serialize; use crate::types::{Recipient, True}; impl_payload! { /// Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the _can\_manage\_topics_ ad...
true
1e35c3d615391dd73425880d61566d00591ab8c4
Rust
Mohamedkz/csv-filter
/lib/config/src/lib.rs
UTF-8
984
3.015625
3
[ "MIT", "LicenseRef-scancode-philippe-de-muyter" ]
permissive
extern crate hashbrown; extern crate serde_json; use hashbrown::HashSet; use serde::Deserialize; /// Represents detailed column configuration of a filter configuration. #[derive(Deserialize, Debug)] pub struct ColumnFilter { pub column: String, pub include: bool, pub values: Option<HashSet<String>>, p...
true
0af6915e43b8ccc48a189890e535dbfb7e53ac0b
Rust
grakshith/crust
/src/rs/src/linked_list_unsafe.rs
UTF-8
1,319
3.34375
3
[ "MIT" ]
permissive
use std::ptr; #[derive(Debug)] struct Node { value: i32, next: *mut Node } #[derive(Debug)] struct List { head: *mut Node } impl List { fn new() -> Self { List { // head: 0x0usize as *mut Node head: ptr::null_mut() } } fn add(&mut self, value: i32) { let new_node = Box::new(Node { value, nex...
true
770d97eaf0544459611cfa381867dafc893418ce
Rust
gnoliyil/fuchsia
/src/lib/fuchsia-async/src/handle/zircon/rwhandle.rs
UTF-8
7,536
2.625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2018 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. use { crate::runtime::{EHandle, PacketReceiver, ReceiverRegistration}, fuchsia_zircon::{self as zx, AsHandleRef}, futures::task::{AtomicWaker, ...
true
a6c88a168407fa951afcb6f0445ab2fd42841b1a
Rust
ufwt/SMB_Fuzzer
/src/fuzzing_lib/src/fuzzer/query_info_fuzzer.rs
UTF-8
3,136
2.6875
3
[ "MIT" ]
permissive
use super::create_random_byte_array_of_predefined_length; use super::create_random_byte_array_with_random_length; use crate::smb2::requests::query_info::{InfoType, QueryInfo}; pub const DEFAULT_BUFFER_LENGTH: &[u8; 4] = b"\xff\xff\x00\x00"; /// Fuzzes the query info request with predefined values. pub fn fuzz_query_i...
true
a1e277926d04f0180e4fc084d1962f6058b0980d
Rust
ValorZard/FixedPhysics.rs
/src/main.rs
UTF-8
857
2.796875
3
[ "MIT" ]
permissive
extern crate num_traits; pub mod physics; pub mod type_defs; use type_defs::FP; use crate::physics::structs::{Vector2, RectCollider}; use fixed_macro::fixed; fn main() { // LUT table test const SIN45: FP = fixed!(0.7071: I48F16); // normal fixed point testing let numb = FP::from_num(19) / 3; prin...
true
a0599d6243fd1dcbc1f91932fa6b3b81da051640
Rust
mbergenlid/rustiness
/nes/tests/screen/mod.rs
UTF-8
1,546
2.71875
3
[]
no_license
#[allow(dead_code)] pub const BACK_DROP: (u8, u8, u8) = (0, 0, 0); pub const WHITE: (u8, u8, u8) = (255, 255, 255); #[allow(dead_code)] pub const ORANGE: (u8, u8, u8) = (0xCB, 0x4F, 0x0F); #[allow(dead_code)] pub const BROWN: (u8, u8, u8) = (0x00, 0x3F, 0x17); #[allow(dead_code)] pub const GREEN: (u8, u8, u8) = (0xB3, ...
true
24ff8a60b52a34691cc5d49d096f2c88ca718294
Rust
bottlerocket-os/bottlerocket
/sources/api/datastore/src/error.rs
UTF-8
2,155
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use snafu::Snafu; use std::io; use std::path::PathBuf; use super::{serialization, ScalarError}; /// Possible errors from datastore operations. #[derive(Debug, Snafu)] #[snafu(visibility(pub))] pub enum Error { #[snafu(display("Error serializing {}: {} ", given, source))] Serialization { given: String,...
true
d2199b434b86a544b46aff780743eeea515ad28e
Rust
juniorbassani/advent-of-code-2020
/src/day20.rs
UTF-8
11,864
3.015625
3
[]
no_license
use ndarray::Array2; use std::fmt::{self, Display, Formatter}; const INPUT_PATH: &str = "input/day20"; #[derive(Debug, Copy, Clone, PartialEq, Eq)] enum Pixel { On, Off, } impl Display for Pixel { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Pixel::On => write!(f...
true
05d359cc0e92c5ca2c52e49b0774f7e0ba7faf65
Rust
Byron/gitoxide
/gix-config-value/tests/value/integer.rs
UTF-8
2,159
3.078125
3
[ "MIT", "Apache-2.0" ]
permissive
use std::convert::TryFrom; use gix_config_value::{integer::Suffix, Integer}; use crate::b; #[test] fn from_str_no_suffix() { assert_eq!(Integer::try_from(b("1")).unwrap(), Integer { value: 1, suffix: None }); assert_eq!( Integer::try_from(b("-1")).unwrap(), Integer { value: -1, ...
true
c265b992e22ca3ad60e36478246c3ab23f1ab3af
Rust
janpauldahlke/fhir-rs
/src/model/Specimen_Container.rs
UTF-8
10,503
3.0625
3
[ "MIT" ]
permissive
#![allow(unused_imports, non_camel_case_types)] use crate::model::CodeableConcept::CodeableConcept; use crate::model::Element::Element; use crate::model::Extension::Extension; use crate::model::Identifier::Identifier; use crate::model::Quantity::Quantity; use crate::model::Reference::Reference; use serde_json::json; u...
true
a892defe9187011205e645a17af4170b2ccae8c6
Rust
RobJenks/google-code-jam
/src/codejam_2018/qualifier_2.rs
UTF-8
2,802
3.125
3
[]
no_license
#[path = "../util/mod.rs"] mod util; pub fn run() { let input = util::stdin_all(); let mut it = input.iter(); let cases = it.next().unwrap().parse::<i32>().unwrap(); (0..cases) .for_each(|x| { it.next(); // Don't care about value count, we get it from the values themselves ...
true
0451814e62ea5725dfaff84f4ae8f321f5db2e94
Rust
lumost/native_spark
/src/dag_scheduler.rs
UTF-8
2,081
2.90625
3
[ "Apache-2.0" ]
permissive
use crate::scheduler::Scheduler; use crate::task::TaskBase; use std::any::Any; use std::collections::HashMap; use std::error::Error; #[derive(Debug, Clone)] pub struct FetchFailedVals { pub server_uri: String, pub shuffle_id: usize, pub map_id: usize, pub reduce_id: usize, } // Send, Sync are required...
true
410615e62d147f7e8c708a5e1101bb9b9d323b61
Rust
Wowo10/rust_piston_tetris
/src/app/state.rs
UTF-8
150
2.703125
3
[]
no_license
pub enum State{ Free, Taken, Active } impl Copy for State { } impl Clone for State{ fn clone(&self) -> State{ *self } }
true
276f459693a19733b538e85c14cbfb8db0e857e5
Rust
PhilippGackstatter/ion
/src/lexer.rs
UTF-8
12,746
3.21875
3
[]
no_license
use crate::types::Token; use crate::types::TokenKind::{self, *}; use std::collections::HashMap; use std::iter::Peekable; use std::str::CharIndices; #[derive(Default)] pub struct Lexer { pub tokens: Vec<Token>, current: usize, keywords: HashMap<String, TokenKind>, // Don't parse subsequent newlines ...
true
2648187c0ed6922fbd78e44ae7a8031894840461
Rust
isgasho/bonsaidb
/book/src/view-example-string.rs
UTF-8
1,536
2.71875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
// ANCHOR: struct #[derive(Serialize, Deserialize, Debug)] pub struct BlogPost { pub title: String, pub body: String, pub category: Option<String>, } // ANCHOR_END: struct // ANCHOR: view pub trait BlogPostsByCategory { type Collection = BlogPost; type Key = Option<String>; type Value = u32; ...
true
2972ae4fc9ef5debe2097964fbcf5a3809b93933
Rust
sean-h/raytracer
/src/hitable/triangle.rs
UTF-8
2,471
3
3
[]
no_license
use tdmath::{Vector3, Ray}; use hitable::{Hitable, HitRecord}; use material::Material; use aabb::AABB; pub struct Triangle { v0: Vector3, v1: Vector3, v2: Vector3, bounding_box: AABB, material: Box<Material>, } impl Triangle { pub fn new(v0: Vector3, v1: Vector3, v2: Vector3, material: Box<Mat...
true
a5892280c476427151b16ea1f20e746776a0cc0c
Rust
jwbuurlage/advent-of-code-2018
/src/bin/day11.rs
UTF-8
1,238
2.890625
3
[ "MIT" ]
permissive
use std::io::{self, Read}; use std::str::FromStr; fn main() { let serial = 9306; let mut grid = vec![vec![0; 302]; 302]; for x in 1..301 { for y in 1..301 { let mut power_level : i32 = ((x + 10) * y + serial) * (x + 10); power_level = ((power_level / 100) % 10) - 5; ...
true
e97e24b46956fbb7ce1193b5b81222ac3284f616
Rust
saik0/rust-aoc-2020
/day04/src/lib.rs
UTF-8
5,481
3.078125
3
[]
no_license
#![cfg_attr(feature = "unstable", feature(test))] const INPUT: &'static str = include_str!("../input"); // ===== fn parse(input: &str) -> Vec<[Option<&str>; 7]> { input.split("\n\n") .map(|line| { line.split(&[' ', '\n'][..]) .filter_map(|entry| { let mut s...
true
5f2ad893e66b99ddac5228428dddf9cb2f61422c
Rust
brianduff/learnrust
/hashmaps/src/main.rs
UTF-8
2,411
4
4
[]
no_license
use std::collections::HashMap; fn main() { test_creating_hashmaps(); test_accessing_hashmap(); test_iterating_hashmap(); test_updating_hashmap(); } fn test_creating_hashmaps() { let mut scores = HashMap::new(); scores.insert(String::from("Blue"), 10); scores.insert(String::from("Yellow"),...
true
241d9dc4a3928ff388507697f71db273fb81e182
Rust
yuri91/ynwm
/src/main.rs
UTF-8
4,329
2.890625
3
[]
no_license
use generational_arena::Index; use ynwm::*; struct ViewData { view: Index, rect: Rect, mapped: bool, } enum CursorMode { Move, Resize, Passthrough, } fn view_at<'a>(server: &'a Server, views: &[ViewData], x: i32, y: i32) -> Option<(Index, SurfaceHit<'a>)> { views.iter().rev().find_map(|v| {...
true
1e9ecdaf34bb58638ceddb7fa7daf3e7fbda6976
Rust
chinatsu/aoc
/src/aoc01/aoc01_test.rs
UTF-8
692
2.609375
3
[]
no_license
use super::*; #[test] fn mass_of_12_should_be_2() { assert_eq!(2, fuel_for(12)) } #[test] fn mass_of_14_should_be_2() { assert_eq!(2, fuel_for(14)) } #[test] fn mass_of_1969_should_be_654() { assert_eq!(654, fuel_for(1969)) } #[test] fn mass_of_100756_should_need_33583() { assert_...
true
5cb23aaef059d09e60cf95b7422f9a390bc3d7f0
Rust
tejasag/ctp
/src/shape.rs
UTF-8
2,532
3.078125
3
[]
no_license
use anyhow::Result; use thiserror::Error; #[derive(Error, Debug)] pub enum TomlError { #[error("\"{0}\" section could not be found in your config. Add it with [{0}]")] SectionNotFound(String), #[error("The language \"{0}\" could not be found in your config.")] LanguageNotFound(String), #[error("T...
true
745ab56bea45cf2e9f8c03299d5fc9728275b2ba
Rust
fanatid/zebra
/zebra-state/src/service/check.rs
UTF-8
7,679
2.609375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Consensus critical contextual checks use std::borrow::Borrow; use chrono::Duration; use zebra_chain::{ block::{self, Block}, parameters::POW_AVERAGING_WINDOW, parameters::{Network, NetworkUpgrade}, work::difficulty::CompactDifficulty, }; use crate::{PreparedBlock, ValidateContextError}; use supe...
true
ba38217f64da63f1546553d32879a5c860928e80
Rust
fanfeilong/rust-learn
/src/CommonProgrammingConcepts/variables/src/main.rs
UTF-8
712
3.640625
4
[]
no_license
fn main() { // // immutable vs mutable // // let x = 5; let mut x = 5; println!("The value of x is:{}", x); x = 6; println!("The value of x is:{}", x); // // constants // const MAX_POINTS: u32 = 100_000; println!("The value of MAX_POINTS is {}", MAX_POI...
true
746c427c0ff7a6dc8c0c2b28c09073226881eab3
Rust
phiresky/tantivy
/src/query/automaton_weight.rs
UTF-8
5,584
2.875
3
[ "MIT" ]
permissive
use crate::common::BitSet; use crate::core::SegmentReader; use crate::query::ConstScorer; use crate::query::{BitSetDocSet, Explanation}; use crate::query::{Scorer, Weight}; use crate::schema::{Field, IndexRecordOption}; use crate::termdict::{TermDictionary, TermStreamer}; use crate::TantivyError; use crate::{DocId, Sco...
true
253ad9f97332bd6c2fd1c57cbc6e1a654d063681
Rust
erdos-project/erdos
/erdos/src/dataflow/stream/loop_stream.rs
UTF-8
1,561
2.796875
3
[ "Apache-2.0" ]
permissive
use std::marker::PhantomData; use serde::Deserialize; use crate::dataflow::{graph::default_graph, Data}; use super::{OperatorStream, Stream, StreamId}; /// Enables loops in the dataflow. /// /// # Example /// ``` /// # use erdos::dataflow::{stream::LoopStream, operator::{OperatorConfig}, operators::{FlatMapOperator...
true
ba6e7206346f40c865c0ceb89b28ddf0e5d9336b
Rust
polyhorn/polyhorn
/crates/polyhorn-core/src/reference.rs
UTF-8
2,389
2.890625
3
[ "MIT" ]
permissive
use std::cell::{Ref, RefMut}; use std::marker::PhantomData; use super::{Link, Weak, WeakReference}; pub struct Reference<T> { instance_id: usize, reference_id: usize, marker: PhantomData<T>, } impl<T> Reference<T> where T: 'static, { pub(crate) fn new(instance_id: usize, reference_id: usize) -> R...
true
16699fd196c9865dba0a899c58ad4f6edd05d6ec
Rust
andy-hanson/rs
/crates/parse/src/lexer.rs
UTF-8
15,156
2.78125
3
[]
no_license
use std::mem::replace; use std::str::from_utf8; use util::arena::Arena; use util::loc::{Loc, Pos}; use util::sym::Sym; use ast::{Expr, ExprData}; use parse_diag::ParseDiag; use super::reader::Reader; use super::token::Token; pub struct ParseDiagnostic(pub Loc, pub ParseDiag); pub type Result<T> = ::std::result::Re...
true
7fd7de57612054417c4583e9d12c4d394a9d306e
Rust
Happy-Ferret/rust-sixel
/examples/draw.rs
UTF-8
3,418
2.59375
3
[]
no_license
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE // Version 2, December 2004 // // Copyleft (ↄ) meh. <meh@schizofreni.co> | http://meh.schizofreni.co // // Everyone is permitted to copy and distribute verbatim or modified // copies of this license document, and changing it is allowed as long...
true
53dd19508279b8f2cc70b53a3ec0d0c349792652
Rust
zhaofengli/attic
/attic/src/nix_store/nix_store.rs
UTF-8
8,150
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! High-level Nix Store interface. use std::ffi::OsStr; use std::os::unix::ffi::OsStrExt; use std::path::{Path, PathBuf}; use std::sync::Arc; use tokio::task::spawn_blocking; use super::bindings::{open_nix_store, AsyncWriteAdapter, FfiNixStore}; use super::{to_base_name, StorePath, ValidPathInfo}; use crate::hash::...
true
a908beb6f2da856e03b6be3a8d78dc400e186d9f
Rust
jacobjonsson/advent-of-code-2020
/src/day_6/day_6.rs
UTF-8
2,294
3.328125
3
[]
no_license
use std::collections::HashMap; #[path = "../input_loader/input_loader.rs"] mod input_loader; pub fn day6() { let input = input_loader::read_input("src/day_6/input.txt"); let part_1_result = part_1(&input); println!("[DAY 6] Result for part 1: {}", part_1_result); let part_2_result = part_2(&input); ...
true
c16e88e67c2d44a935d2a42d4518530a4ce80ecc
Rust
jblindsay/whitebox-tools
/whitebox-tools-app/src/tools/terrain_analysis/multiscale_std_dev_normals.rs
UTF-8
45,377
2.546875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* This tool is part of the WhiteboxTools geospatial analysis library. Authors: Dr. John Lindsay Created: 05/06/2019 Last Modified: 03/09/2020 License: MIT */ use whitebox_raster::*; use whitebox_common::rendering::html::*; use whitebox_common::rendering::LineGraph; use whitebox_common::structures::Array2D; use crate:...
true
c37fcf76c2c7d8c2fb5d61acdc34bc0037588db9
Rust
kfb/advent2019
/advent03/src/point.rs
UTF-8
832
3.953125
4
[]
no_license
#[derive(Debug, PartialEq)] pub struct Point { pub x: f32, pub y: f32 } impl Point { pub fn add(&self, other: &Point) -> Point { Point {x: self.x + other.x, y: self.y + other.y} } pub fn cross(&self, other: &Point) -> f32 { (self.x * other.y) - (self.y * other.x) } pub fn ...
true
031ea13f4a0ce011e3c96dda93ac3cba3e53a19e
Rust
LanJian/raytox
/src/geometry/cube.rs
UTF-8
6,986
2.734375
3
[]
no_license
use crate::algebra::{Point2, Point3, Ray, Vector3}; use super::{Intersect, Intersection, Textured}; #[derive(Debug, Copy, Clone, PartialEq)] pub struct Cube { min_bounds: Point3, max_bounds: Point3, flipped_normals: bool, } impl Cube { pub fn new(min_bounds: Point3, max_bounds: Point3) -> Self { ...
true
b5387e962d7273f8c44f3dcd1fa6798bb23ba0cd
Rust
ggriffiniii/radix64
/examples/io.rs
UTF-8
1,349
3.015625
3
[ "Apache-2.0", "MIT" ]
permissive
/// Very simple example that can either encode or decode stdin and print to stdout. /// $ echo foo | cargo run --example io /// Zm9vCg== /// /// $ echo foo | cargo run --example io | cargo run --example io -- -d /// foo /// use radix64::{ io::{DecodeReader, EncodeWriter}, STD as MY_CONFIG, }; use std::{env, err...
true
4e0a54765474c07ed184ff0ab4c5e434f31ac752
Rust
Dennyching/Rust
/control/src/main.rs
UTF-8
1,551
4.28125
4
[]
no_license
fn main() { let number = 3; if number !=0 /*can't only variable*/{ println!("condition was true"); } let number = 6; if number % 4 == 0 { println!("number is divisible by 4"); } else if number % 3 == 0 { println!("number is divisible by 3"); } else if number % 2 ==...
true
d550c67cc84ab6d8396ff01298e149ae2c9e5b79
Rust
JackAllTrades-MoN/x86emu
/src/emulator/i386/core.rs
UTF-8
3,942
3
3
[]
no_license
use crate::binary; pub enum GRNames { EAX, EBX, ECX, EDX, ESI, EDI, ESP, EBP } pub struct Register { pub general: [u32; 8], pub eflags: u32, pub eip: u32, } pub struct State { pub register: Register, pub memory: Vec<u8>, } impl GRNames { pub fn to_idx(&self) -> usize { match self { ...
true
1d0b835727aea3c320b710b1af83ad22f2a450aa
Rust
KyleCohick/t0r
/src/main.rs
UTF-8
25,362
3.03125
3
[]
no_license
//important namespaces use std::time::{Duration, SystemTime}; use std::thread::sleep; //hacks to beat the game quicker and test things fn hax(money: &mut i128) { *money += 1000000; } fn arma(humans: &mut i128) { *humans -= 7346250000; } fn kill100(kills: &mut i128) { *kills += 100; } //BASE FUNCTION...
true
3f290a27c044b6f52fa72d0b79c508a0d4389083
Rust
andot/hprose-rust
/hprose/src/io/decoders/char_decoder.rs
UTF-8
2,121
2.8125
3
[ "MIT" ]
permissive
/**********************************************************\ | | | hprose | | | | Official WebSite: http://www.hprose.com/ | | ...
true
19e021634ae703965a7aeecc444809e5e8d98ba0
Rust
dignifiedquire/image-meta
/src/errors.rs
UTF-8
736
2.53125
3
[]
no_license
use std::borrow::Cow; use failure::Fail; pub type ImageResult<T> = Result<T, ImageError>; pub type ImageResultU = Result<(), ImageError>; #[derive(Fail, Debug)] pub enum ImageError { #[fail(display = "Corrupt image: {}", 0)] CorruptImage(Cow<'static, str>), #[fail(display = "Invalid signature")] ...
true
5641f8d768d7d6fcde60ada0cd114280d88886d1
Rust
guyoung/CaptfEncoder
/CaptfEncoder-V3/main/src/apps/extensions/query/ext_ip_info.rs
UTF-8
2,195
2.515625
3
[]
no_license
use std::collections::HashMap; use fltk::group::*; use anyhow::anyhow; use pollster; use crate::apps::widgets::WgtExecutor; use super::super::ExtensionOption; use super::super::query_; use super::super::IExtensionResult; #[derive(Clone, Debug)] pub struct Component {} impl super::super::IExten...
true