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
5dede3a47ffd03096b3c1e463f5d0f8c88140e4c
Rust
rustbunker/osm-geo-mapper
/benches/operations.rs
UTF-8
1,034
2.515625
3
[ "MIT" ]
permissive
use std::thread; use criterion::{criterion_group, criterion_main, Criterion}; use osm_geo_mapper::operations; fn bench_process_geojson() { let geojson = operations::parse_geojson_file("resources/ottawa.xml.geojson"); operations::process_geojson(&geojson); } fn bench_threaded_process_geojson() { let mut h...
true
bc770f909c245dcabbe51ef5bca065999edb103f
Rust
uuhan/Accepted
/src/draw/char_style.rs
UTF-8
6,573
2.953125
3
[ "MIT" ]
permissive
use std; use std::fmt; use syntect; use termion; use termion::color::{Bg, Fg}; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Color { Rgb { r: u8, g: u8, b: u8 }, Reset, } impl Default for Color { fn default() -> Self { Self::Reset } } impl Into<Box<dyn termion::color::Color>> for Col...
true
fc67440a9bc4d3b136d8d3fd078e956ade1108c3
Rust
lentzi90/AI-playground
/src/main.rs
UTF-8
5,164
2.9375
3
[ "MIT" ]
permissive
extern crate iron; extern crate staticfile; extern crate mount; extern crate rand; extern crate rustc_serialize; use rustc_serialize::json; use iron::prelude::*; use mount::Mount; use staticfile::Static; use std::path::Path; use std::thread; use std::thread::sleep; use std::sync::{Arc, Mutex}; use std::io::Read; us...
true
a455adaaa16d1bb94971714daebfca8861808ee5
Rust
lazytiger/pbrt-rs
/tests/vectors.rs
UTF-8
3,582
3.21875
3
[ "MIT" ]
permissive
#![allow(dead_code)] use pbrt::core::{ geometry::{Point3, Point3f, Vector3f}, pbrt::Float, transform::{Point3Ref, Transform}, RealNum, }; use std::ops::{Deref, Mul}; #[test] fn test_vectors() { use pbrt::core::geometry::{Vector2f, Vector3f}; let a = Vector2f::new(1.0, 2.0); assert_eq!(a[0]...
true
c631f95e269d3b81f61f48b0dbda842c93308da5
Rust
ilya-mezentsev/cloud-box
/cbox/src/commands/factory.rs
UTF-8
2,325
2.921875
3
[]
no_license
use std::error::Error; use crate::commands::{ create_file::CreateFile, create_folder::CreateFolder, delete_file::DeleteFile, delete_folder::DeleteFolder, get_disks::GetDisks, get_file::GetFile, get_folder::GetFolder, rename::Rename, }; use crate::decorators::commands_loggers::{ RespondingCommandLoggerD...
true
d8bab49445a8fc894bc48b3711ac3a77e3d06859
Rust
aclueless/rustmart-examples
/rustmart-spair-with-components/src/pages/home.rs
UTF-8
1,789
2.765625
3
[]
no_license
use crate::renders::{Error, Spinner}; use crate::types::Product; use spair::prelude::*; pub struct Home { pub all_products: Vec<Product>, pub parent_comp: spair::Comp<crate::App>, pub error_message: Option<spair::FetchError>, } impl Home { pub fn fetch_all_products(&mut self) -> spair::Command<Self> {...
true
44f79d375a6117c3737a339f289b56ed5080024f
Rust
alihsaas/chess-cli
/src/chess_board.rs
UTF-8
6,816
2.796875
3
[]
no_license
use crate::pieces; use console::{Style, Term}; use crossterm::event::{read, Event, KeyCode}; use std::{ collections::HashMap, fmt::{Error, Write}, }; type Board = HashMap<(u8, u8), (pieces::Piece, pieces::Team)>; #[derive(Debug)] pub struct ChessBoard { pub board: Board, user_selected: (u8, u8), b...
true
d77e790476ae4fbeb531f47f359f193a94fded80
Rust
3gx/rustexp
/rust_book/ch14/add/adder/src/main.rs
UTF-8
213
2.890625
3
[]
no_license
use add_one; use rand; use rand::Rng; fn main() { let num = rand::thread_rng().gen_range(1, 101); println!( "Hello, world! {} plus one is {}!", num, add_one::add_one(num) ); }
true
4b16ee2af6c32c1794bf8e73c4efcea2b1479c74
Rust
gimli-rs/object
/src/read/pe/import.rs
UTF-8
11,341
2.953125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use core::fmt::Debug; use core::mem; use crate::read::{Bytes, ReadError, Result}; use crate::{pe, LittleEndian as LE, Pod, U16Bytes}; use super::ImageNtHeaders; /// Information for parsing a PE import table. #[derive(Debug, Clone)] pub struct ImportTable<'data> { section_data: Bytes<'data>, section_address: ...
true
471e0beb308727305a9800d37d859ca3836667da
Rust
timvermeulen/advent-of-code
/src/solutions/year2018/day02.rs
UTF-8
1,525
2.921875
3
[]
no_license
use super::*; fn parser<'a>() -> impl Parser<&'a str, Output = Vec<&'a str>> { satisfy(char::is_alphabetic) .skip_many1() .recognize() .collect_sep_by(token('\n')) } fn part1(ids: &[&str]) -> u32 { let mut two_count = 0; let mut three_count = 0; ids.iter().copied().for_each(|id...
true
df74e14a9ef0baee02177fdd241ed71845f4b39c
Rust
swift-nav/libsbp
/rust/sbp/src/link.rs
UTF-8
11,098
3.140625
3
[ "MIT" ]
permissive
//! Callback based message handler. use std::{ borrow::{Borrow, Cow}, convert::TryInto, sync::{Arc, Mutex}, }; use slotmap::DenseSlotMap; use crate::messages::{ConcreteMessage, Sbp, SbpMessage}; /// Used to send messages to callbacks registered via [Link]s created from this `LinkSource`. pub struct Link...
true
8abbb6723562aff5c17bd1b077bc468fbbc7580a
Rust
bitkis/vagga
/src/wrapper/util.rs
UTF-8
2,404
2.765625
3
[ "MIT" ]
permissive
use std::path::{Path, PathBuf}; use std::collections::BTreeMap; use unshare::{Command}; use crate::config::Container; use crate::config::command::Run; pub fn find_cmd(cmd: &str, env: &BTreeMap<String, String>) -> Result<PathBuf, String> { if cmd.contains("/") { return Ok(PathBuf::from(cmd)); } e...
true
6e6a7695ccc236c4d53dae61e0cbe96af4792c4c
Rust
s32k-rust/s32k144.rs
/src/sim/platcgc.rs
UTF-8
16,306
2.65625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::PLATCGC { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w m...
true
d2de54d19a8f8d1bd0f2f95d800e07fd2174a09a
Rust
Apkawa/infix2postfix
/rust/src/generate_infix.rs
UTF-8
2,843
3.265625
3
[]
no_license
extern crate rand; extern crate num; use rand::Rng; const OPEN_BRACKET_STATE: u8 = 1; const CLOSE_BRACKET_STATE: u8 = 2; const NUMBER_STATE: u8 = 3; const OPERATOR_STATE: u8 = 4; const OPERATORS: [char; 4] = ['/', '*', '-', '+']; const OPEN_BRACKET: char = '('; const CLOSE_BRACKET: char = ')'; static OPEN_BRACKET...
true
87b6727b20cb4dd57e073ee74df8ca37fcd0c8fa
Rust
giodamelio/little_boxes
/vendor/winnow/examples/arithmetic/parser_ast.rs
UTF-8
4,345
3.546875
4
[ "MIT" ]
permissive
use std::fmt; use std::fmt::{Debug, Display, Formatter}; use std::str::FromStr; use winnow::prelude::*; use winnow::{ ascii::{digit1 as digit, multispace0 as multispace}, combinator::alt, combinator::repeat, combinator::{delimited, preceded}, }; #[derive(Debug)] pub enum Expr { Value(i64), Ad...
true
38bbfd71a914d1b326e873106742c2883c9af400
Rust
djcsdy/wildflower-codec
/src/decode/tags/styles/line_style_array.rs
UTF-8
595
2.5625
3
[]
no_license
use crate::decode::bit_read::BitRead; use crate::decode::read_ext::SwfTypesReadExt; use std::io::Result; pub fn read_line_style_array< Read: BitRead, LineStyle, ReadLineStyle: Fn(&mut Read) -> Result<LineStyle>, >( reader: &mut Read, read_line_style: &ReadLineStyle, ) -> Result<Vec<LineStyle>> { ...
true
99843edd068bfdae247b3525f5e8b9d0e58d0b76
Rust
joshkunz/advent-of-code
/2020/02/p1.rs
UTF-8
2,208
3.40625
3
[]
no_license
use std::env; use std::fs; use std::num; use std::str::FromStr; type Result<T> = std::result::Result<T, Error>; #[derive(Debug, Clone)] struct Error(String); impl From<String> for Error { fn from(s: String) -> Self { Self(s) } } impl From<&str> for Error { fn from(s: &str) -> Self { Self...
true
c85e5762454426ccab2a2af9e4da913b1e0e19f4
Rust
viperscape/stratis
/server/src/store.rs
UTF-8
2,707
3.078125
3
[ "Apache-2.0" ]
permissive
use postgres::{Connection, TlsMode}; use uuid::Uuid; use shared::client::{ClientBase}; use shared::player::Player; pub trait DataStore: Sized { fn default () -> Self; fn clients_get (&self) -> Vec<ClientBase>; fn client_put (&self, c: &ClientBase) -> bool; fn msg_put (&self, uuid: &Uuid, data: &Vec<u8...
true
c55b6404c75e15dcfe4d4e593c65ad9aa929e0d0
Rust
FilippoRanza/fsa-net
/src/compiler/name_table/class_index.rs
UTF-8
1,075
3.03125
3
[ "MIT" ]
permissive
use ahash::AHashMap; #[derive(Debug)] pub struct ClassIndex<T> { counter: AHashMap<T, usize>, } impl<T> ClassIndex<T> where T: Eq + std::hash::Hash, { pub fn new() -> Self { Self { counter: AHashMap::new(), } } pub fn get_count(&mut self, cls: T) -> usize { let...
true
7035cbd46247fe6c96324a6d2bda191cb27bb8e6
Rust
yusefkarim/STM32F1-Projects
/rust_hal/nrf24l01_example_v2/embedded-nrf24l01/src/error.rs
UTF-8
206
2.90625
3
[]
no_license
use core::fmt::Debug; #[derive(Debug)] pub enum Error<SPIE: Debug> { SpiError(SPIE), } impl<SPIE: Debug> From<SPIE> for Error<SPIE> { fn from(e: SPIE) -> Self { Error::SpiError(e) } }
true
4108b837a866add81689bf96f5bf051cfe22b1c2
Rust
digitalbitbox/bitbox02-firmware
/src/rust/vendor/minicbor/src/bytes.rs
UTF-8
14,877
3.125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BlueOak-1.0.0" ]
permissive
//! Newtypes for `&[u8]`, `[u8;N]` and `Vec<u8>`. //! //! To support specialised encoding and decoding of byte slices, byte arrays, //! and vectors which are represented as CBOR bytes instead of arrays of `u8`s, //! the types `ByteSlice`, `ByteArray` and `ByteVec` (requires feature "alloc") //! are provided. These impl...
true
5ea945c138fcab5d5a6ae264981c95363d837143
Rust
Im-Oab/One-Man-ggj21
/src/gameplay/enemy_types/spawner.rs
UTF-8
6,398
2.640625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::time::Duration; use rand::prelude::*; use tetra::graphics::{self, Color, GeometryBuilder, Mesh, Rectangle, ShapeStyle}; use tetra::math::Vec2; use tetra::Context; use crate::image_assets::ImageAssets; use crate::sprite::AnimationMultiTextures; use crate::gameplay::enemy_manag...
true
4f9115016c5463d867cbdfffe8f659e4fc6fe009
Rust
MisterUncloaked/rbx-dom
/rbx_binary/benches/serializer.rs
UTF-8
1,109
2.515625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use criterion::{criterion_group, criterion_main, Criterion}; use rbx_dom_weak::{RbxInstanceProperties, RbxTree}; pub fn ser_folders_100(c: &mut Criterion) { let mut tree = RbxTree::new(RbxInstanceProperties { name: "Container".to_owned(), class_name: "Folder".to_owned(), properties: Defaul...
true
780c46881ded31bd8fd4e9260462cb096fd5888a
Rust
Bunogi/darkredis
/deadpool-darkredis/src/lib.rs
UTF-8
2,237
2.9375
3
[ "Zlib" ]
permissive
#![warn(missing_docs)] //! Adapter crate for using Darkredis with Deadpool. use async_trait::async_trait; use darkredis::{Command, Connection, Error, ToSocketAddrs}; use deadpool::managed as pool; ///The connection pool type for Darkredis. See the Deadpool documentation for more information. pub type Pool = pool::Po...
true
bc5f6fbe820c0b0130a763e678cf261c490c1baa
Rust
ArtUshak/trunk
/src/tools.rs
UTF-8
13,231
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Download management for external tools and applications. Locate and automatically download //! applications (if needed) to use them in the build pipeline. use std::path::{Path, PathBuf}; use anyhow::{anyhow, bail, ensure, Context, Result}; use async_compression::tokio::bufread::GzipDecoder; use directories_next::...
true
5262d187ba6229245f5ced140d4621c9122bd878
Rust
laucia/euler-project
/src/bin/10.rs
UTF-8
489
3.328125
3
[]
no_license
// [Problem 10]: (https://projecteuler.net/problem=10) // - - - - - - - - - - - - - - - - - - - - - - - - - - // The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. // Find the sum of all the primes below two million. extern crate algorithm; use algorithm::prime::primer; fn solve(max: u64) -> u64 { primer().tak...
true
650e14f2d56f1c1563f47d5e2c2a5b0960968f2e
Rust
LegNeato/rust-gob-1
/src/schema.rs
UTF-8
3,686
2.53125
3
[ "MIT" ]
permissive
//! Schema management use std::io::Write; use serde::de::value::Error; use serde::{Deserialize, Deserializer}; use serde::{Serialize, Serializer}; use serde_schema::types::Type; use internal::gob::Writer; use internal::ser::SerializeWireTypes; use internal::utils::UniqMap; pub struct Schema { pending_wire_types...
true
63c4c49cb252762168b8960b604a042bf0cb3d8b
Rust
chops76/AoC2017
/src/day23.rs
UTF-8
2,680
3.296875
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::time::Instant; use std::collections::HashMap; use primes::is_prime; type Input = Vec<Command>; #[derive(Debug)] #[derive(Clone)] pub enum Command { Set(String, String), Sub(String, String), Mul(String, String), Jnz(String, String) } fn parse_line(s: ...
true
830334e508ebd9329a4042fa74e7bb1048fdce48
Rust
epylinkn/ahead
/src/main.rs
UTF-8
1,208
2.984375
3
[]
no_license
extern crate clap; use std::process::Command; use clap::{Arg, App}; fn main() -> Result<(), Box<dyn std::error::Error>> { let matches = App::new("Ahead") .version("0.1.0") .author("Anthony Bui") .about("Preview your day on the command line written in Rust") .arg( Arg::with_name("Days") ...
true
a74c86a2ebad74728bbe891dfe04ba480e5aabc5
Rust
Nikheln/advent-of-code-2020
/src/bin/day18.rs
UTF-8
8,247
3.6875
4
[]
no_license
mod helpers; fn main() { let filename: &str = "day18.txt"; let input = &helpers::input_helpers::read_input(&filename).unwrap(); task_1(input); task_2(input); } fn task_1(input: &[String]) -> i64 { let result = input.iter().map(task_1_internal).sum(); println!("Task 1: {}", result); result ...
true
c736cace898551ebcf85ac472ab7e6ea450a79c3
Rust
delta62/soundtest
/src/main.rs
UTF-8
1,831
2.703125
3
[]
no_license
#[macro_use] mod macros; mod alsa; use alsa::{Device, DeviceConfig}; use dasp::signal::{self as signal, Signal}; use dasp::sample::conv; use std::collections::VecDeque; use std::sync::{Arc, Mutex, mpsc}; use std::thread; const SAMPLE_RATE: u32 = 44_100; enum Message { WantMoreData, } fn main() { let mut sig...
true
fb601d6893b78fbd8d198d2aabc4879dbe32f024
Rust
Ninjani/rosalind
/s_indc/src/lib.rs
UTF-8
1,527
2.890625
3
[ "MIT" ]
permissive
use anyhow::Error; use ndarray::Array1; use std::path::Path; /// Independent Segregation of Chromosomes /// /// Given: A positive integer n≤50. /// /// Return: An array A of length 2n in which A[k] represents the common logarithm of the /// probability that two diploid siblings share at least k of their 2n chromosome...
true
37915c58e1c79a4e8dc2660b328facb27ad2ccf3
Rust
zaeleus/noodles
/noodles-htsget/src/client.rs
UTF-8
2,384
3.078125
3
[ "MIT" ]
permissive
use url::Url; use super::{reads, request, request::Kind, variants}; /// A htsget client. #[derive(Clone, Debug)] pub struct Client { http_client: reqwest::Client, base_url: Url, } impl Client { /// Creates an htsget client with a default HTTP client. /// /// # Examples /// /// ``` ///...
true
31f2fe4693cccd09da72f41fd724e2bc0e69b579
Rust
moroso/compiler
/src/mas/ast.rs
UTF-8
30,950
2.625
3
[]
no_license
// Internal representation of Moroso asm instructions. // Note that we actually use the numeric values for the items in these enums. // DO NOT REORDER unless we're changing the instruction encoding in the // processor! use std::fmt; use std::fmt::{Formatter, Display}; use std::collections::BTreeMap; use mas::util::{f...
true
c2ef6e65ba7a4697ff24e5091af5ae6106fd4074
Rust
rustwasm/wasm-bindgen
/crates/web-sys/tests/wasm/slot_element.rs
UTF-8
586
2.625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use wasm_bindgen::prelude::*; use wasm_bindgen_test::*; use web_sys::HtmlSlotElement; #[wasm_bindgen(module = "/tests/wasm/element.js")] extern "C" { fn new_slot() -> HtmlSlotElement; } #[wasm_bindgen_test] fn test_slot_element() { let _slot = new_slot(); // TODO: Test fails in Firefox, but not in Chrome....
true
333f73dae8ca31e114fccdea56aa0e8e438788e3
Rust
seandewar/challenge-solutions
/leetcode/medium/top-k-frequent-elements.rs
UTF-8
2,336
3.625
4
[]
no_license
// https://leetcode.com/problems/top-k-frequent-elements/ // // Using a hash map and sort. // Complexity: runtime O(n*logn) [O(n+k*logn) possible with a partial sort], space O(n). use std::collections::HashMap; impl Solution { pub fn top_k_frequent(nums: Vec<i32>, k: i32) -> Vec<i32> { let mut counts = Ha...
true
3fcb247f69e499051edf2ae81c6a07eb484a1a2a
Rust
OZ-T/Speed-up-your-Python-with-Rust
/chapter_two/defining_interfaces/src/stocks/mod.rs
UTF-8
1,515
3.609375
4
[ "MIT" ]
permissive
pub mod structs; pub mod enums; use structs::stock::Stock; use structs::order::Order; use enums::order_types::OrderType; /// Opens a stock order. /// /// # Arguments /// * number (132): the number of stock in the order /// * order_type (OrderType): the type of order being made /// * stock_name (&str): the name of...
true
77dc8aabff9deb47763673f9dbee5e8c35d9adad
Rust
kstn-cntt-k60/20182-fuzzy
/src/car/fuzzy/distance.rs
UTF-8
1,388
3.203125
3
[]
no_license
use super::*; impl Distance { fn near_fn(x: f32) -> f32 { let x1 = 1.5; let x2 = 5.0; if x < x1 { 1.0 } else if x < x2 { (x2 - x) / (x2 - x1) } else { 0.0 } } fn medium_fn(x: f32) -> f32 { let x1 = ...
true
70a819417e4e7b39b01097953fca1ec7bfb433f8
Rust
TakaakiFuruse/rust-practice
/the_book/ref_and_borrowing/src/main.rs
UTF-8
3,820
4.28125
4
[]
no_license
// ==Code Without Borrow=== // fn main() { // let s1 = String::from("hello"); // let (s1, len) = calculate_length(s1); // println!("{} {}", s1, len); // } // fn calculate_length(s: String) -> (String, usize) { // let length = s.len(); // (s, length) // } fn main() { // ==Code With Borrow=== ...
true
9a82d798d2ba56ff906b7b3324cd2d9de453b399
Rust
keggsmurph21/k10
/src/server/model/user.rs
UTF-8
1,789
3.09375
3
[]
no_license
use serde::{Deserialize, Serialize}; use sqlx::sqlite::SqlitePool; pub type Password = String; // sqlx whines about unsigned pub type UserId = i64; pub type Username = String; /// "Private" data that won't leave the server/db. #[derive(sqlx::FromRow)] pub struct User { pub id: UserId, pub username: Username, ...
true
198ce99b982b390c083eabad739fb416bb547c1c
Rust
AndyBitz/rust-http-server-test
/src/request/mod.rs
UTF-8
2,342
3.21875
3
[]
no_license
use http1; use std::fmt; use std::io::BufReader; use std::net::{TcpStream}; use std::collections::HashMap; pub struct Request { is_tls: bool, method: Option<String>, path: Option<String>, version: Option<String>, headers: Option<HashMap<String, String>>, body: Option<BufReader<TcpStream>>, } ...
true
ed84660d010f951926e62b487a7f09a4ba67b1b2
Rust
stm32-rs/stm32-rs-nightlies
/stm32h7/src/stm32h743/rcc/apb1hrstr.rs
UTF-8
5,007
2.515625
3
[]
no_license
#[doc = "Register `APB1HRSTR` reader"] pub type R = crate::R<APB1HRSTR_SPEC>; #[doc = "Register `APB1HRSTR` writer"] pub type W = crate::W<APB1HRSTR_SPEC>; #[doc = "Field `CRSRST` reader - Clock Recovery System reset"] pub type CRSRST_R = crate::BitReader<CRSRST_A>; #[doc = "Clock Recovery System reset\n\nValue on rese...
true
a6f3baa5022b62a3afe5388518e69048d30fd761
Rust
mcobzarenco/vrum
/src/main.rs
UTF-8
2,534
2.515625
3
[]
no_license
extern crate arrayvec; extern crate env_logger; #[macro_use] extern crate failure; extern crate i2cdev; #[macro_use] extern crate log; mod thunder_borg; use std::process; use std::env; use env_logger::LogBuilder; use log::{LogLevelFilter, LogRecord}; use failure::Error; use thunder_borg::Controller; use std::thread; ...
true
d2aa7e5d46c2f921a9d5d1bd09a09268e4afe756
Rust
brianjp93/aoc2019-rust
/src/days/day1.rs
UTF-8
719
3.25
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; // #[allow(dead_code)] pub fn main() { let f = File::open("./src/data/day1.txt").unwrap(); let reader = BufReader::new(f); let mut part1 = 0; let mut part2 = 0; for line in reader.lines() { let input = line.unwrap().parse::<i32>().unwra...
true
05c8d731eaedff2bc3dad3283e627fd812b4fc85
Rust
yuniruyuni/atcoder
/abc175-b/src/main.rs
UTF-8
465
2.734375
3
[]
no_license
use proconio::input; fn main() { input! { n: usize, mut ls: [i64;n], } ls.sort(); ls.reverse(); let mut ans = 0; for i in 0..n { for j in i..n { if ls[i] == ls[j] { continue } for k in j..n { if ls[j] == ls[k] { continue } ...
true
5fd2db146a3a1e182933ee24ea97b96951a48a65
Rust
KlasafGeijerstam/Kattis
/rust/godzilla.rs
UTF-8
3,643
3.0625
3
[]
no_license
mod fast_input; use fast_input::{FastInput, FastParse}; use std::iter::repeat; use std::collections::VecDeque; #[derive(Copy, Clone)] enum Sector { Empty(bool), Residential, Mech, } use Sector::*; type Position = (usize, usize); #[inline] fn can_be_hit(steps: impl Iterator<Item = Position>, map: &[Sect...
true
08b13ab0d25d17a43836d0c73b08c80cc2705aee
Rust
johnstonskj/rust-code_writer
/src/error.rs
UTF-8
890
2.625
3
[ "MIT" ]
permissive
/*! Standard `Error`, `ErrorKind`, and `Result` types. */ #![allow(missing_docs)] // ------------------------------------------------------------------------------------------------ // Public Types // ------------------------------------------------------------------------------------------------ error_chain! { ...
true
48bc1b5447e06edeafe1b7c542e92cb4cb60d8ef
Rust
mimattan/rover
/crates/rover-client/src/error.rs
UTF-8
6,632
2.625
3
[ "MIT" ]
permissive
use thiserror::Error; use crate::shared::{BuildErrors, CheckResponse, GraphRef}; /// RoverClientError represents all possible failures that can occur during a client request. #[derive(Error, Debug)] pub enum RoverClientError { /// The provided GraphQL was invalid. #[error("{msg}")] GraphQl { /// T...
true
a26daf752cb29e684a75f042c609547ade9300fa
Rust
SiegeEngine/efloat
/src/bin/next_f64.rs
UTF-8
984
3.1875
3
[ "MIT" ]
permissive
use std::env; fn main() { let arg1 = env::args().skip(1).next().unwrap(); let f: f64 = arg1.parse::<f64>().unwrap(); println!("f64: {}", f); println!("Next f64 up: {}", next_f64_up(f)); println!("Next f64 down: {}", next_f64_down(f)); } fn f64_to_bits(f: f64) -> u64 { unsafe { ::std::mem::tra...
true
0a42bd2e91ea1acf3b1cd1cedeab8ff8794c12ce
Rust
tikv/client-rust
/src/kv/value.rs
UTF-8
673
2.734375
3
[ "Apache-2.0" ]
permissive
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0. const _PROPTEST_VALUE_MAX: usize = 1024 * 16; // 16 KB /// The value part of a key/value pair. An alias for `Vec<u8>`. /// /// In TiKV, a value is an ordered sequence of bytes. This has an advantage over choosing `String` /// as valid `UTF-8` is not r...
true
fe0666cd1deb39011c22482f979a323ab5828e94
Rust
ia7ck/competitive-programming
/AtCoder/abc240/src/bin/e/main.rs
UTF-8
892
2.71875
3
[]
no_license
use scanner_proc_macro::insert_scanner; #[insert_scanner] fn main() { let n = scan!(usize); let mut g = vec![vec![]; n]; for _ in 0..(n - 1) { let (a, b) = scan!((usize, usize)); g[a - 1].push(b - 1); g[b - 1].push(a - 1); } let mut ans = vec![(0, 0); n]; dfs(0, 0, &g, ...
true
d244b6bd21e4d992d48e9bd717d88aedc84fe307
Rust
lnds/exercism_rust_track
/triangle/src/lib.rs
UTF-8
1,067
3.5
4
[]
no_license
use std::cmp::PartialOrd; use std::ops::Add; #[derive(PartialEq)] enum Kind { Equilateral, Isosceles, Scalene, } use Kind::{Equilateral, Isosceles, Scalene}; pub struct Triangle(Kind); impl Triangle { pub fn build<T>(sides: [T; 3]) -> Option<Triangle> where T: Copy + PartialOrd + Add<Out...
true
d21faf61b36d9f786cf70dbe9c8782e52adc8ab5
Rust
dbradf/ray-tracer-rust
/src/matrix.rs
UTF-8
22,535
3.390625
3
[]
no_license
use crate::tuple::Tuple; use crate::utils::equal_f64; #[derive(Debug, Clone)] pub struct Matrix { size: usize, elements: Vec<f64>, } impl Matrix { pub fn new(elements: &[f64]) -> Self { let size = (elements.len() as f32).sqrt() as usize; Self { elements: elements.to_vec(), ...
true
10d607770cb47398ac452c874566eec9cb9f8510
Rust
zeroows/onitama
/onitamalib/src/agents/move_gen.rs
UTF-8
2,601
2.984375
3
[ "MIT" ]
permissive
use crate::models::{Board, Move, Player}; use rand::prelude::*; impl Board { pub fn legal_moves(&self) -> Vec<Move> { let mut moves = vec![]; let pieces = self.player_pieces(); for card in self.player_hand() { for src in self.player_pieces().iter().filter_map(|p| *p) { ...
true
3c283be78a6b914e4071f8a68202bef853d5ae92
Rust
forksbot/canduma
/src/models/user.rs
UTF-8
5,064
2.625
3
[ "MIT" ]
permissive
extern crate dotenv; use crate::db::PgPooledConnection; use diesel::prelude::*; use uuid::Uuid; use chrono::*; use crate::schema::users; use crate::utils::identity::{make_hash, make_salt}; use crate::errors::ServiceError; use crate::utils::jwt::create_token; use std::sync::Arc; #[derive(Clone)] pub struct Context { ...
true
8f0f709d99919131a56dcff11455c16fe0a49edb
Rust
pipi32167/LeetCode
/rust/src/problem_0009.rs
UTF-8
640
3.375
3
[]
no_license
mod problem_0009 { pub fn is_palindrome(n: i32) -> bool { if n < 0 { return false; } let mut num = n; let mut res = 0i32; while num > 0 { // println!("{}, {}, {}, {}", res, num, res * 10, num % 10); res = res * 10 + num % 10; num /= 10; } return res == n; } } #...
true
695fa0c947713d9f65e37803e64b3ab8b3841a42
Rust
asg0451/kinesis-firehose
/src/async_producer.rs
UTF-8
9,807
2.84375
3
[]
no_license
//! Async Producer //! //! You probably want to use [`KinesisFirehoseProducer`], which is a type alias of [`Producer<KinesisFirehoseClient>`] use fehler::{throw, throws}; use rand::Rng; use rusoto_core::{Region, RusotoError}; use rusoto_firehose::{ KinesisFirehoseClient, PutRecordBatchError, PutRecordBatchInput, P...
true
3027fca416962322cfd6ff283c579db0f39974d4
Rust
nemotoy/rust-playground
/collection/src/main.rs
UTF-8
1,818
3.765625
4
[]
no_license
use std::collections::HashMap; fn main() { // 空のベクタ // let v: Vec<i32> = Vec::new(); // 初期値を含むベクタ let mut v = vec![1, 2, 3]; println!("collection {:?}", v); v.push(4); println!("collection {:?}", v); let third: &i32 = &v[2]; // let does_not_exist = &v[100]; // panic println...
true
6313ec286123ca69e485eafa8bf5bc5bdca5e703
Rust
waahm7/monkey-rust
/src/evaluator/object.rs
UTF-8
755
3.65625
4
[]
no_license
use std::fmt; type ObjectType = String; pub enum Object { Integer(i64), Boolean(bool), Null, } impl Object { pub fn inspect(&self) -> String { return match self { Object::Integer(i) => i.to_string(), Object::Boolean(i) => i.to_string(), Object::Null => Strin...
true
3d0abd30a675b3c12797d5f41f2fda39bf7feb2f
Rust
patrickbreen/demos
/emulator_6502/src/cpu.rs
UTF-8
11,547
3.0625
3
[]
no_license
use std::collections::HashMap; use mmu::{MMU, Block}; use registers::Registers; #[derive(Copy, Clone)] pub struct Instr { pub addr: fn(&mut CPU) -> u16, pub code: fn(&mut CPU, u16), } impl Instr { pub fn new(addr: fn(&mut CPU) -> u16, code: fn(&mut CPU, u16)) -> Instr { Instr { addr...
true
04aff6a599e542e761bb4c2aa1c4b907c8048882
Rust
mich101mich/game_rs
/src/entity/item.rs
UTF-8
1,306
3.140625
3
[]
no_license
use crate::{ ui::{Clickable, Hitbox}, world::{GamePos, Mineral}, Backend, BackendStyle, Colors, }; #[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)] pub struct ItemID(usize); crate::make_id!(ItemID, Item); #[derive(Debug)] pub struct Item { pub id: ItemID, pub pos: GamePos, pub mineral: Minera...
true
67323c409b2f484bdf647d36346694b124dd1596
Rust
FuriouZz/wk-rs
/src/command/future.rs
UTF-8
1,384
3.046875
3
[]
no_license
use super::command::Command; use crate::error::Error; use std::{ future::Future, pin::Pin, process::Child, task::{Context, Poll}, }; pub type CommandResult = Result<Option<i32>, Error>; pub struct CommandFuture { process: Option<Result<Child, std::io::Error>>, } impl CommandFuture { pub fn new(command: &...
true
ea55366863f5e41d671172c561767a69335a8967
Rust
gabo01/artid
/src/core/ops/test_helpers.rs
UTF-8
4,114
3.109375
3
[ "MIT" ]
permissive
use std::fs::{self, File, OpenOptions}; use std::io::Write; use std::path::{Path, PathBuf}; use tempfile::TempDir; macro_rules! run { ($folder:ident, $options:expr , $op:ident) => {{ let model = Operator::<$op>::modelate(&mut $folder, $options).expect("Unable to build the model"); mode...
true
925b7d6cb0d2ea7259d19ed6b67701ede088e0ec
Rust
amkartashov/exercism
/rust/palindrome-products/src/lib.rs
UTF-8
3,467
3.4375
3
[]
no_license
use std::collections::BTreeSet; #[derive(Debug, Clone, PartialEq, Eq)] pub struct Palindrome { value: u64, factors: BTreeSet<(u64, u64)>, } impl Palindrome { pub fn new(a: u64, b: u64) -> Palindrome { let mut factors = BTreeSet::new(); factors.insert((a, b)); let value = a * b; ...
true
0f4eee2bd1f52037d13e37dff2b7e4ff221f4916
Rust
occlum/occlum
/src/libos/src/signal/do_sigprocmask.rs
UTF-8
1,570
2.75
3
[ "BSD-3-Clause" ]
permissive
use super::constants::*; use super::{sigset_t, SigSet}; use crate::prelude::*; pub fn do_rt_sigprocmask( op_and_set: Option<(MaskOp, &sigset_t)>, oldset: Option<&mut sigset_t>, ) -> Result<()> { debug!( "do_rt_sigprocmask: op_and_set: {:?}, oldset: {:?}", op_and_set.map(|(op, set)| (op, Sig...
true
d569563bd1eae7c56acf709c6b39d61ec8fb136e
Rust
UMASHIBA1/MyRustTutorialPractice
/4/4_12/enum_syntax/src/main.rs
UTF-8
663
3.6875
4
[]
no_license
// Rustにはenum型というものがある。 // 自分なりの解釈ではTypeScriptでいうところの type Message = Quit | ChangeColor | Move | Write;みたいな感じ enum Message { Quit, //データをも持たないヴァリアントの定義方法 ChangeColor(i32, i32, i32), // タプル構造体のような名前なしの構造体の定義方法 Move { x: i32, y: i32 }, // 名前あり構造体の定義方法 Write(String), /...
true
b0f490ec5d1e2d6677bbeb242ea8ee172fc3b993
Rust
speaker73/zemeroth
/src/screen/gui_test.rs
UTF-8
4,661
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
use hate::{self, Context, Event, Screen, Sprite, Time}; use hate::geom::Point; use hate::gui::{self, Gui}; #[derive(Copy, Clone, Debug)] enum GuiCommand { A, B, C, D, E, F, Exit, } #[derive(Debug)] pub struct GuiTest { gui: Gui<GuiCommand>, button_f_id: gui::Id, } impl GuiTest { ...
true
4a0901838f38b1a85011ede8898b276594867e95
Rust
r-englund/rust-spds
/spds/src/utils.rs
UTF-8
2,414
3.21875
3
[]
no_license
use std::{ iter::Sum, ops::{Mul, Sub}, }; pub fn abs_diff<F>(a: F, b: F) -> F where F: Sub<Output = F> + PartialOrd, { if a > b { a - b } else { b - a } } pub fn euclidean_dist_2<F, const D: usize>(a: &[F; D], b: &[F; D]) -> F where F: Sub<Output = F> + Sum + Mul<Output = F...
true
575b54f6de304afffe5f0a3c73cece55e1d99963
Rust
chenghsienwen/rust-demo-service
/src/timeUtil.rs
UTF-8
318
2.578125
3
[]
no_license
use std::time::{SystemTime, UNIX_EPOCH}; pub fn get_current_time_milli() -> u64 { let start = SystemTime::now(); let since_the_epoch = start.duration_since(UNIX_EPOCH) .expect("Time went backwards"); (since_the_epoch.as_secs() * 1000 + since_the_epoch.subsec_nanos() as u64 / 1_000_000) }
true
07fce2bdeb83d54c86659a8748c37e85a383aac6
Rust
iCodeIN/rust-visitors
/src/json/mod.rs
UTF-8
2,142
2.765625
3
[ "Apache-2.0" ]
permissive
pub use self::collect::{CollectMapVisitor, CollectValueVisitor}; pub use self::redact::{RedactMapVisitor, RedactValueVisitor}; pub use self::stringify::{StringifyMapVisitor, StringifyValueVisitor}; pub mod collect; pub mod redact; pub mod stringify; #[derive(Debug, Clone)] pub enum Value { Str(String), Num(f6...
true
66e54fe331f82282dfc077de9a75511f46ec1711
Rust
jimblandy/radiant-rs
/src/core/texture.rs
UTF-8
6,632
3.09375
3
[]
no_license
use prelude::*; use core::{self, RenderContext, Color, Uniform, AsUniform, RenderTarget, AsRenderTarget, Point2}; use core::builder::*; use image::{self, GenericImage}; use backends::backend; /// A texture to draw or draw to. /// /// Textures serve as drawing targets for userdefined [`Postprocessors`](trait.Postproces...
true
2fc8541cf338beb11fee8b0acdb12b88ce6c1fbe
Rust
Atuoha/ruffle
/render/wgpu/src/utils.rs
UTF-8
5,974
2.578125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use lyon::lyon_algorithms::path::Path; use ruffle_core::shape_utils::DrawCommand; use ruffle_core::swf; use std::borrow::Cow; use std::mem::size_of; use swf::{GradientSpread, Twips}; use wgpu::util::DeviceExt; macro_rules! create_debug_label { ($($arg:tt)*) => ( if cfg!(feature = "render_debug_labels") { ...
true
52594dcf35e579e0b22c41097f6229f9cf018f1b
Rust
pcein/rust-gecskp
/examples/all/8.rs
UTF-8
179
2.75
3
[]
no_license
/* assertions */ fn is_delta_one(x: i32, y: i32) -> bool { (x - y) == 1 } fn main() { assert_eq!(is_delta_one(11, 10), true); println!("\ntest passed\n"); }
true
c6114825471a46d14b5e2ee92c1e2f61737d4c79
Rust
gregoryg/csv_parser
/src/bin/src/main.rs
UTF-8
672
2.625
3
[]
no_license
//! This is the binary to run the actual server //! //! # To Use //! //! from the root directory, run: //! //! ```bash //! cargo run //! ``` #![warn(missing_docs)] #![warn(clippy::all)] #![warn(rustdoc)] #![warn(rust_2018_idioms)] #[macro_use] extern crate log; use std::sync::Arc; use config::Config; use server::ap...
true
333d7e337d33f06f406585477097cb67b804e653
Rust
philipstears/osc
/osc-fat/src/support.rs
UTF-8
803
2.640625
3
[]
no_license
use core::convert::{AsRef, TryInto}; use core::ops::Range; mod cluster_walker; pub(crate) use cluster_walker::*; mod read_buffer; pub(crate) use read_buffer::*; pub(crate) type ByteRange = Range<usize>; pub(crate) trait DataStructure { fn range(&self, range: ByteRange) -> &[u8]; fn u8(&self, range: ByteRan...
true
a1b28114b9504c1de7999ffab89cd7bd882e8d59
Rust
matematikaadit/brainf
/src/generator.rs
UTF-8
1,248
3.46875
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::Display; pub enum Instr { Add(u8), Sub(u8), Next(usize), Prev(usize), Get, Put, Open, Close, } pub impl Display for Instr { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { Instr::Add(n) => { for ...
true
5c610e51bf970c4060d210a00d39f9c43fd4e2a6
Rust
stevelorenz/programming-playground
/language/rust/programming_rust/fern_sim/src/simulation.rs
UTF-8
766
2.578125
3
[]
no_license
#![allow(unused_variables, unused_imports, dead_code)] use crate::plant_structure::{Fern, FernType}; use std::fs::File; use std::time::Duration; pub struct Terrarium { ferns: Vec<Fern>, } impl Terrarium { pub fn new() -> Terrarium { return Terrarium { ferns: vec![] }; } pub fn load(filename:...
true
ea312801f6080d2a7271e5d8d9187009e35a48ad
Rust
trustwallet/wallet-core
/codegen-v2/src/codegen/swift/render.rs
UTF-8
7,645
2.625
3
[ "BSD-3-Clause", "LicenseRef-scancode-protobuf", "LGPL-2.1-only", "Swift-exception", "MIT", "BSL-1.0", "Apache-2.0" ]
permissive
// Copyright © 2017-2023 Trust Wallet. // // This file is part of Trust. The full Trust copyright notice, including // terms governing use, modification, and redistribution, is contained in the // file LICENSE at the root of the source code distribution tree. use super::{inits::process_deinits, *}; #[derive(Debug, Cl...
true
d82ffdb8eb6977c78850b2bfa7c58750f26593d5
Rust
vihu/fountain
/src/droplet.rs
UTF-8
602
3.09375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[derive(Debug)] pub enum DropType { /// First is seed, second degree Seeded(u64, usize), /// Just a list of edges Edges(usize), } /// A Droplet is created by the Encoder. #[derive(Debug)] pub struct Droplet { /// The droptype can be based on seed or a list of edges pub droptype: DropType, ...
true
5bfd26ff290df1a2121e2d37d574e5a6810d1292
Rust
keeeal/seance
/src/ghost.rs
UTF-8
2,303
2.609375
3
[]
no_license
use bevy::prelude::{ Plugin, Res, Transform, Input, MouseButton, AppBuilder, Entity, Vec3, Query, With, EventWriter, Time, IntoSystem, }; use bevy_interact_2d::{InteractionPlugin, InteractionState}; pub struct Clickable; pub struct MoveTo { target: Option<(Entity, Vec3)>, vel: f32, interact_radius...
true
ceaef55d97e8e8a0867f41fc100da66650f74259
Rust
isgasho/galangua
/src/sdl/sdl_renderer.rs
UTF-8
5,344
2.765625
3
[ "MIT" ]
permissive
use sdl2::pixels::Color; use sdl2::rect::{Point, Rect}; use sdl2::render::WindowCanvas; use std::collections::HashMap; use galangua_common::framework::sprite_sheet::SpriteSheet; use galangua_common::framework::types::Vec2I; use galangua_common::framework::RendererTrait; use super::sdl_texture_manager::SdlTextureManag...
true
f9d1c7a5742afc3308d7b1c85e5d3b7c031ff9a1
Rust
Mesoptier/advent-of-code-2020
/src/bin/day19.rs
UTF-8
3,819
3.03125
3
[]
no_license
use std::collections::HashMap; use std::fmt::Debug; use std::fs::File; use std::io::Read; use std::str::FromStr; use nom::IResult; use nom::branch::alt; use nom::bytes::complete::tag; use nom::character::complete::{alpha1, anychar, digit1, line_ending}; use nom::combinator::{all_consuming, map, value}; use nom::multi:...
true
6ef99d3c448d5645a38cdb8233dcbdc8a6d9ce80
Rust
rysiekblah/Rust
/src/graphs/adj_mx.rs
UTF-8
4,422
3.4375
3
[ "MIT" ]
permissive
use std::fmt; use std::fmt::{Formatter, Error}; #[derive(Debug)] pub struct Mx { _arr: Vec<Row> } #[derive(Debug)] pub struct Row { _arr: Vec<usize> } pub fn new(v: usize) -> Mx { let mut mx = Vec::with_capacity(v); for ix in 0..v { mx.insert(ix, Row{_arr:Vec::new()}); } Mx { ...
true
8f1566fd9f5c3b2a4e40d3fd6fe8cbd13d4ff800
Rust
tramulns/rust-cookbook
/file/dir/png/src/main.rs
UTF-8
290
2.6875
3
[]
no_license
/// Найти рекурсивно все png файлы use glob::glob; type Error = Box<dyn std::error::Error>; type Result<T> = std::result::Result<T, Error>; fn main() -> Result<()> { for entry in glob("**/*.png")? { println!("{}", entry?.display()); } Ok(()) }
true
0ffbbe9d8752d78fba1e7e5a632dcb127e4c7114
Rust
vbarrielle/aaacs
/src/main.rs
UTF-8
1,769
2.703125
3
[]
no_license
use std::error::Error; use aaacs::accounts::ParsedAccounts; use aaacs::gui_iced; use structopt::StructOpt; /// Automated Accurate Accounting Collaborative System /// /// A simple application to handle accounts between friends #[derive(StructOpt, Debug)] #[structopt(name = "aaacs")] struct Args { /// If present on...
true
3ee75c2e8a36b8d86d51f7eb83cada26ab3f9401
Rust
svmk/rust-sitemap
/src/reader.rs
UTF-8
4,896
3.359375
3
[ "MIT" ]
permissive
//! Contains sitemap reader. //! //! # Examples //! //! Reading sitemap from file. //! //! ```rust //! use sitemap::reader::{SiteMapReader,SiteMapEntity}; //! use std::fs::File; //! fn main() { //! let mut urls = Vec::new(); //! let mut sitemaps = Vec::new(); //! let mut errors = Vec::new(); //! let file = File::...
true
7ad014e5d16d0f0d7713d74e143f179462441042
Rust
PaulDebus/aurelius
/src/http.rs
UTF-8
4,146
3.203125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Contains the HTTP server component. use std::collections::HashMap; use std::fs; use std::io; use std::net::{SocketAddr, ToSocketAddrs}; use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use porthole; use nickel::{self, Nickel, StaticFilesHandler}; use markdown; /// The HTTP server. /// /// The server...
true
0d3e7a899c7a44d174fd101e6d33b331296593eb
Rust
museun/readchat
/src/window.rs
UTF-8
8,557
2.796875
3
[ "Unlicense" ]
permissive
use crate::App; use super::{partition, queue::Queue, truncate}; use std::{borrow::Cow, io::Write}; use crossterm::{ cursor::*, style::*, terminal::{self, *}, }; use twitchchat::{messages::Privmsg, twitch::color::RGB}; use unicode_width::UnicodeWidthStr; // TODO make this configurable const MAX_COLUMN_WI...
true
4a5c7b21facaaa402c880decc4a217f1684c2b01
Rust
icub3d/puzzles
/leetcode/add-two-numbers/src/lib.rs
UTF-8
2,054
3.796875
4
[ "MIT" ]
permissive
#[derive(PartialEq, Eq, Clone, Debug)] pub struct ListNode { pub val: i32, pub next: Option<Box<ListNode>>, } pub struct Solution; impl Solution { pub fn add_two_numbers( l1: Option<Box<ListNode>>, l2: Option<Box<ListNode>>, ) -> Option<Box<ListNode>> { let mut head = ListNode ...
true
41ec3c33cf9afa64fe339f23b48849ab2cc68d82
Rust
ZoeyR/nestor
/rustybot/src/database/models.rs
UTF-8
5,715
2.546875
3
[ "Apache-2.0", "MIT" ]
permissive
use std::io::Write; use std::str::FromStr; use super::import_models::RFactoid; use super::schema::factoids; use super::schema::qotd; use super::schema::winerrors; use anyhow::{anyhow, Error, Result}; use chrono::naive::NaiveDateTime; use diesel::backend::Backend; use diesel::deserialize::{self, FromSql}; use diesel::...
true
976b37bd0b8ec999cb9aee64c83496af210f5429
Rust
Napokue/psx-rs
/src/cpu.rs
UTF-8
638
2.828125
3
[ "MIT" ]
permissive
use crate::system::System; // Start address of BIOS const PC_RESET_VALUE: u32 = 0xBFC00000; pub struct Cpu { pc: u32, system: System, } impl Cpu { pub fn new(system: System) -> Self { Cpu { pc: PC_RESET_VALUE, system, } } pub fn next_instruction(&mut self)...
true
934829a4f81a9dc99b6544880c80f239660d68fe
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_152/src/solution2.rs
UTF-8
1,114
3.109375
3
[ "MIT" ]
permissive
// dp[i][2] // dp[i][0] 表示从 0->i(包括第i个节点)的正的最大值。 // dp[i][1] 表示从 0->i(包括第i个节点)的负的最大值,也就是最小值。 // // dp[i][0] = // if (nums[i] >= 0) dp[i-1][0] * nums[i] // else dp[i-1][1] * nums[i] // // dp[i][1] = // if (nums[i] >= 0) dp[i-1][1] * nums[i] // else dp[i-1][0] * nums[1] // // result = max(dp[0][0], dp[1][0], ...,...
true
9e010088508f03d8403e4246d7f9d3786e78d71b
Rust
austinhartzheim/haptik
/src/models.rs
UTF-8
1,591
3.34375
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::errors::Error; use std::fmt::{self, Display}; use std::str::FromStr; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct AclEntry<T> { /// Element pointer within HAProxy. Forcing u64 instead of usize to allow running haptik on /// 32-bit machines when HAProxy pointers are 64-bits. pub id: u6...
true
e65805769a74bf972fdc2007a3aaedda57b7ea43
Rust
usagi/vec-dimension-shift
/src/lib.rs
UTF-8
13,043
3.21875
3
[ "MIT" ]
permissive
//! [![github]](https://github.com/usagi/vec-dimension-shift)&ensp;[![crates-io]](https://crates.io/crates/vec-dimension-shift)&ensp;[![docs-rs]](https://docs.rs/vec-dimension-shift)<br> //! [![Build Status](https://travis-ci.org/usagi/vec-dimension-shift.svg?branch=master)](https://travis-ci.org/usagi/vec-dimension-sh...
true
c8e112d1e65a6ae0050cf8731fefd3c3179bd0f0
Rust
1ndevelopment/pipr
/src/app/key_select_menu.rs
UTF-8
379
3.296875
3
[ "MIT" ]
permissive
pub struct KeySelectMenu<T> { options: Vec<(char, String)>, pub menu_type: T, } impl<T> KeySelectMenu<T> { pub fn new(options: Vec<(char, String)>, menu_type: T) -> Self { Self { options, menu_type } } pub fn option_list_strings(&self) -> impl Iterator<Item = String> + '_ { self.op...
true
79913f764f3ae61a87faf1d82e6bf9c1979edf48
Rust
r3lik/code_samples
/rust/rust-book/loops/src/main.rs
UTF-8
1,203
4.21875
4
[]
no_license
fn main() { let mut count = 0; 'counting_up: loop { println!("count = {}", count); let mut remaining = 10; loop { println!("remaining = {}", remaining); if remaining == 9 { break; } if count == 2 { break 'co...
true
93bd5a7d40f2271dec16237bcbb03efab9ea8011
Rust
hurwitzlab/gbme
/run_gbme/src/main.rs
UTF-8
504
2.578125
3
[ "MIT" ]
permissive
extern crate run_gbme; use std::process; fn main() { let config = run_gbme::get_args().expect("Could not get arguments"); // match run_gbme::run(config) { // Err(e) => { // println!("Error: {}", e); // process::exit(1); // } // Ok(out_di...
true
b1e50e469888990d1e3b7f6da2735275c2b0fa63
Rust
dignifiedquire/num-bigint
/src/algorithms/sub.rs
UTF-8
3,351
2.84375
3
[ "MIT", "LGPL-3.0-or-later", "Apache-2.0" ]
permissive
use core::cmp; use core::cmp::Ordering::*; use num_traits::Zero; use smallvec::SmallVec; use crate::algorithms::cmp_slice; use crate::big_digit::{BigDigit, SignedDoubleBigDigit, BITS}; use crate::bigint::Sign::{self, *}; use crate::{BigUint, VEC_SIZE}; /// Subtract with borrow: #[inline] pub fn sbb(a: BigDigit, b: B...
true
1a4f6eece4e7f1d51931daf441773fb1496fb923
Rust
marck0z/AdventOfCode_2020
/src/puzzle8.rs
UTF-8
4,398
3.5
4
[]
no_license
use std::convert::TryFrom; use std::fs; #[derive(Debug)] struct Instruction { name: String, val: i32, } #[allow(dead_code)] pub(crate) fn solution() -> i32 { let input = fs::read_to_string("./input/8.txt").unwrap(); let instructions: Vec<Instruction> = input .lines() .map(|l| { ...
true
7f9edf1f8bac364f827da9819631b8d711834798
Rust
astro/rust-lpc43xx
/src/c_can1/cntl/mod.rs
UTF-8
26,022
2.953125
3
[ "Apache-2.0" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::CNTL { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut ...
true