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
ecdd9ad45ca29204678f6e3cb881ff46458ec051
Rust
qdrant/qdrant
/lib/segment/src/payload_storage/payload_storage_base.rs
UTF-8
1,747
2.609375
3
[ "Apache-2.0" ]
permissive
use serde_json::Value; use crate::common::Flusher; use crate::entry::entry_point::OperationResult; use crate::types::{Filter, Payload, PayloadKeyTypeRef, PointOffsetType}; /// Trait for payload data storage. Should allow filter checks pub trait PayloadStorage { /// Assign same payload to each given point fn a...
true
5d8bac9301b7c23a07e6fd6ac13890f301c841ce
Rust
Axect/Rust
/Tutorial/Essential/Chap2/transform.rs
UTF-8
318
2.84375
3
[]
no_license
fn main() { let points = -10i32; let mut saved_points: u32 = 0; println!("save point: {}", saved_points); saved_points = points as u32; // Explicit Transform println!("save point: {}", saved_points); let f2 = 3.14; saved_points = f2 as u32; println!("save point: {}", saved_points); }
true
2e3305c734a6f45722f24a348f2670aa07fb13f2
Rust
twe4ked/mandelbrot-set
/src/buffer.rs
UTF-8
933
4.09375
4
[]
no_license
pub struct Buffer { buffer: Vec<u8>, width: usize, height: usize, } impl Buffer { pub fn new(width: usize, height: usize) -> Self { Self { // * 4 because each color is represented by an RGBA sequence. buffer: vec![0; width * height * 4], width, he...
true
745e6e632c58b9368b62ca86d01282959b807451
Rust
N1ark/oxideboy
/oxideboy/src/ppu.rs
UTF-8
33,489
2.578125
3
[]
no_license
//! The PPU is responsible for rasterizing a pretty 160x144 picture to the Gameboy LCD screen 59.7 times a second. It's //! easily the most complicated part of the Gameboy system. //! Right now, this implementation is *not* cycle accurate during "Mode 3" (pixel transfer). As a result, advanced //! graphics tricks will ...
true
71df4dba26c9d658695191832f712e648f9dbf6c
Rust
Blinningjr/rubigo-lang
/tests/test_lexer/mod.rs
UTF-8
641
2.75
3
[]
no_license
#![allow(dead_code)] #[path = "../../src/span.rs"] mod span; #[path = "../../src/lexer/mod.rs"] pub mod lexer; mod identifiers; mod numbers; mod reserved; mod symbol; mod symbols; use lexer::{ Token, Lexer, }; /** * converts the whole string into a vec of tokens. */ pub fn tokenize_string(input: String...
true
20587f0b0778d23df26b1289c4d43cbda9a5e7ed
Rust
zrma/1d1rust
/src/boj/p2k/p2204.rs
UTF-8
1,141
3.1875
3
[]
no_license
use crate::utils::io::read_line; use std::io::{BufRead, Write}; #[allow(dead_code)] fn solve2204(reader: &mut impl BufRead, writer: &mut impl Write) { loop { let n = read_line(reader).parse::<usize>().unwrap(); if n == 0 { break; } let mut words = vec![]; for _ ...
true
cda8fd7c0b7f64851bfc7f25efb61dba39d60dd4
Rust
rust-lang/rust
/tests/ui/consts/recursive.rs
UTF-8
189
2.578125
3
[ "Apache-2.0", "LLVM-exception", "NCSA", "BSD-2-Clause", "LicenseRef-scancode-unicode", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
#![allow(unused)] const fn f<T>(x: T) { //~ WARN function cannot return without recursing f(x); //~^ ERROR evaluation of constant value failed } const X: () = f(1); fn main() {}
true
8ee9a20ae15e90a31ad1085e9a3b0f2e701050e0
Rust
tryyrt/salvo
/core/src/fs/mod.rs
UTF-8
3,649
3
3
[ "MIT" ]
permissive
mod named_file; pub use named_file::*; use bytes::BytesMut; use futures::Stream; use std::pin::Pin; use std::task::{Context, Poll}; use std::{cmp, io}; use tokio::io::{AsyncRead, AsyncSeek}; pub struct FileChunk<T> { chunk_size: u64, read_size: u64, buffer_size: u64, offset: u64, file: T, } impl<...
true
13d8f4521974c82020fe06d6a780b4d5c3d86b5f
Rust
carl-erwin/unlimited
/src/core/modes/text_mode/word_wrap.rs
UTF-8
13,982
2.53125
3
[ "MIT" ]
permissive
/* TODO(ceg): filters dependencies: check in view's filter_array that dep.index < cur_filter.index or (and WARN) we can push multiple times new instance of a filter :-) prerequisite: - tab/words/"invisible chars" expansion before: ('\t' -> ' ' should be done before) ...
true
02cd6e4bb1cd2eb4255248095dc64f7000b7202b
Rust
erde74/som-rs
/som-parser-core/src/lib.rs
UTF-8
4,308
3.59375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::marker::PhantomData; /// Generic parser combinators. pub mod combinators; /// Defines a parser. /// /// It is basically a function that takes an input and returns a parsed result along with the rest of input (which can be parsed further). pub trait Parser<T, I>: Sized { /// Applies the parser on some inp...
true
e5bba4208d8687891965ac93ae3578a932f7ec57
Rust
The1Penguin/RofiBooks
/src/main.rs
UTF-8
1,743
3.203125
3
[ "MIT" ]
permissive
extern crate rofi; extern crate regex; extern crate clap; use regex::Regex; use std::path::Path; use std::process::Command; extern crate glob; use glob::glob; use clap::{App}; fn main() { let args = App::new("rofi_book") .version("0.1.0") .about("shows all the files in folder and opens using xdg-open") .author(...
true
6ecce56cefdd5fde50d4ecfec503393237da04bf
Rust
ajsutton/beacon-fuzz
/eth2fuzz/src/utils.rs
UTF-8
1,072
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/// Produces a string from a given list of possible values which is similar to /// the passed in value `v` with a certain confidence. /// Thus in a list of possible values like ["foo", "bar"], the value "fop" will yield /// `Some("foo")`, whereas "blark" would yield `None`. /// /// Originally from [clap] which is Copyr...
true
75311546413fc1a14765555aacd3a75debbc6ce1
Rust
Mariii-23/caracol_tobias
/src/commands/examples.rs
UTF-8
2,828
3.015625
3
[]
no_license
extern crate serenity; // use std::path::Path; use crate::modules::pagination; use serenity::{ builder::CreateMessage, // http::AttachmentType, framework::standard::{ macros::{command, group}, CommandResult, }, model::channel::Message, prelude::*, }; use serenity_utils::menu::...
true
513f2eb55e45f403273dc56acfe76a2af3341e69
Rust
kcexn/L_KaranProjects_Rust_TextEditor
/utils/src/lib.rs
UTF-8
2,623
3.125
3
[]
no_license
extern crate utils_structs; use std::io; use std::process; use std::error::Error; use std::io::prelude::*; use std::fs::File; use std::path::Path; use utils_structs::TextData; pub fn read_from_stdin(mut input: &mut String) { match io::stdin().read_line(&mut input) { Ok(_n) => (), Err(error) => { ...
true
9af1e22280bb1476d83da5d574d55e30f855c9a9
Rust
ThomasZumsteg/project-euler
/problem_0046.rs
UTF-8
1,091
2.796875
3
[]
no_license
#[macro_use] extern crate clap; use common::{set_log_level, integer_square_root}; use common::primes::Primes; use log::{info, debug}; fn main() { let args = clap_app!(app => (about: "Solve Project Euler Problem 46, https://projecteuler.net/problem=46") (@arg verbose: -v +multiple "Increase log lev...
true
7f4ff93448ac96fb6b01f159e6a01517edcdfd74
Rust
nakakura/study
/frp/carboxyl/sec4/src/outputs.rs
UTF-8
5,534
2.546875
3
[]
no_license
use carboxyl::*; pub struct Delivery; pub struct Sale; pub struct Outputs { delivery: Signal<Delivery>, preset_lcd: Signal<f64>, sale_cost_lcd: Signal<f64>, sale_quantity_lcd: Signal<f64>, price_lcd1: Signal<f64>, price_lcd2: Signal<f64>, price_lcd3: Signal<f64>, beep: Str...
true
da1c072a57b7fddf41b091afacc3f680c98dbec4
Rust
blackaichi/rustchain
/src/blockchain.rs
UTF-8
746
3.046875
3
[]
no_license
use super::block::{Block, create_block}; pub fn create_blockchain() -> Blockchain { Blockchain { n_difficulty : 3, chain : Vec::new(), } } pub struct Blockchain { n_difficulty: u32, chain: Vec<Block>, } impl Blockchain { pub fn add_first_block(&mut self) { self.chain.push(...
true
6f096c42914e9df157bbcab0f25a6f3e24f577d8
Rust
yuriykulikov/ferrous-systems-rust-training
/tcp-server/src/main.rs
UTF-8
3,510
2.953125
3
[]
no_license
use std::collections::VecDeque; use std::io; use std::sync::Arc; use std::time::Duration; use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader}; use tokio::net::{TcpListener, TcpStream}; use tokio::sync::Mutex; use tokio::task::JoinHandle; use tokio::time; use redisish::{Command, parse}; struct VecDequeMailbox ...
true
9b7a4b8701d006d77bb1a38397f9726c06882b6e
Rust
RobJenks/advent-of-code
/2020/rust/src/day10/mod.rs
UTF-8
3,996
3.046875
3
[]
no_license
use super::common; use itertools::Itertools; pub fn run() { println!("Part 1 result: {}", part1()); println!("Part 2 result: {}", part2()); } fn part1() -> u32 { let deltas = calculate_full_chain_deltas( parse_input(common::read_file("src/day10/problem-input.txt"))); deltas[0] * d...
true
9655c5ff09facf1169b2fc81f035e215b3830a1d
Rust
imDema/advent_of_code_2020
/d16/src/main.rs
UTF-8
1,661
3.046875
3
[]
no_license
use std::io::{stdin, Read}; use lazy_static::lazy_static; use regex::Regex; lazy_static!( static ref RE_RULE : Regex = Regex::new(r": (\d+)-(\d+) or (\d+)-(\d+)").unwrap(); ); struct Rule { a: (u16,u16), b: (u16,u16), } impl Rule { pub fn new(s: &str) -> Result<Self, &'static str> { let caps...
true
6b384d62bbc80bf99dcb414692299b2e1094e60b
Rust
dmvict/wTools
/rust/test/dt/type_constructor/enumerable_test.rs
UTF-8
5,776
2.890625
3
[ "MIT" ]
permissive
#[ allow( unused_imports ) ] use super::*; // macro_rules! PairDefine { () => { struct Pair1( i32, i32 ); impl TheModule::Enumerable for Pair1 { type Element = i32; fn len( &self ) -> usize { 2 } fn element_ref( &self, index : usize ) -> &Self::Element {...
true
ec6b02af17687978edf84ec69169d1e58532c063
Rust
Beidah/roguelikedev-tutorial-2019
/src/map/tile.rs
UTF-8
80
2.671875
3
[ "MIT" ]
permissive
#[derive(Copy, Clone,PartialEq, Debug)] pub enum Tile { Ground, Wall, }
true
65b683438cfb189c97550b5dd3ff164d44a30420
Rust
pczarn/cfg
/src/sequence/destination.rs
UTF-8
399
3.15625
3
[ "Apache-2.0", "MIT" ]
permissive
//! Sequence destination. use sequence::Sequence; /// Trait for storing sequence rules in containers, with potential rewrites. pub trait SequenceDestination<H> { /// Inserts a sequence rule. fn add_sequence(&mut self, seq: Sequence<H>); } impl<'a, H> SequenceDestination<H> for &'a mut Vec<Sequence<H>> { ...
true
768ded122f02869053a736fbdf98eb6fdea8ec8a
Rust
ear7h/mvm
/src/dense_enum.rs
UTF-8
832
2.59375
3
[]
no_license
macro_rules! dense_enum { ($name:ident; $($var:ident) , * , ) => { #[allow(dead_code)] #[derive(Debug)] pub enum $name { $($var) , * } impl $name { pub fn from_int(i:u8) -> $name { return unsafe { std::mem::transmute::<u8, ...
true
fb4cbd639c344997dbb2f5269c136e01e9a6eddf
Rust
liebharc/basic_dsp
/examples/custom_window.rs
UTF-8
873
3.046875
3
[ "Apache-2.0", "MIT" ]
permissive
extern crate basic_dsp; use basic_dsp::conv_types::*; use basic_dsp::*; struct Identity; impl RealImpulseResponse<f64> for Identity { fn is_symmetric(&self) -> bool { true } fn calc(&self, x: f64) -> f64 { if x == 0.0 { 1.0 } else { 0.0 } } } /...
true
761c7d7e89dc9173b1a09ef73eff5c3a79751b81
Rust
delphix/ptools
/vendor/libc/src/macros.rs
UTF-8
2,332
2.640625
3
[ "Apache-2.0", "MIT" ]
permissive
/// A macro for defining #[cfg] if-else statements. /// /// This is similar to the `if/elif` C preprocessor macro by allowing definition /// of a cascade of `#[cfg]` cases, emitting the implementation which matches /// first. /// /// This allows you to conveniently provide a long list #[cfg]'d blocks of code /// withou...
true
84065394b4290615469c4cfd517bcad2cbe36706
Rust
icbiadb/icbiadb
/src/fio/mod.rs
UTF-8
2,697
2.546875
3
[ "MIT" ]
permissive
pub mod reader; pub mod writer; use std::{ io::{BufWriter, Seek, SeekFrom, Write}, sync::RwLock, }; //use reader::Reader; use writer::Writer; use crate::database::{table::TableDb, KvDb}; use crate::storage::KvInterface; use crate::types::{BvObject, BvString}; pub const FILE_STAMP: &[u8] = b"KVIDB"; pub st...
true
8f2dfb95f400e15816b5debd2eb670fcda6999ae
Rust
sunrise-choir/encode_unicode
/tests/read_iterators.rs
UTF-8
4,053
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/* Copyright 2018 Torbjรธrn Birch Moltu * * Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or * http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or * http://opensource.org/licenses/MIT>, at your option. This file may not be * copied, modified, or distributed except according ...
true
3f5b22cec7619ba6f4ee412097215f6ee19a5bf2
Rust
starblue/advent_of_code
/a2020/src/bin/a202010.rs
UTF-8
1,362
3.234375
3
[]
no_license
use std::io; fn main() { let mut line = String::new(); let mut ns = Vec::new(); loop { line.clear(); io::stdin().read_line(&mut line).expect("I/O error"); let v: usize = match line.trim().parse() { Result::Ok(mass) => mass, Result::Err(_) => break, ...
true
194ac02f0445f06b29760280e66239ede94c61f7
Rust
jakyle/rust-algos
/src/check_inclusion.rs
UTF-8
1,136
3.546875
4
[ "MIT" ]
permissive
pub fn check_inclusion(window: String, subject: String) -> bool { let get_idx = |c: u8| (c - b'a') as usize; let mut window_alphabet_counter = [0u8; 26]; window .bytes() .for_each(|b| window_alphabet_counter[get_idx(b)] += 1); let (window_len, subject_letters) = (window.len(), subject....
true
c350b03e764f4f9d45f5b21fa9ad49a581a6d972
Rust
Somainer/stca-weekly-challenge
/week34/34-find-first-and-last-position-of-element-in-sorted-array/searchRange.rs
UTF-8
835
2.9375
3
[]
no_license
impl Solution { pub fn search_range(nums: Vec<i32>, target: i32) -> Vec<i32> { fn search_bounds<T>(xs: &Vec<T>, target: &T, cmp: fn(&T, &T) -> bool) -> usize { let (mut left, mut right) = (0, xs.len()); while left < right { let mid = (left + right) >> 1; ...
true
09450933b377ec215318f6bca18fa037f073a7d3
Rust
AreebSiddiqui/RUST-
/rust_coding/src/main.rs
UTF-8
2,315
3.46875
3
[]
no_license
//**THIS CODE IS ONLY MY PRACTICE REVIEW OTHER CODES FOR BETTER UNDERSTANDING THE CONCEPT OF RUST** // // fn largest<T: PartialOrd + Copy>(x: &[T]) -> T { // // let mut largest = x[0]; // // for &numbers in x.iter() { // // if numbers > largest { // // largest = numbers; // // } // // } // // large...
true
d9bbd2d2045e12fac4c68ececb0b411a1f06ae63
Rust
caspermeijn/advent-of-code-2020
/src/day13/mod.rs
UTF-8
3,762
3.0625
3
[]
no_license
/* Copyright (C) 2020 Casper Meijn <casper@meijn.net> * SPDX-License-Identifier: GPL-3.0-or-later * * 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 Software Foundation, either version 3 of the License, or * (a...
true
a6f4837621d5c7794734252a61247336fb9302d8
Rust
yamakii/ticket-price-in-rust-ddd
/infra/src/db/repository/order.rs
UTF-8
3,362
2.671875
3
[ "MIT" ]
permissive
use crate::db::model::{OrderDTO, OrderDetailDTO}; use crate::db::repository::order::dto::{NewOrder, NewOrderDetail}; use crate::db::schema::order_details::dsl::{order_details, order_id}; use crate::db::schema::orders::dsl::orders; use crate::domain::model::order::{Order, OrderDetail, OrderId}; use crate::domain::model:...
true
b3186eaff7a5757925ae33da0aef71e3cd15eee7
Rust
leudz/shipyard_app
/src/tracked_unique.rs
UTF-8
4,544
3.015625
3
[]
no_license
//! A small change tracker to wrap around a unique so you can determine if the value changes between updates. use tracing::trace_span; use crate::prelude::*; use core::any::type_name; use std::{fmt, ops::Deref, ops::DerefMut}; pub struct TrackedValue<T>(InnerTrackedState, T); pub struct Tracked<'a, T>(UniqueView<'a...
true
d3cb331501d9dabb9348d16f7544f4de1c7c822d
Rust
gaku-sei/rust-gmail
/src/main.rs
UTF-8
2,580
2.90625
3
[]
no_license
extern crate openssl; use std::os; use std::io::{IoResult, TcpStream}; use openssl::ssl::{SslContext, Sslv23, SslStream}; pub enum Status { Auth, NonAuth, Logout } pub struct GmailSocket { _stream: SslStream<TcpStream>, _length: int, _status: Status } impl GmailSocket { pub fn connect() ...
true
6c6b745f4b07c405f38e78515b495d4f647889d7
Rust
jsMRSoL/greek-vocab-test-maker
/src/main.rs
UTF-8
6,117
3.296875
3
[]
no_license
use std::process; use std::path::PathBuf; use std::error::Error; use std::fs; use csv::Reader; use greek_vocab_test_maker::{ Question, Record, AnswerOption, }; // import from file // add manually // duplicate entry // delete entry // edit entry // print to xml fn main() { if let Err(e) = run() { ...
true
6a45e345cfe362fde42605186e8cda6865099516
Rust
SCappella/exercism
/rust/grade-school/src/lib.rs
UTF-8
917
3.546875
4
[ "MIT" ]
permissive
use std::collections::BTreeMap; #[derive(Default)] pub struct School { students: BTreeMap<u32, Vec<String>>, } impl School { pub fn new() -> Self { Self::default() } pub fn add(&mut self, grade: u32, student: &str) { self.students .entry(grade) .or_insert_with(...
true
61a6751efa8db03405520a369d117b0868062d3c
Rust
foxfriends/dwarf-mine-builder
/src/model/floor_map.rs
UTF-8
1,311
2.953125
3
[]
no_license
use game_engine::prelude::*; use std::fmt::{self, Formatter, Debug}; use crate::constant::{TILE_SIZE, CUBE_SIZE}; /// A height map of the floor of a cube. #[derive(Copy, Clone)] pub struct FloorMap([u8; (TILE_SIZE * TILE_SIZE) as usize]); impl FloorMap { pub const SOLID: FloorMap = FloorMap([CUBE_SIZE.depth as u8...
true
f7b7c264d67843b18c069804acbebd19d005296a
Rust
zmilan/examples-1
/template_askama/src/main.rs
UTF-8
922
2.765625
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use actix_web::{web, App, HttpResponse, HttpServer, Result}; use askama::Template; #[derive(Template)] #[template(path = "user.html")] struct UserTemplate<'a> { name: &'a str, text: &'a str, } #[derive(Template)] #[template(path = "index.html")] struct Index; async fn index(qu...
true
d7f166fbbee8cb66d27d4aef7cbb9f56efbcf8d8
Rust
cda-group/arcon
/arcon/src/stream/node/common.rs
UTF-8
1,201
2.53125
3
[ "Apache-2.0" ]
permissive
use crate::data::{ArconEvent, ArconType}; use crate::error::{ArconResult, Error}; use crate::reportable_error; use crate::stream::channel::strategy::{send, ChannelStrategy}; use kompact::prelude::{ComponentDefinition, SerError}; // Common helper function for adding events to a ChannelStrategy and possibly // dispatchi...
true
d588bffa6b6a0f7269416e2fab30c0ee0c9cd770
Rust
MukundhBhushan/rust-tots
/collections/hashmaps.rs
UTF-8
669
3.546875
4
[]
no_license
use std::collections::HashMap fn main(){ let mut marks = HashMap::new(); //add values marks.insert("rust marks",96); marks.insert("JS marks",94); marks.insert("Py marks",92); marks.insert("C# marks",99); //find length let markslen = marks.len(); //get values with keys match m...
true
4420568eb67162226dc6de6977e4150b098b7b91
Rust
Liby99/geometry-sketchpad
/core/lib/src/utilities/screen_space.rs
UTF-8
5,421
3.03125
3
[]
no_license
use crate::math::*; use std::ops::{Add, Div, Mul, Neg, Sub}; #[derive(Debug, Clone, Copy, PartialOrd, PartialEq)] pub struct ScreenScalar(pub f64); impl Into<f64> for ScreenScalar { fn into(self) -> f64 { self.0 } } impl From<f64> for ScreenScalar { fn from(f: f64) -> Self { Self(f) } } impl Div<Scr...
true
2ef81cf01e4d64e98480ceb4586809ae1ff91a28
Rust
zanesterling/shedspreet
/src/engine/parsing.rs
UTF-8
5,919
3.46875
3
[]
no_license
// ``` // Parsing::new(input).try_one([ // |p| Err(Error("oh no, an error!")), // |p| { // let p1 = p.parse_literal()?; // let p2 = p1.skip("+")?.parse_literal()?; // Ok(p2.replace(Expr::Plus(Box::new(p1.val), Box::new(e2.val)))) // }, // ])?; // ``` use std::num; // TODO: Reduce n...
true
bce55a52f7767afb2cc2e57b4e43a2bcdb5f63be
Rust
kpcyrd/rustsec
/rustsec/src/database/entries.rs
UTF-8
4,978
3.375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Entries in the advisory database use super::Iter; use crate::{ advisory::{self, Advisory}, collection::Collection, error::{Error, ErrorKind}, map, Map, }; use std::{ ffi::{OsStr, OsString}, path::Path, }; /// "Slots" identify the location in the entries table where a particular /// advisor...
true
efda9f6073de1e5b39c775b1d431fc6a77800947
Rust
zydiig/secrets
/src/bin/encpipe.rs
UTF-8
5,712
2.578125
3
[]
no_license
extern crate secrets; use std::env; use std::fs::File; use std::io; use std::io::prelude::*; use std::io::BufReader; use std::mem::size_of; use byteorder::{BigEndian, ByteOrder, ReadBytesExt, WriteBytesExt}; use failure::{err_msg, Error, ResultExt}; use serde::{Deserialize, Serialize}; use secrets::{parsing, sodium,...
true
96003cdec5ea56b65c8634ed02de7a4667b72d40
Rust
ipp-collect/ipp.rs
/ipp/src/lib.rs
UTF-8
2,874
2.828125
3
[ "Apache-2.0", "MIT" ]
permissive
//! //! IPP print protocol implementation for Rust. This crate can be used in several ways: //! * using the low-level request/response API and building the requests manually. //! * using the higher-level operations API with builders. Currently only a subset of all IPP operations is supported. //! * using the built-in I...
true
4ec40f973b97629105cc0a00c08f750d393c68fd
Rust
Sauci/ccgen
/src/crkcam/cam.rs
UTF-8
2,247
3.015625
3
[]
no_license
use super::cmn::*; use core::iter::Iterator; use heapless::consts::U21; use heapless::Vec; /// CamCfg, shall be configured in the following manner: /// Level /// ^ /// 0r 1f 2r 3f 4r /// |------+ +----------------+ +------ /// | ag0 | ag1 | ag2 | ag3...
true
23151d813aaff7c5a50b548e351c3b14d8d29417
Rust
okard/rust-playground
/storage/src/storage_memory.rs
UTF-8
3,253
3.140625
3
[ "MIT" ]
permissive
//use std::collections::HashMap; //in memory storage //use a hashmap or something similiar //trie? extern crate crypto; use std::collections::HashMap; use std::io::{Cursor, Result, Error, ErrorKind}; use super::core::{ReadHandle, WriteHandle, KeyValueStorage, ContentStorage}; /// /// Memory Storage /// pub s...
true
4e975aab8da272cf284b270a057d0b48cc0afe2e
Rust
srijs/rust-cfn
/src/aws/globalaccelerator.rs
UTF-8
33,345
2.765625
3
[ "MIT" ]
permissive
//! Types for the `GlobalAccelerator` service. /// The [`AWS::GlobalAccelerator::Accelerator`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-globalaccelerator-accelerator.html) resource type. #[derive(Debug, Default)] pub struct Accelerator { properties: AcceleratorProperties } /// Pr...
true
b2cd482e4fcef7b64e3a6f7e1e39f05e0483ab37
Rust
KillingSpark/sparkpass
/src/cmd/cmd_remove.rs
UTF-8
1,332
2.953125
3
[]
no_license
use crate::util::{Options, prepare_entry_path}; use crate::transform; use std::path; use std::fs; pub fn cmd_remove(opts: &Options, prefix: &path::Path , enc_params: &transform::EncryptionParams) { if opts.args.len() != 1 { println!("Incorrect number of arguments. Want: 'path' Got: {}", opts.args.len());...
true
84b9679729a235ee310ca7f77c0da3bd807e8767
Rust
makuhari-city/dump
/src/redis_util.rs
UTF-8
4,374
2.515625
3
[]
no_license
use crate::{model::RepresentativeInfo, RedisObject}; use actix::Addr; use actix_redis::{Command, RedisActor}; use actix_web::{web, Error as AWError, HttpResponse}; use futures::future::{join, join_all}; use redis_async::{resp::RespValue as Value, resp_array}; use serde_json::json; use uuid::Uuid; // TODO this is obscu...
true
13d81c16db6815fa9754b40793ad725a88155653
Rust
lancelafontaine/coding-challenges
/advent-of-code/2019/aoc-02-2/src/main.rs
UTF-8
1,798
3.265625
3
[]
no_license
use std::io::{self, BufRead, Write}; type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; fn main() -> Result<()> { let stdin = io::stdin(); let stdout = io::stdout(); let stdin_handle = stdin.lock(); let mut stdout_handle = stdout.lock(); let intcode = stdin_handle .lines...
true
6300d3bf5111525046c0c65355435913b6aa4f54
Rust
nunogrl/hookshot
/src/signature.rs
UTF-8
3,573
3.28125
3
[ "MIT" ]
permissive
use openssl::crypto::hash::Type as OpenSSLType; use openssl::crypto::hmac::hmac; use regex::Regex; use std::fmt; use std::string::ToString; #[derive(PartialEq, Debug, Clone, Copy)] pub enum HashType { MD5, SHA1, SHA224, SHA256, SHA384, SHA512, RIPEMD160, } impl HashType { pub fn from_st...
true
b4d0a34f073a3abc834870c19a68868da856d7da
Rust
alex-dukhno/rust-tdd-katas
/old-katas-iteration-02/array_linked_queue_kata/src/day_2.rs
UTF-8
4,094
3.703125
4
[ "MIT" ]
permissive
use std::rc::Rc; use std::cell::RefCell; const SEGMENT_SIZE: usize = 16; type SegmentLink = Rc<RefCell<Segment>>; #[derive(Debug, PartialEq)] struct Segment { head: usize, tail: usize, items: [i32; SEGMENT_SIZE], next: Option<SegmentLink> } impl Segment { fn new(item: i32) -> SegmentLink { ...
true
7d7ebe901ccbdd040c8189ddc0e5452503bef66b
Rust
jkarns275/hcc
/libhcc/src/ast/ty.rs
UTF-8
10,391
2.90625
3
[]
no_license
use ast::context::Context; use ast::id::Id; use ast::AstError; use ast::PosSpan; use visitors::typecheck::*; use parser::Rule; use pest::iterators::Pair; #[derive(PartialEq, Eq)] pub enum TypeCompatibility { None, CastTo(Ty), Ok, } #[derive(PartialEq, Eq, Clone, Hash, Debug)] pub enum TyKind { I0, ...
true
8e58d445799b1bb8e0dd1050ccce204335b361dc
Rust
markshevchenko/rust-learning
/15/processing/src/main.rs
UTF-8
4,386
3.34375
3
[ "Unlicense" ]
permissive
fn main() { { // use std::io::prelude::*; // let stdin = std::io::stdin(); // println!("{}", stdin.lock().lines().count()); } { fn triangle(n: u64) -> u64 { (1..n + 1).sum() } assert_eq!(triangle(20), 210); fn factorial(n: u64) -> u64 { ...
true
932a62f87e2690b283c9f38726b407c4709b78e1
Rust
VladimirMarkelov/rterm
/src/cellbuf.rs
UTF-8
5,390
3.359375
3
[ "MIT" ]
permissive
use common::*; use std::cmp; use std::mem; const DEFAULT_FG: Attribute = COLOR_DEFAULT; const DEFAULT_BG: Attribute = COLOR_DEFAULT; /// Structure `CellRect` is a simple structure to keep information about /// arbitrary rectange. Used internally in `CellBuf` #[derive(Debug,Clone)] pub struct CellRect { pub left: ...
true
d717d1e780fb9fdba04e787652f55b281de014e7
Rust
wotsushi/competitive-programming
/abc/137/d.rs
UTF-8
1,635
2.734375
3
[ "MIT" ]
permissive
macro_rules! get { (Vec<$t:ty>) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::<Vec<_>>() } }; ($t:ty) => { ...
true
c01228e104a5a2cd1e85e06b19764354cb1266a8
Rust
shijuleon/rocker
/src/image.rs
UTF-8
2,337
2.765625
3
[]
no_license
use data_encoding::HEXLOWER; use reqwest::header; use ring::digest::{Context, Digest, SHA256}; use std::fs::File; use std::fs::OpenOptions; use std::io::{BufReader, Read, Write}; use std::path::Path; use crate::registry::Registry; pub struct Image<'a> { name: String, registry: &'a Registry, } fn sha256_digest<R:...
true
0e5c9621c7034ada682e46c179cf8efaf6f2129b
Rust
commerceblock/monotree
/src/bits.rs
UTF-8
2,014
3.453125
3
[ "Apache-2.0", "MIT" ]
permissive
//! A module for representing `BitVec` in terms of bytes slice. use crate::utils::*; use crate::*; use std::ops::Range; #[derive(Debug, Clone, PartialEq)] /// `BitVec` implementation based on bytes slice. pub struct Bits<'a> { pub path: &'a [u8], pub range: Range<BitsLen>, } impl<'a> Bits<'a> { pub fn new...
true
71b0e726934056d3612c743f53e58a97ac45692c
Rust
mackilanu/mcgrep
/src/lib.rs
UTF-8
2,112
3.828125
4
[]
no_license
//! # mcgrep //! `mcgrep` is a clone of the popular `grep` program found in unix-like environments. use std::error::Error; use std::fs; use std::env; pub struct Config { pub query: String, pub filename: String, pub case_sensitive: bool, } impl Config { pub fn new(mut args: env::Args) -> Result<Config, ...
true
0e07130929e4bc87fb65e6839b6f29e12df3b3a5
Rust
okaneco/palette
/palette/src/lib.rs
UTF-8
22,416
3.84375
4
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A library that makes linear color calculations and conversion easy and //! accessible for anyone. It uses the type system to enforce correctness and //! to avoid mistakes, such as mixing incompatible color types. //! //! # It's Never "Just RGB" //! //! Colors in, for example, images, are often "gamma corrected", or...
true
ed0749554d2753a5858ceb19a21a29297ea4032c
Rust
EEP-Benny/AdventOfCode
/src/year2022/day15.rs
UTF-8
7,183
3.0625
3
[]
no_license
use crate::utils::get_input; use lazy_static::lazy_static; use regex::Regex; use std::{ collections::HashSet, hash::Hash, ops::{Add, RangeInclusive}, }; #[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)] struct Position { x: i32, y: i32, } impl Position { fn new(x: i32, y: i32) -> Self { ...
true
aa7274a589f6bef5feef39dde386987bb5965875
Rust
hecrj/window_clipboard
/examples/big_file.rs
UTF-8
1,655
2.96875
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use rand::distributions::{Alphanumeric, Distribution}; use window_clipboard::Clipboard; use winit::{ event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}, event_loop::{ControlFlow, EventLoop}, window::WindowBuilder, }; fn main() { let mut rng = rand::thread_rng(); let data: Str...
true
0ac3a64a0a477f7053d225af02c5ebfd5fd60cc8
Rust
jfarrell468/isim
/src/rmd.rs
UTF-8
1,639
3.09375
3
[]
no_license
fn distributon_period(age: i32) -> Option<f64> { #[rustfmt::skip] const DISTRIBUTION_PERIOD: [f64; 46] = [ 27.4, // Age 70 26.5, 25.6, 24.7, 23.8, 22.9, 22.0, 21.2, 20.3, 19.5, 18.7, 17.9, 17.1, 16.3...
true
f92289370fc40ad9b57ee0bcd430267dfdf6fee6
Rust
3enoit3/rust_playground
/v2_split_word.rs
UTF-8
252
3.53125
4
[]
no_license
fn hello() -> String { "Hello World!".to_string() } fn is_sep(c: char) -> bool { c.is_whitespace() } fn split_into_words(s: &str) -> Vec<&str> { s.split(is_sep).collect() } fn main() { println!("{:?}", split_into_words(&hello())); }
true
793fc031b1021b48ca4cc946693945a8570a64b1
Rust
sejr/core-interpreter
/src/executor.rs
UTF-8
14,879
2.765625
3
[]
no_license
#![allow(dead_code)] #![allow(unused_mut)] #![allow(unused_imports)] #![allow(unused_variables)] #![allow(unused_assignments)] #![allow(unused_must_use)] use std::io; use std::io::stdout; use std::io::Write; use std::ops::Index; use tokenizer::Token; use parser::ParseTree; use std::collections::HashMap; pub fn init_e...
true
940054ab772f25afb08b57769b1bad51e0e7ef50
Rust
quantapix/qnarre
/tools/syn/src/stmt.rs
UTF-8
19,039
2.953125
3
[ "MIT" ]
permissive
use super::*; struct NoSemi(bool); pub enum Stmt { Expr(Expr, Option<Token![;]>), Item(Item), Local(Local), Mac(Mac), } impl Parse for Stmt { fn parse(s: Stream) -> Res<Self> { let y = NoSemi(false); parse_stmt(s, y) } } impl Lower for Stmt { fn lower(&self, s: &mut Stream)...
true
b2b6a3a31912b22bf20653b3a4ec43ce3a4b89c1
Rust
Deskbot/Advent-of-Code-2020
/src/day/day02part1.rs
UTF-8
1,917
3.4375
3
[]
no_license
use crate::util::{ both, option_bind, }; struct Range { min: i32, max: i32 } impl Range { pub fn contains(&self, num: i32) -> bool { num >= self.min && num <= self.max } } struct Rule { range: Range, letter: char, } impl Rule { pub fn test(&self, password: &str) -> bool {...
true
e7ef76b7dbc0a295d033c80465cb271668edb612
Rust
swc-project/swc
/crates/swc_ecma_minifier/src/compress/pure/vars.rs
UTF-8
16,380
2.53125
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use rustc_hash::FxHashSet; use swc_common::{util::take::Take, DUMMY_SP}; use swc_ecma_ast::*; use swc_ecma_utils::{prepend_stmt, StmtLike}; use swc_ecma_visit::{ noop_visit_mut_type, noop_visit_type, Visit, VisitMut, VisitMutWith, VisitWith, }; use super::Pure; use crate::{ compress::util::{drop_invalid_stmts,...
true
ab7a81c0dce512f12e619c38f32adeefb8511fbf
Rust
jturner314/typed_csv
/src/writer/mod.rs
UTF-8
12,231
3.5625
4
[ "MIT", "Unlicense" ]
permissive
mod field_names_encoder; use self::field_names_encoder::FieldNamesEncoder; use csv::{self, Result}; use rustc_serialize::Encodable; use std::fs::File; use std::io::{BufWriter, Write}; use std::marker::PhantomData; use std::path::Path; /// A CSV writer that automatically writes the headers. /// /// This writer provid...
true
374d69c80708c4025efca2e95b45e2a59af43a63
Rust
deliangyang/leetcode.rs
/src/bin/palindromic-substrings.rs
UTF-8
956
3.4375
3
[]
no_license
use std::collections::HashMap; fn count_substrings(s: String) -> i32 { let l = s.len(); if l <= 1 { return l as i32; } let mut count = 0; let ss = s.as_bytes(); for i in 0..l { for j in (i + 1 .. l).rev() { if ss[i] == ss[j] { let mut left = i; ...
true
b5fd7fdf2cc82e4520ab241fae53e1a39bd5d53a
Rust
nikomatsakis/rust
/src/test/run-pass/unique-swap.rs
UTF-8
106
2.875
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "bzip2-1.0.6", "BSD-1-Clause" ]
permissive
fn main() { let i = ~100; let j = ~200; i <-> j; assert i == ~200; assert j == ~100; }
true
92cccd459895259502b455996076f518fc652e31
Rust
sourcepirate/rust-exersices
/beer-song/src/lib.rs
UTF-8
1,321
3.609375
4
[]
no_license
use std::fmt; struct Beer { no: u32 } impl fmt::Display for Beer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let total = phrase(self.no); write!(f, "{}", total) } } fn phrase(no: u32) -> String{ let mut song = String::new(); if no == 0 { let gstr = format!("No mo...
true
71352b46655e1db343cd56fe03096bd65600a1f7
Rust
yottalogical/toggl-rs
/toggl_rs/src/error.rs
UTF-8
1,191
3.1875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::fmt; /// Error Value #[derive(Debug)] pub enum TogglError { /// All errors that come from authentication. AuthError(String), /// Errors that come from reqwest throwing an error ReqwestError(reqwest::Error), /// Dummy Type. Not used in the API NotImplemented, } impl std::convert::From<...
true
814b3d3e3fff5beafd64023782b4b31a1bab8026
Rust
michaelmelanson/advent-of-code-2020
/src/day5.rs
UTF-8
1,975
3.359375
3
[]
no_license
#[derive(Debug, PartialEq)] pub enum Instruction { Left, Right, Front, Back } #[derive(Debug, PartialEq)] pub struct Ticket(Vec<Instruction>); impl Ticket { fn seat_id(&self) -> usize { let mut row = 0; let mut column = 0; for instruction in &self.0 { match instruction { Instruction...
true
a7ca810149e02887a0373374ae1aecd992e7fe46
Rust
csixteen/LeetCode
/Problems/Algorithms/src/Rust/partition-list/src/lib.rs
UTF-8
3,101
3.640625
4
[ "MIT" ]
permissive
// https://leetcode.com/problems/partition-list/ #[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>> } impl ListNode { #[inline] fn new(val: i32) -> Self { ListNode { next: None, val } } } struct Soluti...
true
e7d92860d6ba7044ce8f65d838d5bf948fc0ff5f
Rust
dvdplm/radix
/src/lib.rs
UTF-8
15,622
3.453125
3
[]
no_license
//! A rust library to deal with number conversion between radices. #![feature(conservative_impl_trait)] #![feature(i128_type)] const DEBUG: bool = false; macro_rules! debug { ($fmt:expr $(, $args:expr)*) => {{ if DEBUG { use std::io::Write; println!($fmt, $($args),*); ...
true
af50c6c78a7e5177156ea7f0cfdfa3879453ccdd
Rust
draftedus/tangram
/ui/form/select_field.rs
UTF-8
1,786
2.65625
3
[ "MIT" ]
permissive
use super::FieldLabel; use html::{component, html}; use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; #[derive(Clone)] pub struct SelectFieldOption { pub text: String, pub value: String, } #[component] pub fn SelectField( disabled: Option<bool>, id: Option<String>, label: Option<String>, name: Option<Stri...
true
4da2b409b02cd76351aa667452bfd7a7ed8784ed
Rust
Timeo1210/m3u8-dl-fast
/src/fetcher.rs
UTF-8
1,569
2.921875
3
[]
no_license
use std::path::Path; use anyhow::{Error, Result}; use bytes::Bytes; use url::Url; use futures::{stream, StreamExt}; use reqwest::Client; use crate::file_manager::write_file_from_buffer; const CONCURRENT_REQUESTS: usize = 8; #[derive(Debug)] struct Response { filename: String, data: Bytes, } fn save_response(d...
true
80826042ece889fa825ae05ec93ccb2917b5aa6f
Rust
wortelstoemp/nitrust-oxide
/src/framework/graphics/texture.rs
UTF-8
5,673
2.734375
3
[]
no_license
extern crate gl; extern crate libc; extern crate std; use gl::types::*; use std::io; use std::io::{ Error, ErrorKind }; use std::io::prelude::*; use std::fs::File; pub struct Texture { id: GLuint, } impl Texture { pub fn new() -> Texture { Texture { id: 0, } } pub fn begin(&self) { unsafe { gl::Bind...
true
5d4b64f82e2d0e8b7a037d8876ace02831a63fd5
Rust
DoumanAsh/stm32l4x6_hal
/src/lcd/ram.rs
UTF-8
1,561
3.046875
3
[ "Apache-2.0" ]
permissive
use super::LCD; pub trait Index { type RamType; fn ram(lcd: &LCD) -> &Self::RamType; fn write(lcd: &mut LCD, data: u32); } macro_rules! define_index { ($(#[$attr:meta])* $name:ident: $ram_type:ty, $access:ident) => { $(#[$attr])* pub struct $name; impl Index for $name { ...
true
a399dc3b818f7f75a166e892532ffa21b88c408e
Rust
joshmarinacci/idealos_rust_client
/src/window.rs
UTF-8
2,637
2.90625
3
[]
no_license
use serde::{Deserialize, Serialize}; use crate::messages::{WindowInfo, window_info}; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Rect { pub x:i32, pub y:i32, pub width:i32, pub height:i32, pub color:String, } pub struct Dimensions { pub width:i32, pub height:i32, } pub str...
true
c5e09dd61d840bd1208ae575614b8d5cdddc3834
Rust
makutak/sandbox
/books/rustbook/ch03/basic/src/my_loop.rs
UTF-8
345
2.78125
3
[]
no_license
pub fn exec() { 'main: loop { println!("main loop start"); 'sub: loop { println!("sub loop start"); break 'main; println!("sub loop end"); //ใ“ใ“ใพใงๆฅใชใ„ใฎใง่กจ็คบใ•ใ‚Œใชใ„ } println!("main loop end"); //ใ“ใ“ใพใงๆฅใชใ„ใฎใง่กจ็คบใ•ใ‚Œใชใ„ } }
true
d4922a2b2432feea05616ddd9357b92579b1cd23
Rust
mindsbackyard/galvanic-assert
/tests/core_matchers.rs
UTF-8
7,975
2.65625
3
[ "Apache-2.0" ]
permissive
/* Copyright 20&17 Christopher Bacher * * 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...
true
514ff065c208bdc874fe816407e99c03ab8221ab
Rust
IThawk/rust-project
/rust-master/src/test/rustdoc/const-generics/const-impl.rs
UTF-8
912
2.640625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// ignore-tidy-linelength #![feature(const_generics)] #![crate_name = "foo"] pub enum Order { Sorted, Unsorted, } // @has foo/struct.VSet.html '//pre[@class="rust struct"]' 'pub struct VSet<T, const ORDER: Order>' // @has foo/struct.VSet.html '//h3[@id="impl-Send"]/code' 'impl<const ORDER: Order, T> Send fo...
true
40df59d746247ccdcf6e70e69b83b775fa44881f
Rust
katyo/drm-rs
/src/control/dumbbuffer.rs
UTF-8
1,210
2.953125
3
[ "MIT" ]
permissive
//! //! # DumbBuffer //! //! Memory-supported, slow, but easy & cross-platform buffer implementation //! use buffer; #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] /// Slow, but generic `Buffer` implementation pub struct DumbBuffer { pub(crate) size: (u32, u32), pub(crate) length: usize, pub(crate) fo...
true
831acf42c6d8f43782df6983c894fc7707ec258c
Rust
lhutyra/0dmg
/zerodmg-codes/src/disassembled.rs
UTF-8
8,570
3.0625
3
[ "MIT" ]
permissive
#![macro_use] use std::fmt; use std::fmt::Display; use self::prelude::*; use crate::assembled::prelude::*; use crate::instruction::prelude::*; /// Re-exports important traits and types for glob importing. pub mod prelude { pub use super::DisassembledRom; pub use super::RomBlock; pub use super::RomBlockCo...
true
cbae0b226f7028ad1e1b56bef1c98d0a1cb63beb
Rust
brandonw/cgmath-rs
/tests/line.rs
UTF-8
4,122
2.578125
3
[ "Apache-2.0" ]
permissive
// Copyright 2013-2014 The CGMath Developers. For a full listing of the authors, // refer to the AUTHORS file at the top-level directory of this distribution. // // 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 cop...
true
c1f2ccf3d4ab4ae31e6f6828580dcccf0dd27b2a
Rust
ousbots/AdventOfCode
/archive/2019/day5/src/main.rs
UTF-8
8,559
3.40625
3
[]
no_license
use std::fs; use std::io; // Parses the given memory location for the opcode, parameters, and modes of a given length. fn parse_opcode(memory: &Vec<i64>, pos: usize, len: usize) -> (i64, Vec<i64>, Vec<i64>) { const INSTR_MOD: i64 = 100; const MODE_MOD: i64 = 10; let mut opcode: i64 = memory[pos]; let...
true
4cee1c391b6f825df6f78c67f63bd2a9899c8661
Rust
peterino2/peterinogl
/src/peter_gl.rs
UTF-8
4,313
2.734375
3
[]
no_license
use std::ffi::{CString, CStr}; use std::path; use std::fs; use std::io::Read; use std::io; pub struct ShaderPipe{ frag_shader: Shader, vert_shader: Shader, prog_id: gl::types::GLuint, } impl ShaderPipe{ pub fn construct() -> ShaderPipe { let frag_shader_src = load_file_as_cstr(path::Path:...
true
f720dc52e6e26df37897aef6212867c60722d982
Rust
rehwinkel/winkel
/src/gl_renderer/mod.rs
UTF-8
7,144
2.71875
3
[]
no_license
use super::Renderer; use super::{Style, TextStyle}; use std::collections::HashMap; mod font; mod utils; use font::Font; use utils::{ shader::{Program, Shader}, VertexArray, }; #[derive(Eq, PartialEq, Hash)] struct FontDescription { size: u32, name: String, } pub struct GlRenderer<'a> { quad: Ver...
true
0b6c2ba6e1699d7f4af2311a3283da7baad4b653
Rust
notflan/chacha20stream
/src/ffi/error.rs
UTF-8
1,834
3.171875
3
[ "MIT" ]
permissive
//! FFI errors use super::*; #[macro_export] macro_rules! errchk { ($expr:expr) => { match CErr::from($expr) { CErr::Success => (), x => return x, } }; } //TODO: Rework the error handling/reporting here. #[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Copy)] #[repr(C)] pub enum CErr...
true
628fa4a227053918f65d36fb98910aadd9b72183
Rust
passchaos/debug-here
/debug-me/src/main.rs
UTF-8
239
3.25
3
[ "Apache-2.0", "MIT" ]
permissive
#[macro_use] extern crate debug_here; fn factorial(n: usize) -> usize { let mut res = 1; debug_here!(); for i in 0..n { res *= i; } res } fn main() { println!("The factorial of 5 is {}!", factorial(5)); }
true
c233a8baa6903076c94c45decfe1418a837b140f
Rust
pajh/tron
/src/floodfill.rs
UTF-8
6,711
2.75
3
[]
no_license
use board::AvailMoves; use board::BHEIGHT; use board::BWIDTH; use board::Board; use board::MoveTree; use std::io; use support::Fill; use support::MAXPLAYERS; use support::Move; use support::PPos; use support::PScore; use support::Player; use std::collections::VecDeque; pub struct FloodBoard { pub cells: [u16; 600...
true
e98853a6ccc69bd267bf3ea13a0d806d0723189e
Rust
tagirov/ccl
/src/main.rs
UTF-8
1,253
3.609375
4
[]
no_license
use std::process::exit; fn main() { let mut args = std::env::args().skip(1); let print_ops = "Expected operator: [ + ][ - ][ / ][ x ][ % ]"; let a = args.next() .unwrap_or_else(|| { eprintln!("Not enough arguments"); exit(1); }) .parse::<f64>() .unw...
true
c7f6a61d9d602ce5409b6069e3b31654f36c1aef
Rust
emptyrivers/advent2019
/src/opcodes.rs
UTF-8
1,414
2.96875
3
[]
no_license
fn evaluate(data: &Vec<i64>, noun: i64, verb: i64) -> i64 { let mut mem = data.clone(); mem[1] = noun; mem[2] = verb; let mut ptr = 0; while ptr < mem.len() { let op = mem[ptr]; match op { 99 => return mem[0], 1 => { let loc0 = mem[ptr + 1] as...
true
03789d2f13119efd4b7d7b2ea7af23184d45e221
Rust
Danue1/lzw
/rust/src/main.rs
UTF-8
313
2.953125
3
[]
no_license
mod dictionary; fn main () { use self::dictionary::Dictionary; let mut map = Dictionary::new(); let source = read_source(); let result = map.compress(&source); println!("{:?}", result); } #[inline] fn read_source () -> String { let source = "ABABBABCABABBA"; source.to_string() }
true
c6ccc35c8d11e868752fd81cfce2b28d4fed6efd
Rust
Dannnno/wk4-starter
/replace_with/src/lib.rs
UTF-8
224
2.96875
3
[]
no_license
use std::ptr; /// Replaces `*t` with `f` applied to the original `*t`, pub fn replace_with<T, F: FnOnce(T) -> T>(t: &mut T, f: F) { let pointer = t as *mut T; unsafe { ptr::write(pointer, f(ptr::read(pointer))) } }
true