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
bc30531e7197a73a61756d80a89d2e2b37f36da4
Rust
asciiu/blackjack
/src/blackjack/shoe.rs
UTF-8
1,351
3.578125
4
[]
no_license
use rand::Rng; use std::fmt; const CARDS: [char; 13] = ['A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2']; const SUIT: [char; 4] = ['C', 'D', 'H', 'S']; #[derive(Debug)] pub struct Card { text: char, suit: char, } impl Card { pub fn new(text: char, suit: char) -> Card { Card{ text:...
true
cca9317006ba4d5f8a72ed14ebb92e0931aaeafd
Rust
pjoe/glslpp-rs
/src/pp.rs
UTF-8
43,888
2.875
3
[ "BSD-3-Clause" ]
permissive
use crate::lexer; use crate::lexer::Token as LexerToken; use crate::lexer::TokenValue as LexerTokenValue; use crate::token::*; use std::collections::{HashMap, HashSet}; use std::rc::Rc; #[derive(Clone, PartialEq, Debug)] struct Define { name: String, function_like: bool, params: HashMap<String, usize>, ...
true
f5d3af58c94208a882e2fd6de5a59b244bfbac22
Rust
asari555/tcmb_evds_c
/src/evds_c/date_entities.rs
UTF-8
4,933
3.421875
3
[ "MIT" ]
permissive
use crate::evds_c::common_entities::*; use crate::evds_c::error_handling::ReturnErrorC; use crate::traits::checking_string_character::CheckingStringCharacter; pub(crate) fn check_date_string_validity( valid_amount_number: bool, valid_amount_dash: bool, valid_amount_comma: bool, ) -> Result<(), TcmbEvds...
true
353981a0742eb3e4d439ea3b605ab8c74cf4e2e8
Rust
seanwallawalla-forks/nushell
/crates/nu-data/src/config/local_config.rs
UTF-8
5,439
3.203125
3
[ "MIT" ]
permissive
use nu_errors::ShellError; use std::path::{Path, PathBuf}; static LOCAL_CFG_FILE_NAME: &str = ".nu-env"; pub struct LocalConfigDiff { pub cfgs_to_load: Vec<PathBuf>, pub cfgs_to_unload: Vec<PathBuf>, } /// Finds all local configs between `from` up to `to`. /// Every config seen while going up the filesystem ...
true
eec5167012001af836c83e70c9a9c541cb0007b2
Rust
atsamd-rs/atsamd
/hal/src/thumbv7em/clock/v2/osculp32k.rs
UTF-8
17,089
3.234375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! # Internal, ultra low power, 32 kHz oscillator //! //! ## Overview //! //! The `osculp32k` module provides access to the 32 kHz ultra low power //! internal oscillator (OSCULP32K) within the `OSC32KCTRL` peripheral. //! //! The `OSCULP32K` clock is unlike most other clocks. First, it is an internal //! clock that i...
true
6ce29d143bd1ac7f833ccffff766c4ccb86e076b
Rust
Cecca/progress-logger-rs
/src/lib.rs
UTF-8
9,175
3.359375
3
[ "MIT" ]
permissive
#[macro_use] extern crate log; use std::time::{Duration, Instant}; use sysinfo::{System, SystemExt}; /// A tool to report the progress of computations. It can be built and configured /// using the `builder` function. If given the expected number of updates, /// reports the expected time to completion, based on the cu...
true
41b35fa6a93e1deaa8a7a6f0a95610dfde8f5df2
Rust
CatsRang/RustExercise
/ex00_guessinggame/src/main.rs
UTF-8
1,591
3.59375
4
[]
no_license
extern crate rand; use std::io; use std::io::Write; use rand::Rng; use std::cmp::Ordering; fn main() { //---- io write excample { let stdout = io::stdout(); let mut handle = stdout.lock(); handle.write(b"Hello, Rust\n").expect("Error"); } //---- Using println! macro printl...
true
9d85ec8794d6eb8e7d4bbb564a020e70ed92363d
Rust
lislis/aoc2020
/day04/src/helper.rs
UTF-8
3,466
2.921875
3
[]
no_license
use utils::utils; use std::collections::HashMap; use regex::Regex; pub fn read_parse_passports(path: &str) -> Vec<HashMap<String, String>> { let content = utils::read_file(path); let lines = content.split("\n\n").collect::<Vec<&str>>(); let values = lines.iter() .map(|x| create_passport(x)) ...
true
3ce4234673dda88d202e1e1b442903ab4c371670
Rust
DriesCruyskens/raytracing-in-one-weekend
/rt/src/ray.rs
UTF-8
572
3.171875
3
[]
no_license
use vec3::{Point3, Vec3}; pub struct Ray { pub origin: Point3, pub direction: Vec3, pub time: f64, } impl Ray { pub fn new(origin: Point3, direction: Vec3, time: f64) -> Ray { Ray { origin, direction, time, } } pub fn at(&self, t: f64) -> Po...
true
988d60fe1ed0027eb5f5b0e33531a80c9a5f6753
Rust
WilliamTCarroll/dim_struct
/src/common/float.rs
UTF-8
1,402
3.921875
4
[]
no_license
/// The default Float type (currently f64). /// This is to avoid having to change hundreds of units in the event of an f128 pub type Float = f64; impl RoundTo for Float { /// Returns a floating point number rounded to the specified digits fn round_to(&self, decimals: usize) -> Float { let decimals: i32 ...
true
1a29f4a6c2c8706426cb15669f275ce5596e8271
Rust
iCodeIN/chitin
/chitin-model/src/lib.rs
UTF-8
2,937
2.53125
3
[]
no_license
use proc_macro::TokenStream; use quote::quote; use syn::{parse_macro_input, Ident, Item, ItemMod, UseTree}; #[proc_macro_attribute] pub fn chitin_model(_attr: TokenStream, item: TokenStream) -> TokenStream { let item_mod: &ItemMod = &parse_macro_input!(item as ItemMod); let mut models = Vec::new(); match i...
true
851591a5ae50a2ab6b4369eef2c9157a31dea865
Rust
DanielBarton446/planner-rs
/src/opts.rs
UTF-8
2,712
2.84375
3
[]
no_license
use std::convert::From; use std::path::PathBuf; use app_dirs::AppDataType; use clap::{AppSettings, Clap}; use crate::constants::*; #[derive(Clap)] #[clap(version = VERSION, author = APP_INFO.author)] #[clap(setting = AppSettings::ColoredHelp)] #[clap(about = "A CLI planner. Fun :)")] pub struct Opts { #[clap(sho...
true
f2ff8a5391cf9386e9ba3fe4c3d9e55494ccde0c
Rust
udoprog/OxidizeBot
/crates/oxidize-settings/src/lib.rs
UTF-8
38,602
2.765625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Utilities for dealing with dynamic configuration and settings. use std::collections::HashMap; use std::fmt; use std::future::Future; use std::marker; use std::ops; use std::pin::Pin; use std::sync::Arc; use std::task::{Context, Poll}; use chrono_tz::Tz; use common::stream::StreamExt as _; use diesel::prelude::*; ...
true
195c5f607810d9cec9ffcc1b85bdcf4cc0683032
Rust
jean553/rust-single-float-precision
/rust-single-float-precision/src/main.rs
UTF-8
1,891
3.53125
4
[]
no_license
use std::env::args; fn main() { let decimal_string: String = args().nth(1).unwrap(); let decimal: u32 = decimal_string.trim().parse().expect("parsing error"); let mut value: u32 = 1; let mut last_value: u32 = 1; let mut pow: u32 = 0; let mut last_pow: u32 = 0; while value < decimal { ...
true
1d82aeb58139272bfcbfbe6e622bbd98eb25eea8
Rust
tatref/honeyssh
/src/fake_shell.rs
UTF-8
3,720
3.140625
3
[]
no_license
use std::collections::HashMap; use log::info; struct FakeShellState { cwd: String, user: String, vars: HashMap<String, String>, } impl Default for FakeShellState { fn default() -> Self { Self { cwd: Default::default(), user: Default::default(), vars: vec![ ...
true
07ea867e80cf26868c0c6f44ae057d5c124568f0
Rust
Burtannia/rust-sandbox
/clicky/src/main.rs
UTF-8
1,087
2.84375
3
[ "MIT" ]
permissive
extern crate gio; extern crate gtk; use gio::prelude::*; use gtk::prelude::*; use std::cell::RefCell; use std::error::Error; use std::io::Write; use std::rc::Rc; use gtk::{Application, ApplicationWindow, Button}; fn main() -> Result<(), Box<dyn Error>> { let application = Application::new(Some("com.githu...
true
079afc4a6c9132a0a8048d9dc90be31c3582eff8
Rust
matthewmeyer/language-learning
/rust/variables/src/twelve_days.rs
UTF-8
949
3.828125
4
[]
no_license
pub mod twelve_days { const DAYS: [(&str, &str); 4] = [ ("Chicken in Road Ditch", "1st"), ("Frogs a Leaping", "2nd"), ("Maids a Milking", "3rd"), ("Golden Rings", "4th") ]; pub fn twelve_days(day: usize, holiday: &str) { println!("On the {} day of {} my true love g...
true
a95697605f1c9976fff9a6dc3e32fc423d07f479
Rust
pfirsich/adventofcode2019
/7/rust/day7.rs
UTF-8
11,672
3.390625
3
[]
no_license
use std::fs; use std::collections::VecDeque; trait InputSource { fn read(&mut self) -> i64; fn len(&self) -> usize; } trait OutputSink { fn write(&mut self, value: i64); } impl InputSource for VecDeque<i64> { fn read(&mut self) -> i64 { if self.len() == 0 { panic!("...
true
693cc9f922c9a7e9ff43444acdaea42afcd11ac6
Rust
fabienheureux/engine
/src/window.rs
UTF-8
7,006
3
3
[]
no_license
use crate::constants::{GAME_TITLE, SCREEN_HEIGHT, SCREEN_WIDTH}; use crate::opengl::OpenGL; use glutin::{ dpi, ContextBuilder, DeviceEvent, ElementState, Event, EventsLoop, ModifiersState, MouseButton, VirtualKeyCode, WindowBuilder, WindowEvent, WindowedContext, }; use std::collections::HashMap; use std::ti...
true
dbf1e5e48afbcb96174541cf487b75c05c4a28fa
Rust
adamnemecek/Gestalt
/gestalt/src/voxel/subdivstorage.rs
UTF-8
36,843
3.015625
3
[]
no_license
use std::fmt::{Display, Debug}; use std::fmt; use std::error; use std::error::Error; use std::result::Result; use std::cell::RefCell; use generational_arena::Arena; use generational_arena::Index as ArenaIndex; use crate::voxel::voxelmath::*; use crate::voxel::subdivmath::*; use crate::voxel::voxelstorage::Voxel; /// ...
true
b5e70e1a81fabf3d4bf8f200e2038061912ddc9e
Rust
prisma/prisma-engines
/schema-engine/sql-migration-tests/tests/migrations/shadow_database_url_configuration.rs
UTF-8
6,170
2.640625
3
[ "Apache-2.0" ]
permissive
use expect_test::expect; use quaint::{prelude::Queryable, single::Quaint}; use sql_migration_tests::multi_engine_test_api::*; use test_macros::test_connector; use user_facing_errors::UserFacingError; // exclude: auth works differently in single-node insecure cockroach #[test_connector(tags(Postgres), exclude(Cockroach...
true
2e7d7f8b77c9f94e6f1cb8b7d7d03221c669be09
Rust
RNAcentral/rnacentral-import-pipeline
/utils/search-export/src/sequences/accession.rs
UTF-8
5,700
2.8125
3
[ "GPL-1.0-or-later", "Apache-2.0", "Artistic-1.0-Perl", "LicenseRef-scancode-other-copyleft", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::{ collections::HashSet, iter::FromIterator, }; use serde::{ Deserialize, Serialize, }; #[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone)] pub struct RawAccession { pub id: usize, pub urs_taxid: String, accession: String, common_name: Option<String>, database: S...
true
8b6357a49aa93c195f39d785243ea4c191698a54
Rust
kconte/project-euler-rust
/solvers/004/src/main.rs
UTF-8
559
3.125
3
[]
no_license
#![warn(clippy::all)] #![warn(clippy::pedantic)] fn main() { run(); } fn run() { let start = std::time::Instant::now(); // code goes here let mut res = 0; for a in 100..1000 { for b in 100..1000 { let c = a * b; if is_palindrome(c) && c > res { res = c; } } } let spa...
true
3e1e6f1712747fac2a383b87321acafe87ae62c9
Rust
dsbarnes/learning-rust
/chapter6/option_type/src/main.rs
UTF-8
1,350
3.78125
4
[ "MIT" ]
permissive
enum Coin { Penny, Nickel, Dime, Quarter(UsState), } #[derive(Debug)] enum UsState { Colorado } fn main() { let my_penny = Coin::Penny; let shiny_nickel = Coin::Nickel; let state = UsState::Colorado; let quarter = Coin::Quarter(state); let total_value = Some(0); println!("...
true
d3475cd8008c7173db3476d23b6ec2b0641c0e25
Rust
maxdee/freeliner-rs
/src/parameter.rs
UTF-8
1,647
3.65625
4
[]
no_license
// use std::fmt::Debug; // // pub trait Parameter { // fn get_name(&self) -> &str; // fn set(&mut self, string: &str); // } // // pub enum Param { // Float{name: String, value: f32, min: f32, max: f32, default: f32}, // Radio{name: String, value: usize, len: usize, default: usize}, // } // // impl Para...
true
85d9705aca1bd09641ea2e85a01cf439615bd924
Rust
mrandri19/opengl-compute-shaders
/src/shader.rs
UTF-8
1,411
2.6875
3
[]
no_license
use gl::types::*; use std::ffi::CStr; use std::ffi::CString; pub struct Shader { id: GLuint, } impl Shader { pub fn from_source(source: &CStr, kind: GLenum) -> Result<Shader, String> { let id = unsafe { gl::CreateShader(kind) }; unsafe { gl::ShaderSource(id, 1, &source.as_ptr(), std...
true
73d82e51d7430253d34b92efe7188d1c6c50c910
Rust
demisstif/bevy_game
/src/main.rs
UTF-8
2,141
3.21875
3
[ "MIT" ]
permissive
use bevy::prelude::*; fn main() { App::build() // All Bevy engine features are implemented as plugins // adds an "event loop" to our application. Our App's // ECS Schedule now runs in a loop once per "frame" .add_default_plugins() // WindowPlugin, WinitPlugin .add_plugin(He...
true
f55c45659c505123dfd722c457c4c66fcaaf00c2
Rust
iamNarcisse/my-rust
/src/error_handling/index.rs
UTF-8
1,645
3.6875
4
[]
no_license
use core::panic; fn drink(drink: &str) { if drink == "beer" { panic!("Aaaaaaaaaah!!!"); } println!("Some refreshing {} is all I need", drink); } fn give_adult(drink: Option<&str>) { match drink { Some("lemonade") => println!("Yuck! Too sugary"), Some(inner) => println!("{}? Ho...
true
89242f8abce54a1ad7015597c80c40ed61f8c5ce
Rust
mtharrison/wasmparse-core
/src/types/element_section.rs
UTF-8
1,424
2.96875
3
[]
no_license
use leb128::ReadLeb128Ext; use std::io::{Error, Read}; use super::*; #[derive(Debug, PartialEq, Serialize)] pub struct ElementSection { pub count: u32, pub entries: Vec<ElementSegment>, } impl ElementSection { pub fn from_reader<T: Read>(reader: &mut T) -> Result<ElementSection, Error> { let (cou...
true
7b511b8b21177f865c9ec260e8885e603d538899
Rust
drogue-iot/embassy
/embassy-rp/src/uart.rs
UTF-8
4,772
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
use core::marker::PhantomData; use embassy::util::Unborrow; use embassy_extras::unborrow; use gpio::Pin; use crate::{gpio, pac, peripherals}; #[non_exhaustive] pub struct Config { pub baudrate: u32, pub data_bits: u8, pub stop_bits: u8, } impl Default for Config { fn default() -> Self { Self...
true
31ca55599ef9e8aa7e389b3b4167c5a208fb4a4f
Rust
tylerreisinger/rust-fractal-generator
/src/runner.rs
UTF-8
5,696
3.046875
3
[]
no_license
use std::thread; use std::sync; use std::sync::mpsc; use std::mem; use std::fmt; use std::error::Error; use std::any::Any; use num_complex::{Complex}; use fractal::{Fractal, FractalOrbit}; use grid; #[derive(Debug)] pub enum RunnerError { RunnerError(String), SendError(Box<Error + Send + 'static>), RecvE...
true
e53af56b6bb2dc15f958d38f991454c0c5260322
Rust
diecast/metadata
/src/toml.rs
UTF-8
2,518
3.046875
3
[]
no_license
use std::error::Error as StdError; use std::fmt; use typemap; use toml_; use diecast::{self, Item}; /// Metadata key type. /// /// This is a simple key type for keying /// into the item extensions and accessing /// or modifying the parsed TOML metadata /// for a given item. pub struct Metadata; impl typemap::Key f...
true
cbcad732dbab1df68ac1f53334214bcfe2e0806d
Rust
ryoherisson/rust-programming
/src/rust-as-second-language/structual-programming/structure/src/main.rs
UTF-8
626
3.5
4
[]
no_license
// Uint Struct struct Dummy; // Tuple Struct struct Point(f64, f64); // struct Name {field: type, ...} struct Color { r: u8, g: u8, b: u8, } fn main() { // Unit構造体は名前でそのまま初期化 let dummy = Dummy; // Tuple構造体は関数のように初期化 // 関数として扱うこともできる let point = Point(0.0, 0.0); // Tuple構造体のフィールド...
true
9fc91a8ab9f9f3fa146847a0070580813ef6bf67
Rust
feadoor/rustdoku
/src/generator/brute_force.rs
UTF-8
14,008
3.0625
3
[]
no_license
//! A (hopefully!) very quick brute-force solver, used to aid in grid generation. use rand::prelude::*; use grid::{Grid, GridSize}; type Cell = usize; type House = usize; type DigitMask = usize; struct ConstantData { num_digits: usize, num_houses: usize, num_cells: usize, all_digits_mask: DigitMask,...
true
b6df73c060b1bb1a5509428637da1952a17c0d38
Rust
doy/nbsh
/src/runner/command.rs
UTF-8
5,662
2.8125
3
[ "MIT" ]
permissive
use crate::runner::prelude::*; pub struct Command { inner: Inner, exe: std::path::PathBuf, redirects: Vec<crate::parse::Redirect>, pre_exec: Option< Box<dyn FnMut() -> std::io::Result<()> + Send + Sync + 'static>, >, } impl Command { pub fn new(exe: crate::parse::Exe, io: super::builti...
true
7327c59a84ece8c9898e6310a837c5b009ee681b
Rust
abhijeetbhagat/boa
/boa/src/syntax/parser/expression/primary/object_initializer/mod.rs
UTF-8
8,940
2.84375
3
[ "Unlicense", "MIT" ]
permissive
//! Object initializer parsing. //! //! More information: //! - [MDN documentation][mdn] //! - [ECMAScript specification][spec] //! //! [mdn]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer //! [spec]: https://tc39.es/ecma262/#sec-object-initializer #[cfg(test)] mod te...
true
a302b4199b44bc6ffbcb90319204a51f3c0a103e
Rust
km19809/wasm-game-of-compass
/src/text.rs
UTF-8
781
2.640625
3
[ "MIT", "Apache-2.0" ]
permissive
#[cfg(not(feature = "Korean"))] #[macro_export] macro_rules! TEMPLATE_TEXT_GIVEN_UP { () => { "{} (Given Up)" }; } #[cfg(not(feature = "Korean"))] #[macro_export] macro_rules! TEMPLATE_TEXT_WINNER { () => { "The winner is {}!" }; } #[cfg(not(feature = "Korean"))] #[macro_export] macro_ru...
true
c6e80dc4d1550d02b242c1390a377116f9e18fa5
Rust
konstin/demos
/oparl-cache-rs/src/server.rs
UTF-8
1,391
3.078125
3
[]
no_license
use json; use json::JsonValue; use std::error::Error; use reqwest; use reqwest::Url; use std::io::Read; /// Defines an oparl server /// /// Send and Sync are required because the server will be used from multiple workers pub trait Server: Send + Sync { /// Returns a freshly loaded object as json fn get_json(&...
true
c850f68cd77d5080d0e77cd4eacb0a22e63f02f6
Rust
Deniallugo/bot_mother
/src/enum_button.rs
UTF-8
1,187
3.09375
3
[]
no_license
use telegram_bot::KeyboardButton; #[derive(Debug, Fail)] pub enum Error { #[fail(display = "failed to parse '{}' to {}", input, to)] ParseStrError { input: String, to: String }, } pub trait AsButton { fn as_button(&self) -> KeyboardButton; } #[macro_export] macro_rules! enum_button { ($name:ident, $(...
true
b9bd96dc67f05b6087192e512fbaefa3a1e14926
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/ctr-0.8.0/src/flavors.rs
UTF-8
986
2.671875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-warranty-disclaimer", "BSD-2-Clause" ]
permissive
//! CTR mode flavors use cipher::{ generic_array::{ArrayLength, GenericArray}, SeekNum, }; mod ctr128; mod ctr32; mod ctr64; pub use ctr128::*; pub use ctr32::*; pub use ctr64::*; /// Trait implemented by different counter types used in the CTR mode. pub trait CtrFlavor<B> where Self: Default + Clone, ...
true
70ec185e73fe380c5d0d017a6b9914752bb6bb8f
Rust
dinAlt/yatt
/src/style.rs
UTF-8
7,557
3.015625
3
[]
no_license
use core::result::Result; use crossterm::style::{Color, ContentStyle}; use std::{convert::TryInto, num::ParseIntError}; use termimad::*; use crate::errors::{CliError, CliResult}; #[derive(Clone, Debug)] pub struct Theme { pub c1: Color, pub c2: Color, pub c3: Color, pub c4: Color, pub c5: Color, } impl Defa...
true
95e733cad7dd588aaaa445a02f64955bd7ffa6e6
Rust
u-03c9/sctp
/src/chunk/chunk_heartbeat_ack.rs
UTF-8
4,417
3.03125
3
[ "MIT" ]
permissive
use super::{chunk_header::*, chunk_type::*, *}; use crate::param::{param_header::*, *}; use crate::param::param_type::ParamType; use crate::util::get_padding_size; use bytes::{Bytes, BytesMut}; use std::fmt; ///chunkHeartbeatAck represents an SCTP Chunk of type HEARTBEAT ACK /// ///An endpoint should send this chunk ...
true
fb871d7d46ed38ff4ec23090989631d79ca9c12d
Rust
Jimskapt/rust-book-fr
/FRENCH/listings/ch06-enums-and-pattern-matching/no-listing-14-count-and-announce-if-let-else/src/main.rs
UTF-8
438
3.421875
3
[ "Apache-2.0", "MIT", "Unlicense", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
#[derive(Debug)] enum EtatUs { Alabama, Alaska, // -- partie masquée ici -- } enum PieceUs { Penny, Nickel, Dime, Quarter(EtatUs), } fn main() { let piece = PieceUs::Penny; // ANCHOR: here let mut compteur = 0; if let PieceUs::Quarter(etat) = piece { println!("Il s'...
true
3969d23f3e66f53e0aed0b6b891faddecbfef813
Rust
facebookexperimental/rust-shed
/shed/bytes_ext/src/compat.rs
UTF-8
1,402
2.65625
3
[ "MIT", "Apache-2.0" ]
permissive
/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under both the MIT license found in the * LICENSE-MIT file in the root directory of this source tree and the Apache * License, Version 2.0 found in the LICENSE-APACHE file in the root directory * of this source tree. */ use...
true
10335e813824b33780322e00dc99982973f16cdd
Rust
kSDOT/automata
/src/tests/transition_dfa_to_minimized.rs
UTF-8
8,960
2.609375
3
[ "Apache-2.0", "MIT" ]
permissive
#[cfg(test)] pub mod tests { use crate::automata_nfa::*; use crate::automata_dfa::*; use crate::connection::*; use crate::automata::*; use std::fs::File; use std::io::Read; #[test] fn test_automata_minimized_1() { let mut file = File::open("www/tests/automata_minimized_1.json")....
true
5b271e67deba0ef7d20e58a68b20b63277dd3e19
Rust
TianTianForever/Rust-Tutorial
/loops.rs
UTF-8
487
3.703125
4
[]
no_license
fn main(){ let mut a = 0 ; loop{ a += 1; print!("{} ",a); if a == 10{ break;} } let mut x = 0; let mut y = false; while !y { x += 1; println!("{} ",x); if x ==10 { break; } // if x == 100 {y = true;} } for x in 1..20 { if x % 2 =...
true
cb8590cc42196b6e67c92bd018218072b024ba6c
Rust
magurotuna/leetcode-rust
/src/bin/31.rs
UTF-8
1,564
3.53125
4
[]
no_license
struct Solution; impl Solution { pub fn next_permutation(nums: &mut Vec<i32>) { let mut last_greater_index = None; for i in (0..(nums.len() - 1)).rev() { if nums[i] < nums[i + 1] { last_greater_index = Some(i); break; } } if l...
true
59e2a569e654b7457922cdf20d069b04fb851549
Rust
muskanmahajan37/conveyance-cli
/src/main.rs
UTF-8
5,803
2.96875
3
[]
no_license
use std::fs; use std::str; use std::path::PathBuf; use std::io::Cursor; use std::io::prelude::*; use quick_xml::Writer; use quick_xml::Reader; use quick_xml::events::{Event, BytesText, BytesEnd, BytesStart}; use serde_json::{Map,Value}; use structopt::StructOpt; use zip::write::{FileOptions, ZipWriter}; /// Arguments ...
true
4de604b89664d8988d3bb240f47232bcd144458d
Rust
ezlaif/celsius_farenheit
/src/main.rs
UTF-8
564
3.484375
3
[]
no_license
use std::io; const CONVERSION_DELIMITER: f32 = 32.0; const CONVERSION_RATE: f32 = 5.0/9.0; fn main() { println!("Please enter dem Fahrenheits!"); loop { let mut fahrenheit = String::new(); io::stdin().read_line(&mut fahrenheit) .expect("Failed to read dem Fahrenheits"); let ...
true
b60b8f21454e498c23962fef14571f129a21b6ff
Rust
grogers0/advent_of_code
/2020/day7/src/main.rs
UTF-8
2,988
3.328125
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::io::{self, Read}; use lazy_static::lazy_static; use regex::Regex; type Rules = HashMap<String, Vec<(usize, String)>>; fn parse(puzzle_input: &str) -> Rules { lazy_static! { static ref OUTER_RE: Regex = Regex::new("^([a-z]+ [a-z]+) bags contain (.*)\\.$").unwrap(); ...
true
a732ce05eeaa14d2b26c6b09f6398e0f8dcc1fe2
Rust
astral-sh/ruff
/crates/ruff_macros/src/combine_options.rs
UTF-8
1,920
2.671875
3
[ "BSD-3-Clause", "0BSD", "LicenseRef-scancode-free-unknown", "GPL-1.0-or-later", "MIT", "Apache-2.0" ]
permissive
use quote::{quote, quote_spanned}; use syn::{Data, DataStruct, DeriveInput, Field, Fields, Path, PathSegment, Type, TypePath}; pub(crate) fn derive_impl(input: DeriveInput) -> syn::Result<proc_macro2::TokenStream> { let DeriveInput { ident, data, .. } = input; match data { Data::Struct(DataStruct { ...
true
a1d6ac0a801cb4deff568ac1c0913d82220965aa
Rust
prajithkb/tokio-experiments-redis
/src/lib.rs
UTF-8
1,105
2.640625
3
[]
no_license
//! This is an implementation of redis for my learning. //! It implements GET/SET/PUBLISH/SUBSCRIBE similar to `mini-redis` crate #![warn(missing_docs)] pub mod client; pub mod commands; pub mod connection; pub(crate) mod database; pub mod parse; pub mod resp; pub mod server; /// /// When writing a real application, ...
true
e0f4e89e0c2340a2cb4ddd3b642f322d0013e120
Rust
treeman/libhabitrpg
/src/data/user.rs
UTF-8
2,282
2.921875
3
[]
no_license
use rustc_serialize::{ Encodable, Decoder, Encoder }; use data::{ Date, Achievements, Habit, Daily, Todo, Reward, Stats, Tag, Items, Profile, }; // TODO custom Show #[derive(Debug, RustcEncodable, RustcDecodable)] pub struct User { pub achievements: Achievements, // Ma...
true
f4701645d9b7e9ae9bb9607d9da384d054f4b734
Rust
floppyMike/RustProjects
/e_to_nth_digit/src/main.rs
UTF-8
886
3.140625
3
[]
no_license
use std::slice; use std::str; fn main() { let e: &'static str = "2.718281828459045235360287471352662497757247093699959574966967627724076630353547594571382178525166427"; if std::env::args().len() != 2 { println!("e_to_nth_digit <num>\nPrint the constant to num digit. Goes till 100."); return; ...
true
7a211f02fba1835d17c6767de946ba5e67b55ccc
Rust
ennis/autograph-ng
/api/src/error.rs
UTF-8
551
2.953125
3
[]
no_license
//! Error type. //! //! This is the shared error type for the whole crate. // TODO it's unclear what's best: a shared error enum like this, or smaller error types for each module use std::{error, fmt}; #[derive(Clone, Debug)] pub enum Error { OutOfMemory, InvalidRenderTarget, InvalidSampledImage, Inv...
true
c058618e694d245dc4bf13289fd9fd974edd7d27
Rust
mygirl8893/chain-1
/chain-core/src/init/coin.rs
UTF-8
6,020
3.078125
3
[ "Apache-2.0", "MIT" ]
permissive
//! # Value with associated properties (e.g. min/max bounds) //! adapted from https://github.com/input-output-hk/rust-cardano (Cardano Rust) //! Copyright (c) 2018, Input Output HK (licensed under the MIT License) //! Modifications Copyright (c) 2018 - 2019, Foris Limited (licensed under the Apache License, Version 2.0...
true
4eb960febabaacf99d5177ea320a2ea2b5b016d0
Rust
MariuszBielecki288728/rust-course
/lab06/task3/src/main.rs
UTF-8
1,532
3.71875
4
[]
no_license
fn main() { println!("Hello, world!"); println!("{:?}", print(5).unwrap()); } fn print(n: i32) -> Option<String> { if n % 2 == 0 || n < 0 { None } else { let mut s1: Vec<String> = vec![]; for i in 1..(n + 1) / 2 { let mut s = std::iter::repeat(" ").take(i as usize).c...
true
222a437bf7fe357271c33f2cbdc01602e541115c
Rust
cuplv/iodyn.rust
/eval/src/actions.rs
UTF-8
13,870
2.640625
3
[]
no_license
use std::marker::PhantomData; use std::rc::Rc; use rand::{Rng,StdRng}; use time::Duration; use primitives::*; use adapton::engine::{Name,ns,name_fork}; pub trait Creator<R,D> { fn create(&mut self, rnd: &mut StdRng) -> (R,D); } pub trait Editor<R,D> { fn edit(&mut self, data: D, rng: &mut StdRng) -> (R,D); } pub tra...
true
fe81eba660ba65e989275e269fb15927d1a58cd0
Rust
mun-lang/mun
/crates/mun_language_server/tests/support.rs
UTF-8
7,810
2.625
3
[ "Apache-2.0", "MIT" ]
permissive
use crossbeam_channel::{after, select}; use lsp_server::{Connection, Message, Notification, Request}; use lsp_types::{ notification::Exit, request::Shutdown, ProgressParams, ProgressParamsValue, Url, WorkDoneProgress, }; use mun_hir::fixture::Fixture; use mun_language_server::{main_loop, Config, FilesWatcher}; ...
true
bf2f8f09ff6ecf4328fb038f99145f8d7b361988
Rust
dorucioclea/brandywine-bridge
/packages/erd-contracts/weth/src/lib.rs
UTF-8
4,579
3.015625
3
[ "MIT" ]
permissive
#![no_std] #![allow(clippy::string_lit_as_bytes)] imports!(); #[elrond_wasm_derive::contract(SimpleErc20TokenImpl)] pub trait SimpleErc20Token { // STORAGE /// Total number of tokens in existence. #[view(totalSupply)] #[storage_get("total_supply")] fn get_total_supply(&self) -> BigUint; #[storage_set("total_s...
true
22725775748ae064e909e6fde4efd88366389eb0
Rust
KlasafGeijerstam/Kattis
/rust/coinstacks.rs
UTF-8
843
2.640625
3
[]
no_license
mod fast_input; use fast_input::FastInput; fn main() { let inp = FastInput::new(); inp.next_line(); let mut stacks: Vec<(i16, u8)> = inp .next_as_iter() .enumerate() .map(|(i, x)| (x, i as u8)) .collect(); let mut moves = Vec::with_capacity(25000); loop { sta...
true
a9804017da3ab0e967b6ef79b001a03851e91ab3
Rust
skishore/fantasy
/src/lib/base.rs
UTF-8
434
2.59375
3
[]
no_license
pub type HashMap<K, V> = rustc_hash::FxHashMap<K, V>; pub type HashSet<T> = rustc_hash::FxHashSet<T>; pub type Result<T> = std::result::Result<T, Error>; #[derive(PartialEq)] pub struct Error(String); impl std::fmt::Debug for Error { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{...
true
d63fd18ac8408c1b835ffbbb6f619afaeff9b0f3
Rust
da9ish/relay
/compiler/crates/graphql-syntax/src/lexer.rs
UTF-8
17,554
3.171875
3
[ "MIT" ]
permissive
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ use crate::char_constants::*; use crate::lexer_position::LexerPosition; use crate::syntax_node::Token; use crate::token_kind::Token...
true
b6fc813a462b7718583529fccb5e8265b9ade23f
Rust
dlaststark/machine-learning-projects
/Programming Language Detection/Experiment-2/Dataset/Train/Rust/dutch-national-flag-problem.rust
UTF-8
999
3.640625
4
[]
no_license
extern crate rand; use rand::Rng; // Color enums will be sorted by their top-to-bottom declaration order #[derive(Eq,Ord,PartialOrd,PartialEq,Debug)] enum Color { Red, White, Blue } fn is_sorted(list: &Vec<Color>) -> bool { let mut state = &Color::Red; for current in list.iter() { if curr...
true
1467af5146bd02f903112665c35527fafdd70670
Rust
jtimon/qcircuits
/src/main.rs
UTF-8
2,626
2.578125
3
[ "MIT" ]
permissive
// use qcircuits::angle::MAX_ANGLE; use qcircuits::cfactory::QCircuitFactory; use qcircuits::circuits::{ FilterType, ParticleSource, }; use qcircuits::sources::{ // AngleParticleSource, EnumParticleSource, // DetAngleParticleSource, // DetAngleParticleSourceDebug, DetBitsParticleSource, ...
true
b54e2b28ebe24878eaf1bd1c2771a1a041544d9d
Rust
pprobst/rust-stuff
/ch9_functions/input_functions.rs
UTF-8
826
3.9375
4
[]
no_license
/* * Since closures may be used as arguments, you might wonder if the same can be said * about functions. And indeed they can! If you declare a function that takes a closure * as parameter, then any function that satisfies the trait bound of that closure can * be passed as a parameter. */ // Define a function ...
true
da358835608d29eff11cee54404c3ae6b0838e99
Rust
Mefgalm/Metal
/src/downloader.rs
UTF-8
3,399
2.765625
3
[]
no_license
use crate::addons_manager::*; use crate::base::*; use crate::error::*; use futures::future::join_all; use regex::Regex; use reqwest::Client; use serde::Deserialize; use std::fs::create_dir_all; use std::{ fs::File, io::{self, Write}, path::{Path, PathBuf}, }; #[derive(Deserialize, Debug)] struct Asset { ...
true
a76ea0d7f877053d399e18092dc0b02a5d8772af
Rust
boa-dev/boa
/boa_engine/src/builtins/bigint/mod.rs
UTF-8
10,813
3.140625
3
[ "MIT", "Unlicense" ]
permissive
//! Boa's implementation of ECMAScript's global `BigInt` object. //! //! `BigInt` is a built-in object that provides a way to represent whole numbers larger //! than the largest number JavaScript can reliably represent with the Number primitive //! and represented by the `Number.MAX_SAFE_INTEGER` constant. //! `BigInt`...
true
02b2cdf67f547d1a3839a62212e47db7f6380fec
Rust
ThibsG/linreg-rs
/src/lib.rs
UTF-8
10,413
3.671875
4
[ "MIT" ]
permissive
//! Linear regression //! //! `linreg` calculates linear regressions for two dimensional measurements, also known as //! [simple linear regression](https://en.wikipedia.org/wiki/Simple_linear_regression). //! //! Base for all calculations of linear regression is the simple model found in //! https://en.wikipedia.org/wi...
true
35a1308aabc3102106cddfa83e20db13ed81575a
Rust
liam0215/catnip
/src/protocols/ethernet2/frame.rs
UTF-8
2,353
2.71875
3
[ "MIT" ]
permissive
// Copyright (c) Microsoft Corporation. // Licensed under the MIT license. use crate::{fail::Fail, protocols::ethernet2::MacAddress, runtime::RuntimeBuf}; use byteorder::{ByteOrder, NetworkEndian}; use num_traits::FromPrimitive; use std::convert::{TryFrom, TryInto}; pub const MIN_PAYLOAD_SIZE: usize = 46; pub const E...
true
c1554414b4c7b422c7c495a73f1138ff8d18d924
Rust
jonwingfield/atsamd09-rs
/atsamd09d14a/rtc/mode2/mask/mod.rs
UTF-8
6,772
2.984375
3
[]
no_license
#[doc = r" Value read from the register"] pub struct R { bits: u8, } #[doc = r" Value to write to the register"] pub struct W { bits: u8, } impl super::MASK { #[doc = r" Modifies the contents of the register"] #[inline] pub fn modify<F>(&self, f: F) where for<'w> F: FnOnce(&R, &'w mut W)...
true
2205a923dcb73799d4fb7fd77d6b4134814c3c74
Rust
rusterlium/rustler
/rustler_tests/native/rustler_test/src/test_list.rs
UTF-8
531
2.75
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use rustler::{Error, ListIterator, NifResult}; use std::panic; #[rustler::nif] pub fn sum_list(iter: ListIterator) -> NifResult<i64> { // Do nothing and suppress panic message. From https://stackoverflow.com/a/35559417 panic::set_hook(Box::new(|_info| {})); let res: Result<Vec<i64>, Error> = iter.map(|x| ...
true
b273da4898d6acaac5987a93e460a16dfac35dba
Rust
baajarmeh/Mysticeti
/src/controls/mod.rs
UTF-8
2,658
3.03125
3
[ "MIT" ]
permissive
mod service; mod transport; pub use service::*; use transport::Transport; use tokio::net::TcpStream; use anyhow::{ Result, anyhow }; use super::{ state::State, config::Conf, }; use std::{ net::SocketAddr, sync::Arc, }; /// 控制器 pub struct Controls { inner: Arc<Transport>, state: Arc<S...
true
0b64837f54978a24d14656fa3d87d2d6dbada9b7
Rust
tustvold/rust-playground
/lib/rusoto_util/src/lib.rs
UTF-8
1,936
2.546875
3
[]
no_license
use async_trait::async_trait; use log::warn; use rusoto_core::credential::{ AwsCredentials, ChainProvider, CredentialsError, ProvideAwsCredentials, }; use rusoto_core::Region; use rusoto_sts::WebIdentityProvider; use std::time::Duration; // A custom chain provider incorporating web identity support // See - https:...
true
1b06a9a6b81428561b71ecf306f0a63306cc3e38
Rust
ocstl/advent_of_code_2015
/src/bin/day15.rs
UTF-8
3,814
3.078125
3
[]
no_license
use std::fs; const PUZZLE_INPUT: i32 = 100; const MAX_CALORIES: i32 = 500; #[cfg(test)] mod tests { use super::*; } #[derive(Clone, Debug)] struct Ingredient { name: String, capacity: i32, durability: i32, flavor: i32, texture: i32, calories: i32, } impl Ingredient { fn from_str(s: &...
true
1dcbec0edb040e1949ec65d4b8db55d9c51c7f45
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/euclid-0.22.1/src/angle.rs
UTF-8
8,062
3.1875
3
[ "BSD-2-Clause", "MIT", "Apache-2.0" ]
permissive
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
true
339fc54e1b726fb3ba426d6ce49fcab0ed4f66e3
Rust
SigmaDojo/rust-in-piece
/src/lib.rs
UTF-8
86
2.640625
3
[]
no_license
pub trait Game { fn roll(&mut self, pins: i32); fn score(&self) -> i32; }
true
ba52618d5e47d7eb6d456a43685b1d517e312f86
Rust
oneshadab/trebek
/src/memory/gc.rs
UTF-8
1,684
3.078125
3
[]
no_license
use std::collections::{HashSet, VecDeque}; use super::object_heap::{ObjectHeap, ObjectId}; pub struct GarbageCollector { marked: HashSet<ObjectId>, } impl GarbageCollector { pub fn new() -> GarbageCollector { GarbageCollector { marked: HashSet::new(), } } pub fn collect(&...
true
be0489965934b82526d5d744d6ee49aaef32098e
Rust
sadroeck/Heimdall-RS
/api/src/account/db.rs
UTF-8
1,111
2.5625
3
[]
no_license
use super::mmo_account::MmoAccount; #[derive(Debug, thiserror::Error)] pub enum DBError { #[error("No such account {0}")] NoSuchAccount(AccountId), #[error("No such user {0}")] NoSuchUser(UserId), #[error("Account {0:?} already exists")] AccountAlreadyExists(AccountId), } pub type DBResult<T> ...
true
0831ee25875b221e5b4f6b54a3bdc92949ac2d76
Rust
rsstdd/Rust-Lang-Basics
/src/string_slices.rs
UTF-8
954
4.125
4
[]
no_license
// String Slcies const CONSTANT_STRING: &'static str = "This is a constant string"; // & - this is a refererence (point to existing strings) // 'static - lifetime of the reference is static - Lives for the whole duration of program // str - indicates string slice fn say_hello(to_whom: &str) { // If you need to pass a...
true
817381dc97f481a60be2d44788045c5d231492b7
Rust
Dr-Horv/Advent-of-Code-2019
/src/day07/mod.rs
UTF-8
6,025
2.78125
3
[ "MIT" ]
permissive
use std::sync::mpsc::{Sender, Receiver}; use std::sync::mpsc; use std::thread; use crate::lib::Solver; use crate::lib::intcode_computer; pub(crate) struct Day7Solver {} fn valid(a: i128, b: i128, c: i128, d: i128, e: i128) -> bool { a != b && a != c && a != d && a != e && b != c && b != d && b != e && ...
true
e0b086c42cd2bc9bf8b5492a2c5f2915a36770a3
Rust
xorond/rust_training
/chapter_4/references_and_borrowing/dangling_references/src/main.rs
UTF-8
198
2.890625
3
[]
no_license
fn main() { let reference_to_nothing = dangle(); } fn dangle() -> String { // &String won't compile let s = String::from("hello"); s //&s won't compile because of dangling reference }
true
bfabd7c220f53ef361d010422e5b4e1b635d4b12
Rust
vslynko/chapter20
/src/bin/main.rs
UTF-8
2,004
2.84375
3
[]
no_license
use chapter20::ThreadPool; use std::fs; use std::io::prelude::*; use std::net::TcpListener; use std::net::TcpStream; use std::sync::{Arc, Mutex}; use std::thread; use std::time::Duration; fn main() { let listener = TcpListener::bind("127.0.0.1:7878").unwrap(); let pool = ThreadPool::new(4); let term = Arc:...
true
7ae01d5bcc75fee2e9859dd02de1ce060c09e2cb
Rust
dfrankland/mk20d7
/src/i2s0/rcr4/mod.rs
UTF-8
15,562
2.75
3
[ "MIT" ]
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::RCR4 { #[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
e166b39bf853999b636101032217055ba354a3f1
Rust
dnhua/mythril
/mythril/src/logger.rs
UTF-8
4,387
2.578125
3
[ "MIT" ]
permissive
use crate::time; use core::fmt; use core::fmt::Write; use spin::Mutex; static LOG_LOCK: Mutex<()> = Mutex::new(()); static mut VGA_WRITER: VgaWriter = VgaWriter::new(); const VGA_BASE_ADDR: usize = 0xB8000; const VGA_WIDTH: usize = 80; const VGA_HEIGHT: usize = 25; const VGA_ATTRIB: u16 = 0x0F00; // black background...
true
fb54c341a0211c95f6c87afba2263d7ddf32fe5a
Rust
club-code/CodingChallenges
/advent-of-code/2020/rust/day7/src/bin/part2.rs
UTF-8
638
3.125
3
[]
no_license
use anyhow::Result; use day7::{parse_rules, Rules, TypeCount}; /// Solves part 2 using another recursive function. fn main() -> Result<()> { let rules = parse_rules()?; println!("{}", count_bags(&rules, &rules["shiny gold"]) - 1); Ok(()) } /// Counts the number of bags directly or indirectly contained in ...
true
2718ec47d7c2549be3573249919352321531c591
Rust
qdrant/qdrant
/lib/storage/src/content_manager/conversions.rs
UTF-8
5,832
2.578125
3
[ "Apache-2.0" ]
permissive
use tonic::Status; use crate::content_manager::collection_meta_ops::{ AliasOperations, ChangeAliasesOperation, CollectionMetaOperations, CreateAlias, CreateAliasOperation, CreateCollection, CreateCollectionOperation, DeleteAlias, DeleteAliasOperation, DeleteCollectionOperation, InitFrom, RenameAlias, Renam...
true
827f8eb851af29e7666feb98028e37a63dda4c44
Rust
UnlimitedHugs/MazeWalk
/src/utils/children.rs
UTF-8
1,159
2.828125
3
[]
no_license
use bevy_ecs_wasm::{prelude::{Entity, World}, system::{Command, EntityCommands}}; use crate::prelude::error; pub struct Children(pub Vec<Entity>); pub fn despawn_with_children_recursive(world: &mut World, entity: Entity) { if let Some(mut children) = world.get_mut::<Children>(entity) { for e in std...
true
f69d79c83e229f44ef559aec79c7f7ae5bba21a0
Rust
taraka/AoC2020
/day7/src/main.rs
UTF-8
3,300
3.40625
3
[]
no_license
#![feature(str_split_once)] use std::io::{self, Read}; use std::collections::{HashMap, HashSet}; type Bag<'a> = &'a str; type Holds<'a> = Vec<(u64, Bag<'a>)>; fn main() -> io::Result<()> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer)?; let n = count_eventually_contains(&buffe...
true
89d5b67889e11c399afe36f6d3df40e09ce86e0e
Rust
fluffware/stepper_paths
/src/curves/linear_curve.rs
UTF-8
6,735
3.34375
3
[]
no_license
use std::fmt::Debug; use std::fmt::Error; use std::fmt::Formatter; pub trait CurveApprox { /// Split a segment of a curve and return the lengths. /// Lengths are only returned if the segment is sufficently short to /// estimate the length with requred precision. /// A suitable split point is chosen by ...
true
901c8890d422b8bcb9c184b2de39abf2c7708296
Rust
sonald/lxxtcode-rs
/src/merge_intervals.rs
UTF-8
1,364
3.171875
3
[ "MIT" ]
permissive
pub struct Solution; impl Solution { pub fn merge(intervals: Vec<Vec<i32>>) -> Vec<Vec<i32>> { Self::by_sort(intervals) } pub fn by_sort(mut intervals: Vec<Vec<i32>>) -> Vec<Vec<i32>> { intervals.sort_unstable_by_key(|v| v[0]); intervals.into_iter().fold(vec![], |mut acc, v| { ...
true
26767cadefafb2373c36e55729b85515a837f99f
Rust
AppliedPoetics/keybork.appliedpoetics.org
/rust/src/lib.rs
UTF-8
1,912
3.03125
3
[]
no_license
extern crate regex; extern crate itertools; use regex::Regex; use std::env; use std::fs::File; use std::io::Read; use std::collections::HashSet; pub struct Task { pub file: String, pub args: Vec<String> } pub fn read(filename: String) -> String { let mut contents = String::new(); let mut ...
true
3a17e3d82dae1ddfd3034b8771b7f0f370ca1772
Rust
timokae/ma-node
/src/distribution_service.rs
UTF-8
11,073
2.953125
3
[]
no_license
use log::{error, info}; use rand::{seq::IteratorRandom, thread_rng}; use std::collections::HashMap; use std::sync::{atomic::Ordering, Arc}; use std::time::Duration; use crate::app_state::AppState; use crate::config_store::{ConfigStoreFunc, Monitor}; use crate::file_store::FileStoreFunc; use crate::http_requests::{dist...
true
aff3aaf6a1018c3f72a4411299c11a9afae56e3c
Rust
naturemickey/chi-lang
/projects/chic/src/grammar/lexer/StateSet.rs
UTF-8
3,456
3.59375
4
[]
no_license
pub struct StateSet { states: Vec<Rc<RefCell<State>>>, } impl StateSet { pub fn new(states: Vec<Rc<RefCell<State>>>) -> StateSet { Self { states } } pub fn add(&mut self, state: Rc<RefCell<State>>) -> bool { for rc_state in &self.states { if Rc::as_ptr(rc_state) == Rc::as_p...
true
2d15a2ceacab6a121a17b7766b23a087e09f4114
Rust
Linkeer365/Rust_fool
/ch04-01-what-is-ownership/src/main.rs
UTF-8
3,618
4.46875
4
[]
no_license
fn main() { /// Rust 中的每一个值都有一个被称为其 所有者(owner)的变量。 /// 值有且只有一个所有者。 /// 当所有者(变量)离开作用域,这个值将被丢弃。 let _s = "hello"; { // s 在这里无效, 它尚未声明 let _s = "hello"; // 从此处起,s 是有效的 // 使用 s } // 此作用域已结束,s 不再有效 /// 换句话说,这里有两个重要的时间点: /// 当 s 进入作用域 时,它...
true
0eb4c6a41b9a443b49c9512be82bb8c61b8443a5
Rust
FyroxEngine/Fyrox
/fyrox-ui/src/inspector/editors/vec.rs
UTF-8
3,459
2.59375
3
[ "MIT" ]
permissive
use crate::{ core::{algebra::SVector, num_traits::NumCast}, inspector::{ editors::{ PropertyEditorBuildContext, PropertyEditorDefinition, PropertyEditorInstance, PropertyEditorMessageContext, PropertyEditorTranslationContext, }, FieldKind, InspectorError, Property...
true
dd874d810db1ac1ac3b77e628fa74f81d2a1371a
Rust
westonsteimel/rust
/src/test/ui/closures/2229_closure_analysis/run_pass/move_closure.rs
UTF-8
1,115
3.046875
3
[ "MIT", "BSD-3-Clause", "Apache-2.0", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
// run-pass // Test that move closures compile properly with `capture_disjoint_fields` enabled. #![feature(capture_disjoint_fields)] //~^ WARNING: the feature `capture_disjoint_fields` is incomplete fn simple_ref() { let mut s = 10; let ref_s = &mut s; let mut c = move || { *ref_s += 10; }; ...
true
b13541eed55b42e16c816b2007d7ac3a36e2dd45
Rust
andyyu2004/mp
/mp-protocol/src/encoding/mod.rs
UTF-8
811
2.734375
3
[]
no_license
mod binary_encoder; mod encode; mod encoder; pub use binary_encoder::BinaryEncoder; pub use encode::Encode; pub use encoder::Encoder; use crate::{error::ParseError, ProtocolResult}; use num_enum::TryFromPrimitive; use std::{convert::TryFrom, io::Write}; pub fn binary_encode_to_bytes<T>(item: &T, writer: impl Write) ...
true
6d3b5054b203c8c7ea08cc3a50d670cbc92e9951
Rust
danoclarke/programminglanguages
/Assignment2/drc357.rs
UTF-8
13,171
3.21875
3
[]
no_license
use std::io; use std::io::prelude::*; ////////// SYNTAX CHECK FUNCTIONS ////////// fn is_input(a: &str) -> bool { let lines: Vec<&str> = a.split(".\n").collect(); if lines.len() > 1 { if is_data(lines[0].trim()) && is_query(lines[1].trim()) { return true; }else{ //println!("{} - is_input", a)...
true
498f9dd0b5b0599e4ca314b2ce71d321bef4d5b8
Rust
tqtifnypmb/JustToLearnANewLanguage
/Rust/json/src/map.rs
UTF-8
444
3.140625
3
[ "MIT" ]
permissive
use std::collections::BTreeMap; use crate::value::Value; pub struct Map<K, V> { map: BTreeMap<K, V> } impl Map<String, Value> { pub fn new() -> Self { Map { map: BTreeMap::new() } } pub fn is_empty(&self) -> bool { self.map.is_empty() } pub fn length(&self) -> usize { ...
true