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
586b8f302d645a13f463a976f580515cc2c825f6
Rust
harpiechoise/ArithmeticParser
/src/parsemath/token.rs
UTF-8
2,854
4
4
[]
no_license
use std::cmp::PartialEq; /// The Token struct holds the token type for a specific symbol or number #[derive(Debug, PartialEq, Clone)] pub enum Token { ADD, SUBTRACT, MULTIPLY, DIVIDE, CARET, LEFTPAREN, RIGHTPAREN, NUM(f64), // If the value is numeric we store the number in an Enum Varia...
true
c6462c935fe9af651cfc2147788c53b66670a251
Rust
Txuritan/rewryte
/rewryte-generator/src/mysql.rs
UTF-8
1,260
2.59375
3
[ "MIT", "Apache-2.0" ]
permissive
use { crate::Error, rewryte_parser::models::{Column, ColumnDefault, Enum, ForeignKey, Item, Schema, Table, Types}, std::io, }; pub fn write_schema(schema: &Schema, writer: &mut impl io::Write) -> Result<(), Error> { for item in &schema.items { write_item(item, writer)?; writeln!(writer...
true
fc5aded2c8d78c6fc37726b87877b5735e4216f9
Rust
JoshCheek/nushell
/crates/nu-serde/src/test.rs
UTF-8
1,127
2.96875
3
[ "MIT" ]
permissive
use crate::{to_success_return_values, to_value}; use insta::assert_debug_snapshot; use nu_source::Tag; use serde::Serialize; use std::collections::BTreeMap; #[test] fn it_works_with_single_integers() { assert_debug_snapshot!(to_value(&4i32, Tag::default())); } #[test] fn it_works_with_lists_of_values() { asse...
true
0912017f0bc53890fa657e11bcf480b2645149d9
Rust
zhanpon/atcoder
/rust/src/bin/abc167_a.rs
UTF-8
185
3.015625
3
[]
no_license
use proconio::input; fn main() { input! { s: String, t: String, } let answer = if t.starts_with(&s) { "Yes" } else { "No" }; println!("{}", answer); }
true
38a8f00f39e25739636d5ca79fa395623046bf3e
Rust
yongkyuns/noon_egui
/src/data/mod.rs
UTF-8
12,525
3.578125
4
[]
no_license
use std::{ cell::{Ref, RefCell}, ops::RangeInclusive, rc::Rc, }; pub type Time = f32; use crate::Pose; /// Aggregate of [`ColumnData`] that can only be added and not deleted. /// Length of all [`ColumnData`] are equal, making this effectively a 2D table. pub type DataSet<T = f32> = Vec<ColumnData<T>>; //...
true
902305ed81985c7ae147e62197d0fbf05ce371b5
Rust
datadevopscloud/fluvio
/src/spu-schema/src/server/stream_fetch.rs
UTF-8
9,716
2.734375
3
[ "Apache-2.0" ]
permissive
//! //! # Continuous Fetch //! //! Stream records to client //! use std::fmt::Debug; use std::marker::PhantomData; use std::io::{self, Read}; use std::borrow::Cow; use dataplane::core::{Encoder, Decoder}; use dataplane::api::Request; use dataplane::fetch::FetchablePartitionResponse; use dataplane::record::RecordSet; u...
true
34485704282c6663b80a30e2786909090cbf15ec
Rust
AngeloLupo/advent_of_code_2020
/src/day8/mod.rs
UTF-8
2,849
3.640625
4
[]
no_license
use std::fs; pub fn one(instruction_index: usize) -> (bool, i32) { let input = fs::read_to_string("src/day8/input").expect("Unable to read file"); let instructions: Vec<&str> = input.split("\n").collect(); let mut index: usize = 0; let mut accumulator: i32 = 0; let mut visited_indexes: Vec<usize...
true
d3ff4168fe568edc17a0d0349a079eadfdba5d3f
Rust
callym/vsop2013-rs
/src/planet_data.rs
UTF-8
1,014
2.8125
3
[]
no_license
use crate::{util::*, Error, Header}; use nom::character::complete::space0; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, Clone)] pub struct Table { pub start: f64, pub stop: f64, pub data: Vec<f64>, } impl Table { pub fn parse<'a>(header: &Header, input: &'a str) -> Error<'a, Se...
true
f98f6a4b522da357b300f335dac4935f374b5c8d
Rust
Baekalfen/BachelorProject
/rusqlite/src/named_params.rs
UTF-8
8,100
3.09375
3
[ "MIT" ]
permissive
use libc::c_int; use super::ffi; use {Result, Error, Connection, Statement, Rows, Row, str_to_cstring}; use types::ToSql; impl Connection { /// Convenience method to prepare and execute a single SQL statement with named parameter(s). /// /// On success, returns the number of rows that were changed or ins...
true
68fec9ba11d74275ca8c9ed36747fed27f5e3cc5
Rust
placrosse/cortex-m
/src/peripheral/nvic.rs
UTF-8
3,165
3.453125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Nested Vector Interrupt Controller use volatile_register::{RO, RW}; use interrupt::Nr; /// Register block #[repr(C)] pub struct RegisterBlock { /// Interrupt Set-Enable pub iser: [RW<u32>; 8], reserved0: [u32; 24], /// Interrupt Clear-Enable pub icer: [RW<u32>; 8], reserved1: [u32; 24], ...
true
9a201df698d5a5f383823b76ad2ba0a5b3768c21
Rust
dtolnay/star-history
/src/main.rs
UTF-8
16,636
2.59375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! [![github]](https://github.com/dtolnay/star-history)&ensp;[![crates-io]](https://crates.io/crates/star-history)&ensp;[![docs-rs]](https://docs.rs/star-history) //! //! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github //! [crates-io]: https://img.shields.io/badge...
true
739feb43801f61c210f69d96ca9b97a99c5d9563
Rust
binh-vu/semantic-modeling
/mira/src/assembling/other_models/bayes_model.rs
UTF-8
2,626
2.640625
3
[ "MIT" ]
permissive
use utils::dict_get; use rayon::prelude::*; use assembling::features::statistic::Statistic; use assembling::models::annotator::Annotator; use std::collections::HashMap; use algorithm::data_structure::graph::*; pub struct BayesModel<'a> { stat: &'a Statistic, sm_index: &'a HashMap<String, usize>, stype_scor...
true
0b5ac5cd94ec76e25f14da9818ca856f07ab70a3
Rust
elrnv/buffer
/dyn-derive/src/lib.rs
UTF-8
25,353
2.828125
3
[ "MIT", "Apache-2.0" ]
permissive
use proc_macro2::{Span, TokenStream}; use quote::{quote, TokenStreamExt}; use std::collections::HashMap; use syn::parse::{Parse, ParseStream}; use syn::punctuated::Punctuated; use syn::*; type GenericsMap = HashMap<Ident, Punctuated<TypeParamBound, Token![+]>>; #[derive(Debug)] struct Config { dyn_crate_name: Str...
true
553910c0002abeb8eccc76182e06f6676a3a5292
Rust
dodok8/rust-programming-language
/ch4/slices/src/main.rs
UTF-8
827
3.84375
4
[]
no_license
fn main() { let mut s = String::from("hello world"); let word = fisrt_word(&s); //불변 참조 형성 -> 가변 참조가 형성될 수 없다. s.clear(); // 따라서 가변 참조가 필요한 부분에 에러가 발생하게 된다. println!("{}", word); } fn fisrt_word(s: &String) -> &str { let bytes = s.as_bytes(); for (i, &item) in bytes.iter().enumerate() { ...
true
9c6deb71883a1e7cb851e2b36e0e40316870b725
Rust
Hugal31/yara-rust
/src/internals/object.rs
UTF-8
5,610
3.15625
3
[ "MIT", "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::ffi::CStr; use std::fmt::Debug; /// A value from a module. pub struct YrObject<'a>(&'a yara_sys::YR_OBJECT); impl Debug for YrObject<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt("YrObject", f) } } impl<'a> From<&'a yara_...
true
be7cb0983ebeb7ca2aa412fba016b9736bc88b00
Rust
Salpadding/tiny-wasm
/src/types/offset.rs
UTF-8
608
2.734375
3
[]
no_license
const STACK_BASE_MASK: u64 = 0x7fffffff; const STACK_BASE_SHIFTS: u32 = 0; const LABEL_BASE_MASK: u64 = 0x7fffffff00000000; const LABEL_BASE_SHIFTS: u32 = 32; #[derive(Clone, Copy, Default)] pub(crate) struct Offset(u64); impl Offset { pub(crate) fn label_base(&self) -> u32 { ((self.0 & LABEL_BASE_MASK) >...
true
b65aea73a58c219644076325ede30ef8057ff251
Rust
MSDimos/leetcode-rust2018
/Q39-combination-sum/src/lib.rs
UTF-8
1,204
3.578125
4
[ "MIT" ]
permissive
pub struct Solution; impl Solution { pub fn combination_sum(mut candidates: Vec<i32>, target: i32) -> Vec<Vec<i32>> { let mut result = vec![]; candidates.sort(); Solution::back(&candidates, 0, target, &mut vec![], &mut result); result } pub fn back( candidates: &Ve...
true
827d8678bf21a2f76f748a95a5b746a84b090849
Rust
eatrero/rust_ray_tracer
/src/shape/sphere.rs
UTF-8
7,291
3.1875
3
[]
no_license
use crate::colors::Color; use crate::intersections::{Intersection, Intersections}; use crate::material::Material; use crate::matrix::Matrix; use crate::ray::Ray; use crate::shape::{Shape, ShapeType}; use crate::transform::Transform; use crate::vectors::{dot, point, vector, Tuple}; use rand::Rng; use std::f64; #[derive...
true
b8f7e861d184657de7e945633c7e99c9745dcc4c
Rust
o8vm/krabs
/src/bios/stage_3rd/src/init/vid.rs
UTF-8
718
2.546875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use plankton::mem::MemoryRegion; pub fn set_screen_info() { let zero_page = MemoryRegion::new(0x000, 4096); let mode: u8; let page: u8; unsafe { llvm_asm!("int $$0x10" : "={al}"(mode), "={bh}"(page) : "{ax}"(0x0f00), "{ebx}"(0) ); } zero_page.write_u8(0x004, p...
true
082968980d2e782e3898d7dabe8d3c7f7bd5df5c
Rust
mattjbray/rust-raytracing
/src/scene.rs
UTF-8
798
2.953125
3
[]
no_license
use super::ray::{Hit, Hittable, Ray}; pub struct Scene<'a> { objects: Vec<&'a (dyn Hittable)>, } impl<'a> Scene<'a> { pub fn new() -> Self { Self { objects: Vec::new(), } } pub fn add(&mut self, o: &'a (dyn Hittable)) { self.objects.push(o) } } impl<'a> Hittab...
true
59b12cd569fad51606d66de2dea41d6e0dcc077c
Rust
s-petersson/RIP-8
/src/opcodes.rs
UTF-8
8,790
3.015625
3
[]
no_license
#[derive(Debug, Clone, PartialEq)] pub enum Instruction { SysAddressJump_0x0NNN, // Jump to address NNN ClearDisplay_0x00E0, // Clear the display RetFromSubroutine_0x00EE, // Return from Subroutine JumpLocation_0x1NNN, // Jump to address: Set PC to 0xNNN CallSubr...
true
86860beecad950c0b588a352bfa61a21c6b9857e
Rust
oberblastmeister/bulk-rename
/src/filesystem.rs
UTF-8
4,235
3.390625
3
[]
no_license
use std::fs; use std::path::{Path, PathBuf}; use anyhow::{bail, Context, Result}; use rayon::prelude::*; use crate::errors::{anyhow_multiple, print_error}; /// Gets a string representation of the paths in the specified directory. pub fn get_string_paths(dir: impl AsRef<Path>, allow_hidden: bool) -> Result<Vec<String...
true
de098db697e6a150b1846fc7d46b16784fc6796b
Rust
Hirevo/async-broadcast
/src/lib.rs
UTF-8
12,702
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Async broadcast channels //! //! # Examples //! //! ``` //! // tbi //! ``` #![forbid(unsafe_code, future_incompatible, rust_2018_idioms)] #![deny(missing_debug_implementations, nonstandard_style)] #![warn(missing_docs, missing_doc_code_examples, unreachable_pub)] use std::collections::VecDeque; use std::error; us...
true
84ea0b960465aa320bea9e47cde8ed467e71dde8
Rust
chipsenkbeil/over-there
/src/cli/opts/client/exec.rs
UTF-8
1,770
2.671875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use crate::cli::opts::parsers; use clap::Clap; use std::time::Duration; /// Executes a process on the server #[derive(Clap, Debug)] pub struct ExecCommand { /// The command to execute #[clap(parse(try_from_str))] pub command: String, /// The arguments for the command #[clap(parse(try_from_str))] ...
true
314e2f60b15da7b601415d49a6c6a309865acfc5
Rust
quote27/paperboids-rs
/src/boids.rs
UTF-8
2,053
2.859375
3
[]
no_license
extern crate cgmath; extern crate rand; use aabb::AABB; use cgmath::*; use rand::prelude::*; pub struct Boid { pub pos: Vector3<f32>, pub vel: Vector3<f32>, pub acc: Vector3<f32>, pub min_speed: f32, } impl Boid { pub fn random_new(bbox: &AABB) -> Boid { let mut rand = rand::thread_rng();...
true
408027b1a0a4f048162faaa6ce2dbeee5a24656d
Rust
dnseitz/CortexM0Rust
/port/cortex-m0/src/peripheral/rcc/clock_control.rs
UTF-8
6,749
2.875
3
[ "MIT" ]
permissive
// peripheral/rcc/clock_control.rs // AltOSRust // // Created by Daniel Seitz on 11/30/16 //! This module handles the clock control register of the CRR use super::super::Register; pub mod clock_rate { static mut CLOCK_RATE: u32 = 0; pub fn get_system_clock_rate() -> u32 { unsafe { CLOCK_RATE } ...
true
80f50032ec6876ea0690ee8034534ea8380d7150
Rust
BurntSushi/rust-analyzer
/crates/rust-analyzer/src/diagnostics.rs
UTF-8
2,780
2.9375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Book keeping for keeping diagnostics easily in sync with the client. use std::{collections::HashMap, sync::Arc}; use lsp_types::{CodeActionOrCommand, Diagnostic, Range}; use ra_ide::FileId; pub type CheckFixes = Arc<HashMap<FileId, Vec<Fix>>>; #[derive(Debug, Default, Clone)] pub struct DiagnosticCollection { ...
true
2be532e1a70ed45b9a1acf9c8eb5f04ea5237288
Rust
gwy15/leetcode
/src/62.不同路径.rs
UTF-8
789
2.84375
3
[]
no_license
/* * @lc app=leetcode.cn id=62 lang=rust * * [62] 不同路径 */ struct Solution; // @lc code=start impl Solution { pub fn unique_paths(m: i32, n: i32) -> i32 { let (m, n) = (m as usize, n as usize); let mut last = vec![0; m]; let mut row = vec![0; m]; row[0] = 1; for _i in 0..n...
true
3ed49141a9eddad26894e4e4142f750127a066b5
Rust
tokio-rs/axum
/axum/src/extract/host.rs
UTF-8
5,404
3.109375
3
[ "MIT" ]
permissive
use super::{ rejection::{FailedToResolveHost, HostRejection}, FromRequestParts, }; use async_trait::async_trait; use http::{ header::{HeaderMap, FORWARDED}, request::Parts, }; const X_FORWARDED_HOST_HEADER_KEY: &str = "X-Forwarded-Host"; /// Extractor that resolves the hostname of the request. /// ///...
true
7a8c3810baca685c33e4fff89c970a7d50886674
Rust
agam/Cavegen
/src/main.rs
UTF-8
5,644
3.0625
3
[]
no_license
// A "translation" from https://bitbucket.org/agambrahma/caves/ use array2d::Array2D; use rand::Rng; #[derive(Debug, Clone, Copy)] enum Cell { Space, Wall } #[derive(Debug, Clone, Copy)] struct Params { r1_cutoff: u8, r2_cutoff: Option<i8> } const NUM_ROWS: usize = 10; const NUM_COLS: usize = 20; c...
true
8602906fc3069885fbc916058616bbd0f4e84aea
Rust
jaredwolff/serde_arrays
/src/lib.rs
UTF-8
8,091
3.28125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2021 Travis Veazey // // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or // https://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or // https://opensource.org/licenses/MIT>, at your option. This file may not be // copied, modified, or distributed except according to th...
true
8b111b34d76a3b9e906495bc260140b161fb7016
Rust
Pe6oProgramista/rusty-brain
/src/utils.rs
UTF-8
1,791
2.53125
3
[ "MIT" ]
permissive
use ndarray::prelude::*; use gnuplot::*; use gnuplot::Axis as gpAxis; pub fn max_arr1(array: &ArrayView1<f64>) -> f64 { let mut max = array[0]; for a in array.iter() { if *a > max { max = *a; } } max } pub fn max_arr2(array: &ArrayView2<f64>) -> f64 { let mut max = arr...
true
c9700c52e1f32d44086b20f81c0e3cdee388c23d
Rust
EtomicBomb/picture_scout_rust
/src/parse/target_mesh.rs
UTF-8
7,731
2.84375
3
[]
no_license
use std::cmp::{max, min, Reverse}; use crate::parse::boolean_matrix::BooleanMatrix; use crate::parse::image::{Image, Color}; use crate::parse::target::Target; use ordered_float::OrderedFloat; #[derive(Debug)] pub struct TargetMesh { pub targets: Vec<Target>, // coordinates stored are between 0 and 1 as height p...
true
95993b2010a1d6cc2996b8ac81cedc31f51b5410
Rust
JoshGendein/rust-git
/src/commit.rs
UTF-8
3,477
3.078125
3
[]
no_license
use super::file::FileService; use super::types::{ Tree, Commit }; use super::error::Error; use super::index::Index; use std::collections::{ BTreeMap, HashMap, HashSet }; pub fn commit() -> Result<(), Error> { let file_service = FileService::new()?; let index = Index::new(&file_service.root_dir)?; let fi...
true
b821e60ff37cb995e980b6b1aa7b251f7636c339
Rust
embed-rs/embedded-rs
/src/components/gpio/stm32f7/output_data.rs
UTF-8
443
3.109375
3
[]
no_license
//! port output data register (GPIOx_ODR) use super::Pin; use bit_field::BitField; /// Register #[derive(Clone, Copy)] pub struct OutputDataRegister(BitField<u32>); #[allow(dead_code)] impl OutputDataRegister { /// Get output pin pub fn get(&self, pin: Pin) -> bool { self.0.get_bit(pin as u8) } ...
true
55af9b47f5ae09e5a5fc785c89f8985812cf8421
Rust
vab9/advent-of-code-16-rust
/2/src/main.rs
UTF-8
1,487
3.75
4
[]
no_license
use std::io::prelude::*; use std::io::BufReader; use std::fs::File; fn main() { let mut b = Button { n: 5 }; let f = File::open("../input2.txt").unwrap(); let reader = BufReader::new(f); for line in reader.lines() { for c in line.unwrap().chars() { b.make_move(match c { ...
true
d2602d317003a2c828a1d0a16005087bce4c3501
Rust
jly36963/notes
/rs/web/gotham-example/src/main.rs
UTF-8
5,234
2.703125
3
[]
no_license
#[macro_use] extern crate gotham_derive; use gotham::handler::HandlerResult; use gotham::helpers::http::response::{create_empty_response, create_permanent_redirect, create_response}; use gotham::hyper::{body, Body, Response, StatusCode}; use gotham::router::builder::*; use gotham::router::Router; use gotham::state::{F...
true
3bbd6d3bbe9f41a928e49d82ed88dfa62e37cab1
Rust
jonhoo/left-right
/src/write.rs
UTF-8
24,994
3.0625
3
[ "Apache-2.0", "MIT" ]
permissive
use crate::read::ReadHandle; use crate::Absorb; use crate::sync::{fence, Arc, AtomicUsize, MutexGuard, Ordering}; use std::collections::VecDeque; use std::marker::PhantomData; use std::ops::DerefMut; use std::ptr::NonNull; #[cfg(test)] use std::sync::atomic::AtomicBool; use std::{fmt, thread}; /// A writer handle to ...
true
7a90666a9e8ddd1209649ccc0d787c16321f26bd
Rust
oxalica/statx-sys
/src/lib.rs
UTF-8
5,946
2.65625
3
[ "MIT" ]
permissive
//! # Bindings to `statx` syscall. //! //! Note that `statx()` was added to Linux in kernel 4.11 . //! //! # See also //! <http://man7.org/linux/man-pages/man2/statx.2.html> #![no_std] #![cfg(target_os = "linux")] #![deny(warnings)] use libc::syscall; use libc::{c_char, c_int, c_uint}; /// Timestamp structure for the...
true
5c1afe4f00b1e47b081d9e216560acacef0e9064
Rust
LaplaceKorea/sml-compiler
/crates/sml-frontend/src/parser/mod.rs
UTF-8
7,845
3.078125
3
[ "MIT" ]
permissive
use super::ast::*; use super::lexer::Lexer; use super::tokens::*; use sml_util::diagnostics::Diagnostic; use sml_util::interner::*; use sml_util::span::{Span, Spanned}; use sml_util::Const; use std::iter::Peekable; mod decls; mod exprs; mod pats; pub mod precedence; mod types; pub struct Parser<'s, 'sym> { tokens:...
true
e6798e7676e3f73c78f90ee82b76552503a3626f
Rust
GaloisInc/mir-verifier
/lib/liballoc/tests/btree/map.rs
UTF-8
35,914
2.9375
3
[]
permissive
use std::collections::btree_map::Entry::{Occupied, Vacant}; use std::collections::BTreeMap; use std::convert::TryFrom; use std::fmt::Debug; use std::iter::FromIterator; use std::ops::Bound::{self, Excluded, Included, Unbounded}; use std::ops::RangeBounds; use std::panic::catch_unwind; use std::rc::Rc; use std::sync::at...
true
73ae65c42a240644d8170dec3b515cfe0cb1bf2d
Rust
mislav-markovic/advent-of-code
/aoc-19/src/input_reader.rs
UTF-8
1,079
3.328125
3
[]
no_license
pub fn read_sparated_values_from_input( path: &str, separator: &str, ) -> Result<Vec<String>, ReaderError> { use std::fs; let contents = fs::read_to_string(path) .map_err(|_| ReaderError {}) .map(|text| text.split(separator).map(|s| String::from(s)).collect()); contents } pub trai...
true
3e5e3a48a75c71f270f08b459bfb0340a6ee7670
Rust
troyunverdruss/advent-of-code-2020
/src/day10.rs
UTF-8
3,738
3.171875
3
[]
no_license
use crate::util::inputs::day_input; use itertools::Itertools; use std::collections::HashMap; pub fn run() { let adapters = day_input(10) .iter() .map(|s| s.parse::<i32>().unwrap()) .sorted() .collect::<Vec<i32>>(); let part1 = part_1(&adapters); println!("Part 1: {}", part1...
true
229c356d05f5b1439e59d57a0a33aa8281213234
Rust
redox-os/termion
/src/screen.rs
UTF-8
2,707
3.75
4
[ "MIT" ]
permissive
//! Managing switching between main and alternate screen buffers. //! //! Note that this implementation uses xterm's new escape sequences for screen switching and thus //! only works for xterm compatible terminals (which should be most terminals nowadays). //! //! # Example //! //! ```rust //! use termion::screen::Into...
true
93483bc6c5882d376f1c5cf0ace8b7b6c5cd48de
Rust
vegaluisjose/toml-example
/src/main.rs
UTF-8
446
2.6875
3
[]
no_license
// extern crate serde; // #[macro_use] // extern crate serde_derive; // extern crate toml; use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize, PartialEq)] #[serde(tag = "type", content = "args")] enum Actions { Wait(usize), Move { x: usize, y: usize }, } fn main() { println!("{}"...
true
09760ebfb008d73be3644062f7420a77a6dfbe0a
Rust
FauxFaux/tempfile-fast-rs
/tests/sponge.rs
UTF-8
960
2.90625
3
[ "MIT" ]
permissive
use std::fs; use std::io; use std::io::Read; use std::io::Write; #[test] fn sponge() -> Result<(), io::Error> { let dir = tempfile::TempDir::new()?; let mut test_path = dir.path().to_path_buf(); { test_path.push("hello"); fs::create_dir_all(&test_path)?; test_path.push("world.txt");...
true
665e5116f0d644ca5eeb1cb9463a4cf26ae7efff
Rust
pacheco/sevent
/src/chan.rs
UTF-8
1,650
2.875
3
[]
no_license
use std::io; use std::cell::RefCell; use std::sync::mpsc::TryRecvError; use mio::Ready; use mio::Poll; use mio_more::channel; use ::TokenKind; // we need the trait because we want to be able to store channels of any T. pub trait Chan { fn id(&self) -> usize; fn ready(&self, ready: Ready); fn deregister(...
true
08cfb3f129191cb9f1a545aac722d72509fa60d0
Rust
pd0wm/exercises
/advent_of_code_2022/src/bin/13.rs
UTF-8
4,098
3.296875
3
[]
no_license
#![feature(test)] use std::cmp::Ordering; use bisection::bisect_left; extern crate test; #[derive(Debug, Eq, PartialEq, Clone)] enum Packet { Int(u64), List(Vec<Packet>), } impl From<&str> for Packet { fn from(packet: &str) -> Self { if packet.starts_with('[') { let mut packets = Vec...
true
306fac27dbd8151d1f6fdea2605ce4c519e5a42a
Rust
Setheum-Labs/scale-info
/src/form.rs
UTF-8
2,869
2.796875
3
[ "Apache-2.0" ]
permissive
// Copyright 2019-2020 Parity Technologies (UK) Ltd. // // 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 applicab...
true
5e3209a7eafd58b94a04d59d7ea05e5f6fea2825
Rust
NyxTo/Advent-of-Code
/2019/Code/day6_orbit.rs
UTF-8
1,313
3.21875
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::collections::HashMap; fn dfs(directs: &HashMap<String, Vec<String>>, ctr: &str, dist_com: i32) -> (i32, i32, i32) { let (mut tot_com, mut dist_you, mut dist_san) = (dist_com, -1, -1); if let Some(orbits) = directs.get(ctr) { for arnd in orbits {...
true
433ff5f1bec0d6d102bd8d5d46df6578a9ec956c
Rust
srijs/rust-cfn
/src/aws/ses.rs
UTF-8
99,222
3.125
3
[ "MIT" ]
permissive
//! Types for the `SES` service. /// The [`AWS::SES::ConfigurationSet`](http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ses-configurationset.html) resource type. #[derive(Debug, Default)] pub struct ConfigurationSet { properties: ConfigurationSetProperties } /// Properties for the `Conf...
true
68052910a79955b3f377fcaf0d91272b0469cfb4
Rust
SkyMomentum/tonegen-rs
/src/wavfile/util.rs
UTF-8
2,639
3.625
4
[]
no_license
/// Transmute and copy to u8 array. /// /// # Unsafe /// Forces $targ to be represented as an arry of u8. $num_bytes is assumed to be the number of /// bytes $targ occupies. $num_bytes must also be the same size as the $outbuf used. First param /// is just for readability at use site. /// #[macro_export] macro_rules! ...
true
0c7ab5eddcb2e5bf948478632273bd3dfdbb8c91
Rust
LeJane/rust
/v1/src/postgresql_db_contexts/quests_attribute_assets.rs
UTF-8
3,320
2.53125
3
[]
no_license
use crate::models::quests_attribute_assets::QuestsAttributeAsset; use crate::schema::quests_attribute_assets; use diesel::prelude::*; use crate::{utils::binary_read_helper::*, BinaryDecode, BinaryEncode}; use anyhow::Result; use std::io::Cursor; use crate::{ FrontDisplayMetaVersion, FrontDisplayMetaVersionRelation...
true
c2ff2bcf005e4e64e81645ae4d4c1643b75e0911
Rust
saethlin/bloomset
/src/lib.rs
UTF-8
6,439
3.296875
3
[ "MIT" ]
permissive
//! A set-like data structure that is the same size as a `HashSet<T>` but has faster best-case //! membership checks, because `x86_64` only supports 48 bits of address space. So we can embed a //! bloom filter in the 32 free bits between its capacity and length. #![warn(clippy::pedantic, clippy::nursery, clippy::restr...
true
7d27b03b95ab8abca739a288f1149569dd3aadfd
Rust
spacejam/demikernel
/src/rust/catnip/src/protocols/arp/options.rs
UTF-8
954
2.703125
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. use std::time::Duration; #[derive(Clone, Debug)] pub struct ArpOptions { pub cache_ttl: Duration, pub request_timeout: Duration, pub retry_count: usize, } impl Default for ArpOptions { fn default() -> Self { ArpOptions...
true
81ca19a099be553f6464861497c3c7df586f0b01
Rust
ajunlonglive/may_http
/examples/echo.rs
UTF-8
650
2.59375
3
[ "MIT", "Apache-2.0" ]
permissive
use std::io::{Read, Write}; use may_http::server::*; // test with: curl -v POST -d "asdfasdfasf" "http://127.0.0.1:8080/" // test with: curl -v POST --header "Transfer-Encoding: chunked" -d "hello chunk" "http://127.0.0.1:8080/" fn hello(mut req: Request, rsp: &mut Response) { let mut s = String::new(); req....
true
4543005b321660cab3d3853f256e48cfaf49cb75
Rust
regexident/RustUI
/src/view_components/widgets/scrollbar.rs
UTF-8
6,111
2.96875
3
[ "MIT" ]
permissive
extern crate sdl2; use sdl2::pixels::Color; use sdl2::rect::Rect; use sdl2::event::Event; use crate::view_components::{ViewComponent, IntoViewComponent}; use crate::backend::system::window::Window; use crate::colors; use crate::Orientation; use super::{Widget, WidgetState}; use super::Text; pub struct ScrollBar<T> {...
true
62f8ecd3926b265cfe5abb2de0b9b73e42b4f4c2
Rust
patahene/rrt
/src/hit.rs
UTF-8
1,161
3.109375
3
[]
no_license
use crate::material::MaterialKind; use crate::ray::Ray; use crate::vec3::Vec3; #[derive(Debug)] pub struct HitRecord { pub t: f32, pub p: Vec3, pub normal: Vec3, pub material: MaterialKind, } impl HitRecord { pub fn new(mt: MaterialKind) -> HitRecord { HitRecord { t: 0.0, ...
true
6b5496cabefb3a6cfbd5b709c64982b0c41245ef
Rust
untoldwind/t-rust-less
/daemon/build.rs
UTF-8
638
2.546875
3
[ "MIT" ]
permissive
use std::env; use std::fs; use std::process; use clap::Shell; #[path = "src/cli.rs"] mod cli; fn main() { let outdir = match env::var_os("OUT_DIR") { Some(outdir) => outdir, None => { eprintln!("OUT_DIR environment variable not defined."); process::exit(1); } }; fs::create_dir_all(&outd...
true
2d7d8232e39dde32ecd319b3e103e0094e6763a3
Rust
yoshitsugu/fdl
/src/note.rs
UTF-8
1,346
2.796875
3
[]
no_license
use crate::circle::Circle; #[derive(Clone)] pub struct Fdl { pub fun: bool, pub done: bool, pub learn: bool, } #[derive(Clone)] pub struct Note { pub description: String, pub fdl: Fdl, pub x: isize, pub y: isize, pub width: isize, pub height: isize, pub original_x: isize, p...
true
791e43c6e2a98f87df158151c8d82d7eb78e9c14
Rust
sanbox-irl/bit-bots
/src/serialization/serialized_entity.rs
UTF-8
10,321
2.609375
3
[]
no_license
use super::{ physics_components::*, prefab_system, ComponentBounds, ComponentDatabase, ConversantNPC, DrawRectangle, Entity, Follow, GraphNode, GridObject, Marker, Name, NonInspectableEntities, Player, PrefabMarker, ResourcesDatabase, SceneSwitcher, SerializableComponent, SingletonDatabase, SoundSource, Spr...
true
9a85ba518d91466e650f8c19bbadea3e0d627682
Rust
mcaveniathor/cathode
/src/mode.rs
UTF-8
10,698
2.984375
3
[]
no_license
use std::{io,process,str,thread,time}; use std::io::Error; use std::result::Result; use regex::Regex; use serde::{Serialize,Deserialize}; use crate::{fileio,util}; #[derive(Debug)] pub struct InputMode { width:String, height:String, rate:String, name:String, display:String, } impl InputMode { ...
true
cdae0c00a44b8ce67c06cea86a5293e3b6a64518
Rust
PaulJuliusMartinez/rust
/src/test/ui/cleanup-rvalue-scopes-cf.rs
UTF-8
994
2.640625
3
[ "MIT", "LicenseRef-scancode-other-permissive", "Apache-2.0", "BSD-3-Clause", "BSD-2-Clause", "NCSA" ]
permissive
// ignore-compare-mode-nll // Test that the borrow checker prevents pointers to temporaries // with statement lifetimes from escaping. use std::ops::Drop; static mut FLAGS: u64 = 0; struct Box<T> { f: T } struct AddFlags { bits: u64 } fn AddFlags(bits: u64) -> AddFlags { AddFlags { bits: bits } } fn arg(x: &A...
true
6e7a18c68109b18baaa2918981fd10420f3b44ce
Rust
chin0/llrl
/llrl0/src/tests/error_expectation.rs
UTF-8
8,924
2.671875
3
[]
permissive
use crate::prelude::*; use crate::sexp::matcher as m; use std::borrow::Cow; use std::collections::HashSet; #[derive(Debug)] pub(super) enum ErrorExpectation { Syntax, MacroExpansion(String), MultipleDeclarations(String), ConflictingExports(String), DuplicatedIdentifier(String), Unresolved(Strin...
true
36a4e9b9b57a5f9fe918c4df7ff03f8954ce3560
Rust
davethecanuck/rust-poly-logger
/src/log_formatter.rs
UTF-8
3,394
3.078125
3
[]
no_license
use strfmt::strfmt; use std::collections::HashMap; pub struct LogFormatter { // strftime format string timestamp_format: &'static str, // e.g. [{timestamp}] {level} [{path}] - {msg} msg_format: &'static str, // Flag to indicate we need to do more expensive // formatting with strfmt use_st...
true
18314c5ba17bac357e8f6d523151287608e6c301
Rust
JadenGeller/Advent2016
/src/dec4.rs
UTF-8
3,845
3.328125
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::{BufRead, BufReader}; use std::str::FromStr; use std::error::Error; use std::fmt; use std::process::exit; use std::collections::HashMap; use std::cmp::Ordering; #[allow(dead_code)] struct Room { name: String, id: i32, } #[derive(Debug)] enum ParseRoomError { InvalidFormat, ...
true
e40c186458cee81c1d3604db206ef39565bb3219
Rust
pointedGroup/openmls
/src/schedule/mod.rs
UTF-8
16,545
2.75
3
[ "MIT" ]
permissive
//! This module represents the key schedule as introduced in Section 8 of the //! MLS specification. The key schedule evolves in epochs, where in each epoch //! new key material is injected. //! //! The flow of the key schedule is as follows (from Section 8 of the MLS //! specification): //! //! ```text //! ...
true
6107ec3a46aedeef15682dd10eaabe85ca155393
Rust
oknozor/m1s2_compil
/src/token/to_token.rs
UTF-8
11,188
2.84375
3
[]
no_license
use std::collections::HashMap; use crate::ast::expression::Expression::*; use crate::ast::expression::*; use crate::ast::statement::Statement; use crate::ast::statement::Statement::*; use crate::token::token::*; use crate::token::token::Operator::*; use crate::token::token::Token::*; use crate::visitor::Visitor; use c...
true
6cc7859ef5f2c2c303c3d7878a12de15c2929a2a
Rust
NLnetLabs/rpki-rs
/src/repository/resources/set.rs
UTF-8
13,590
2.859375
3
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::convert::TryFrom; use std::fmt; use std::str::FromStr; #[cfg(feature = "serde")] use serde::{Deserialize, Serialize}; use crate::repository::resources::{AsResources, IpResources}; use crate::repository::Cert; use crate::repository::{ resources::{AsBlock, AsBlocks, AsBlocksBuilder, Ipv4Blocks, Ipv6Blocks}...
true
4c71f4993937418a6dd34a90e9ad72b1a67f6858
Rust
Drevoed/vector
/lib/tracing-metrics/examples/yak_shave.rs
UTF-8
2,138
2.53125
3
[ "Apache-2.0" ]
permissive
#[macro_use] extern crate tracing; extern crate hotmic; extern crate serde_json; extern crate tracing_env_logger; extern crate tracing_fmt; extern crate tracing_metrics; use hotmic::Receiver; use std::thread; fn shave(yak: usize) -> bool { trace_span!("shave", yak = yak).in_scope(|| { debug!( ...
true
2976119b7794cccc4aaadff716ad5987774a94b1
Rust
kellda/peripherals
/src/attributes/periph.rs
UTF-8
2,040
2.671875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! An example of where attributes get expanded in [`periph!`] macros //! //! Take a look at the source of this module to see the macro invocation used. crate::periph! { #[doc = "Nothing: only on peripheral struct"] Peripheral; #[doc = "Nothing: on `Register` and field of peripheral"] rw Register @ 0x0...
true
554c568cd356d0a587518247885f27b29498e778
Rust
Weltraumschaf/minivm
/src/frontend/lexer/number_lexer.rs
UTF-8
7,625
3.5
4
[]
no_license
use frontend::token::*; use frontend::lexer::SubLexer; use frontend::character_stream::CharacterStream; use frontend::character_helper::CharacterHelper; #[cfg(test)] use frontend::Position; /// Recognizes a number literal token. pub struct NumberLexer {} impl NumberLexer { pub fn new() -> NumberLexer { Nu...
true
31d21515948921dc6b01983b3d73971e9ef06131
Rust
doytsujin/dns-message-parser
/src/encode/encoder.rs
UTF-8
695
2.53125
3
[ "BSD-3-Clause" ]
permissive
use crate::{EncodeError, EncodeResult}; use bytes::BytesMut; use std::collections::HashMap; use std::convert::TryInto; pub(crate) struct Encoder { pub bytes: BytesMut, pub domain_name_index: HashMap<String, (u16, usize)>, } impl Encoder { #[inline] pub(super) fn get_offset(&self) -> EncodeResult<u16> ...
true
5c9a365ba00c1cffaac67d086deb8250b01fc897
Rust
tynes/rsd
/primitives/src/block.rs
UTF-8
1,270
2.984375
3
[]
no_license
use crate::BlockHeader; use crate::Transaction; use extended_primitives::Buffer; use handshake_protocol::encoding::{Decodable, DecodingError, Encodable}; /// A Handshake block, which is a collection of transactions with an attached /// proof of work. #[derive(PartialEq, Clone, Debug)] pub struct Block { /// The bl...
true
11226a7d073c3a815e81a5758ac97e99a1701972
Rust
juxd/aoc2020
/src/day12/mod.rs
UTF-8
3,688
3.4375
3
[]
no_license
use regex::Regex; #[derive(Debug, PartialEq, Eq)] enum Move { N(i32), S(i32), E(i32), W(i32), L(i32), R(i32), F(i32), } #[derive(Debug, PartialEq, Eq)] struct Ship { dir: i32, x: i32, y: i32, waypoint_x: i32, waypoint_y: i32, } impl Move { fn of_dir_and_value(dir: ...
true
0597dd547dff779aeb713367525ac7da7ec2685e
Rust
Its-its/pixel-circuits
/frontend/src/canvas/pixels/map.rs
UTF-8
3,983
2.703125
3
[]
no_license
use circuit_sim_common::{CellPos, Dimensions, NodeObjectSide}; use wasm_bindgen::JsValue; use web_sys::CanvasRenderingContext2d; use crate::Result; use crate::editor::{Node, ViewOptions}; use super::{PIXEL_NODE, PIXEL_OBJECT, PixelColor, PixelType}; // Used for rendering the object. #[derive(Debug)] pub struct P...
true
bb63b3decce87276831becc283cf37d91b1fc9a7
Rust
wotsushi/competitive-programming
/arc/061/d.rs
UTF-8
1,762
2.734375
3
[ "MIT" ]
permissive
#![allow(non_snake_case)] #![allow(unused_variables)] #![allow(dead_code)] fn main() { let (H, W, N): (i64, i64, usize) = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap(...
true
9ee5f150a8804e67407dfeeabe533e086bb9fa5a
Rust
mkeeter/advent-of-code
/2016/02/src/main.rs
UTF-8
1,464
3.25
3
[]
no_license
use std::collections::HashMap; use std::io::Read; fn main() { let mut input = String::new(); std::io::stdin().read_to_string(&mut input).unwrap(); let run = |keypad: &str| { let mut keys: HashMap<(i32, i32), char> = HashMap::new(); let mut pos = (0, 0); for (y, line) in keypad.line...
true
abadf2cfcfb52ba86cfbc5e2f9ca709982941bef
Rust
cloudflare/lol-html
/src/transform_stream/dispatcher.rs
UTF-8
12,371
2.515625
3
[ "BSD-3-Clause", "CC-BY-SA-4.0" ]
permissive
use super::*; use crate::base::{Bytes, Range, SharedEncoding}; use crate::html::{LocalName, Namespace}; use crate::parser::{ Lexeme, LexemeSink, NonTagContentLexeme, ParserDirective, ParserOutputSink, TagHintSink, TagLexeme, TagTokenOutline, }; use crate::rewritable_units::{ DocumentEnd, Serialize, ToToken,...
true
e889becba0c817d88f245f1aa56e70f1adfcb1eb
Rust
SilvanCodes/novel-set-neat
/src/utility/gym.rs
UTF-8
1,924
2.875
3
[]
no_license
use gym::State; use ndarray::{stack, Array1, Array2, ArrayView1, ArrayView2, ArrayViewMut1, Axis}; use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Deserialize, Serialize)] pub struct StandardScaler { means: Array1<f64>, standard_deviations: Array1<f64>, } impl StandardScaler { pub fn for_envir...
true
939a072f0a0cc07326e837584456a45e96f0fa59
Rust
gmalmquist/arose
/src/utils.rs
UTF-8
1,690
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
use chrono; use js_sys::Math::{exp, sqrt, pow, log2}; use wasm_bindgen::__rt::core::f64::consts::PI; pub fn set_panic_hook() { // When the `console_error_panic_hook` feature is enabled, we can call the // `set_panic_hook` function at least once during initialization, and then // we will get better error me...
true
2cc21316c087bbfaea80bff6d19afe2ce16e5f96
Rust
torkeldanielsson/aoc2020
/day_13_a/src/main.rs
UTF-8
416
2.890625
3
[ "MIT" ]
permissive
fn main() { // let start_time= 939; // let buses = vec![7, 13, 59, 31, 19]; let start_time = 1001171; let buses = vec![17, 41, 37, 367, 19, 23, 29, 613, 13]; let mut n = start_time; 'outer: loop { for bus in &buses { if n % bus == 0 { println!("{}", (n - st...
true
0f8038f8348dca453b06c729231b506a6d295815
Rust
dahliaOS/fuchsia-pi4
/src/connectivity/lib/at-commands/codegen/src/definition.rs
UTF-8
2,927
2.703125
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2020 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 super::codegen::common::to_initial_capital; #[derive(Debug, Clone, PartialEq)] pub enum Definition { Command(Command), Response { name...
true
a268d30698e8ae056e03e6885f78ef35e506753a
Rust
DTFN/occlum
/demos/rust/rust_app/src/main.rs
UTF-8
660
3.046875
3
[ "BSD-3-Clause" ]
permissive
extern crate libc; use std::{time, thread}; use std::thread::sleep; use std::time::Duration; extern "C" { fn increment_by_one(input: *mut libc::c_int); } fn main() { let mut input = 5; let old = input; unsafe { increment_by_one(&mut input) }; println!("{} + 1 = {}", old, input); let mut numbe...
true
4e942ce687c614ca9b56cc6b7791f9d8e62cde4f
Rust
JuanFdS/advent-of-code-2020
/dia-2/src/main.rs
UTF-8
4,021
3.25
3
[]
no_license
use std::str::FromStr; use std::num::ParseIntError; fn main() { println!("Hello, world!"); } fn contrasenia_valida_segun_politica(minimo: i32, maximo: i32, letra: String, contrasenia: String) -> bool { let n = contrasenia.matches(&letra).count() as i32; return n >= minimo && n <= maximo } fn parsear_poli...
true
7c5f4ae8ecaf13b631b02ec0c824d0b2a7225eb9
Rust
jamesmarva/The-Rust-Programming-Language
/code/ch10/c_10_15/src/main.rs
UTF-8
311
3.28125
3
[]
no_license
fn main() { let v = vec![1, 2, 4, 5, 6]; let v1 = vec!['a', 'z', 'b', 'c', 'r', 't']; println!("largest: {}", larget(&v1)); } fn larget<T>(l: &[T]) -> T where T: PartialOrd + Copy { let mut rst = l[0]; for &i in l { if i > rst { rst = i; } } rst }
true
326dab541b957389b0669ba27daa2d92f5eadbe8
Rust
algesten/lolb
/src/limit.rs
UTF-8
2,411
2.828125
3
[]
no_license
use crate::{AsyncRead, AsyncWrite, LolbError}; use std::io; use std::pin::Pin; use std::task::{Context, Poll}; /// Helper to make an AsyncRead that reads up to a limit of bytes. pub(crate) struct LimitRead<S> where S: AsyncRead, { source: S, read: usize, limit: usize, } impl<S: AsyncRead> LimitRead<S>...
true
1de9f9118537a8daf52f712a085364b97256c714
Rust
SnakeSolid/rust-postgres-status
/src/handler/dropdb.rs
UTF-8
1,159
2.734375
3
[ "MIT" ]
permissive
use super::util::handle_request; use super::HandlerError; use crate::config::ConfigRef; use crate::postgres::PostgreSQL; use iron::middleware::Handler; use iron::IronResult; use iron::Request as IronRequest; use iron::Response as IronResponse; #[derive(Debug)] pub struct DropDbHandler { config: ConfigRef, } impl ...
true
c6b35d3eb54f33334c2503375b685e9249ffe201
Rust
fyang93/rust-leetcode
/src/p0036_valid_sudoku.rs
UTF-8
1,681
3.53125
4
[]
no_license
use std::collections::HashMap; pub fn is_valid_sudoku(board: Vec<Vec<char>>) -> bool { let mut rows = vec![HashMap::new(); 9]; let mut cols = vec![HashMap::new(); 9]; let mut boxes = vec![HashMap::new(); 9]; for i in 0..9 { for j in 0..9 { if let Some(num) = board[i][j].to_digit(10...
true
297bfb9be010519437a06afc27f4c2a857013603
Rust
1aim/state_machine_future
/tests/generics.rs
UTF-8
2,711
2.875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Test that we handle generics properly. //! //! Here's the deal: we don't figure out which generics are used in which //! variants, so it is up to you to add phantom datas as needed. #![feature(futures_api, pin, arbitrary_self_types)] extern crate futures; #[macro_use] extern crate state_machine_future; use future...
true
e45aae36fc34867492d26e1358b0c05a2cc89f0d
Rust
enso-org/enso
/app/gui/language/ast/impl/src/crumbs.rs
UTF-8
36,807
2.984375
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
//! Crumbs for AST. Crumb identifies children node location in AST node. The access should be //! possible in a constant time. use crate::prelude::*; use enso_text::index::*; use crate::enumerate_non_empty_lines; use crate::known; use crate::HasTokens; use crate::Shape; use crate::ShiftedVec1; use crate::SpanSeed; us...
true
591aed47a99d2d1a6d096179fd9d8457048db9ef
Rust
koute/yew
/src/services/storage.rs
UTF-8
2,137
3.46875
3
[ "MIT", "Apache-2.0" ]
permissive
//! This module contains the implementation of a service to //! use local and session storage of a browser. use stdweb::Value; use format::{Storable, Restorable}; /// Represents errors of a storage. #[derive(Debug, Fail)] enum StorageError { #[fail(display = "restore error")] CantRestore, } /// An area to ke...
true
f824a055d9afb1efcf1d8f36a54e9f965df7b9e2
Rust
jDomantas/ccg
/crates/engine/src/renderer.rs
UTF-8
4,568
2.671875
3
[]
no_license
use ggez::Context; use ggez::graphics::{DrawParam, Image, Rect, Color}; use ggez::nalgebra::Point2; use crate::{Ctx, CtxData, Result}; pub struct Renderer { icons: Image, textures: Vec<Image>, indices: Textures, } impl Renderer { pub fn new(icons: Image, textures: Vec<Image>, indices: Textures) -> Sel...
true
32d67f4836f6508c12683d98a1865541a32b1495
Rust
qti3e/ross
/ross_core/src/db/batch.rs
UTF-8
1,483
2.828125
3
[]
no_license
use super::DB; use super::{bincode::serialize, keys::DbWriteKey}; use crate::error::{Error, Result}; /// An atomic batch of write operations. This is a type safe wrapper around /// rocksdb::WriteBatch. pub struct Batch<'a> { db: &'a DB, batch: rocksdb::WriteBatch, } impl<'a> Batch<'a> { pub fn new(db: &'a...
true
c7f16274b4bb2c4980f521b93a97da2721f51d6b
Rust
gengjiawen/leetcode
/Array/_0888_fair_candy_swap.rs
UTF-8
2,307
3.734375
4
[]
no_license
// https://leetcode.com/problems/fair-candy-swap // // Alice and Bob have a different total number of candies. You are given two integer arrays `aliceSizes` and `bobSizes` where `aliceSizes[i]` is the number of candies of the `i<sup>th</sup>` box of candy that Alice has and `bobSizes[j]` is the number of candies of the...
true
ab99475dc781d845512672ad73a82bc0fbdf4a71
Rust
ufwt/SMB_Fuzzer
/src/fuzzing_lib/src/smb2/helper_functions/negotiate_context.rs
UTF-8
26,116
3.015625
3
[ "MIT" ]
permissive
//! This module describes the negotiate contexts. //! The SMB2_NEGOTIATE_CONTEXT structure is used by the SMB2 NEGOTIATE Request //! and the SMB2 NEGOTIATE Response to encode additional properties. //! The server MUST support receiving negotiate contexts in any order. use rand::{ distributions::{Distribution, Stan...
true
773f2346f39cc6106a93e63137729968e3321cfe
Rust
mankenavenkatesh/ibc-rs
/relayer/src/worker/handle.rs
UTF-8
2,754
2.6875
3
[ "Apache-2.0", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
use core::fmt; use std::thread::{self, JoinHandle}; use crossbeam_channel::Sender; use tracing::trace; use ibc::{ core::{ics02_client::events::NewBlock, ics24_host::identifier::ChainId}, events::IbcEvent, Height, }; use crate::{event::monitor::EventBatch, object::Object}; use super::error::WorkerError; ...
true
d4863e8802fe4b963cfa2a6ab46052a723718653
Rust
delaneyj/minigame-rust
/src/collider.rs
UTF-8
7,001
3.140625
3
[ "MIT" ]
permissive
extern crate cgmath; use rectangle::Rectangle; use self::cgmath::{InnerSpace, MetricSpace, Vector2}; use utils::{Clamp}; pub struct CircleCollider { radius: f32, origin: Vector2<f32>, } impl CircleCollider { pub fn new(radius: f32, origin: Vector2<f32>) -> Self { CircleCollider { radi...
true
b489e0a9428ad7b6a20dbc8bcc4edcf82a80104e
Rust
fossabot/fastobo
/fastobo/src/ast/mod.rs
UTF-8
8,192
2.8125
3
[ "MIT" ]
permissive
//! Owned syntax tree for the [OBO format version 1.4]. //! //! [`OboDoc`] is the struct acting as the root of the syntax tree. It can be //! created from a borrowed string slice with either [`FromStr::from_str`] or //! [`FromSlice::from_slice`], from a file with [`OboDoc::from_file`], or from //! a buffered reader wit...
true
76e279bd0bc6f78806e0c085f14f3bf6897747d8
Rust
slayfer-dev/Challenges-sol
/Programming/Codeabbey/012/CrazyCapitan.rs
UTF-8
1,327
2.921875
3
[]
no_license
//Author CrazyCapitan pub fn main() { let reader = std::io::stdin(); let mut count = String::new(); reader.read_line(&mut count).expect("Cloud not read your input"); for _ in 0..count.trim().parse::<i32>().unwrap() { let mut line = String::new(); reader.read_line(&mut line).expect("Cloud...
true