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
b69bad5760670fe98a324e765e600d2c179f2ea1
Rust
uuhan/yata
/src/core/indicator/instance.rs
UTF-8
1,716
3.21875
3
[ "Apache-2.0" ]
permissive
use super::{IndicatorConfig, IndicatorResult}; use crate::core::OHLCV; /// Base trait for implementing indicators **State** pub trait IndicatorInstance: Sized { /// Type of Indicator **Configuration** type Config: IndicatorConfig<Instance = Self>; // <Instance = Self>; /// Returns a reference to the indicator **Co...
true
e117b41ce6b145f138fa5cb38cdc2f6e79512b12
Rust
0b01/DIRTY
/src/ui/tinput.rs
UTF-8
2,974
2.671875
3
[ "Zlib" ]
permissive
// wengwengweng use super::*; use kit::textedit; pub struct Input { buf: textedit::Input, prompt: &'static str, hovering: bool, focused: bool, } impl Input { pub fn new(prompt: &'static str,) -> Self { return Self { buf: textedit::Input::new(), prompt, focused: false, hovering: false, }; } pub...
true
39e64bfa59380292895927b5108cb1f8acc46374
Rust
MikailBag/lxtrace
/src/magic/parse_tree.rs
UTF-8
3,095
2.96875
3
[]
no_license
//! Defines parse tree - thin typed wrapper for pest use super::raw::Rule; use std::collections::HashMap; // Utilities type N<'a> = pest::iterators::Pair<'a, Rule>; pub(super) fn new(p: pest::iterators::Pairs<Rule>) -> Input { let pairs = p.collect::<Vec<_>>(); assert_eq!(pairs.len(), 1); Input::new(pairs...
true
e18af1a21e9be99f9ac38207d4c5d21ae71a9439
Rust
aoki/dots
/src/main.rs
UTF-8
6,752
2.71875
3
[]
no_license
use anyhow::anyhow; use clap::{Parser, Subcommand}; use colored::Colorize; use dots::dotfile::{Dot, DotState}; use skim::{ prelude::{SkimItemReader, SkimOptionsBuilder}, Skim, }; use std::{ collections::HashSet, fs::{self, read_link}, io::Cursor, path::PathBuf, str::FromStr, }; use std::{fs:...
true
0a6fb9b75360439fe3ea2cabc15fbc40b99dea59
Rust
bobbyrward/rust-sandbox
/src/project-euler-problem-02/main.rs
UTF-8
795
3.21875
3
[ "MIT" ]
permissive
use std::int; use std::comm::stream; use std::comm::Port; use std::comm::Chan; type MaybeInt = Option<int>; fn fib_generator(max: int, chan: &Chan<MaybeInt>) { let mut a = 0; let mut b = 1; loop { let next = a + b; if next > max { break; } b = a; a ...
true
c74544fbb857fca7f0d5cdc82fb7a75267cef4ea
Rust
Lulzx/dynamaze
/src/player.rs
UTF-8
1,154
3.8125
4
[]
no_license
//! Player information use serde::{Deserialize, Serialize}; use crate::colors::Color; /// The ID assigned to a player pub type PlayerID = u64; /// Information about a player #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Player { /// Name pub name: String, /// Token color pub color: Colo...
true
285e69245d67256bc4da064da164c7e691825268
Rust
DAigory/Exercism
/rust/bob/src/lib.rs
UTF-8
518
3.46875
3
[]
no_license
pub fn reply(value: &str) -> String { if value.is_empty() { "Fine. Be that way!".to_string() } else if test_upper_alphabetic(value) { "Whoa, chill out!".to_string() } else if test_question(value) { "Sure.".to_string() } else { "Whatever.".to_string() } } ...
true
8dc6d8aca21fa234d252ce23cf526cb9b1d96cfd
Rust
fiburonsk/maze-rs
/src/prims.rs
UTF-8
2,643
2.765625
3
[]
no_license
use rand::{rngs::StdRng, Rng, SeedableRng}; use super::maze::{Blocks, Maze, Part, Pos}; use super::shared::{self, ChangeBoard, Direction, Movement, Progress}; use std::io::{self, Write}; use std::thread; use std::time::Duration; fn walls_for(pos: &Pos, m: &Maze) -> Blocks { shared::all_directions() .iter(...
true
5f7548c5c63981212b1fb1fccf7094743e51f8f7
Rust
C-W-M-Oliver8012/genetic_algorithm
/src/nn.rs
UTF-8
5,382
3.15625
3
[]
no_license
use rand; #[derive(Copy, Clone, PartialEq)] enum NodeType { Bias, Input, Hidden, Output, } #[derive(Copy, Clone)] pub struct Node { node_type: NodeType, value: f64, layer: usize, } #[derive(Copy, Clone)] pub struct Connection { input: usize, output: usize, weight: f64, } #[derive(Clone)] pub struct NN { ...
true
23b00f67bafd4dd6aa91df0067c78f4e3336d280
Rust
seanwallawalla-forks/nushell
/crates/nu-command/src/commands/filesystem/save.rs
UTF-8
8,503
2.640625
3
[ "MIT" ]
permissive
use crate::prelude::*; use nu_engine::{UnevaluatedCallInfo, WholeStreamCommand}; use nu_errors::ShellError; use nu_protocol::{ hir::ExternalRedirection, Primitive, Signature, SyntaxShape, UntaggedValue, Value, }; use nu_source::Tagged; use std::path::{Path, PathBuf}; pub struct Save; macro_rules! process_unknown ...
true
bb2dd1e1c8baaf9daf2421c33501ccf436195c7e
Rust
nwn/implore
/tests/fail/partial_autoref_unary.rs
UTF-8
219
2.5625
3
[]
no_license
use implore::impl_op; #[derive(Copy, Clone, PartialEq, Eq, Debug)] struct X; #[impl_op(autoref)] fn neg(rhs: X) -> X { rhs } fn partial_negation() { assert_eq!(X, -X); assert_eq!(X, -&X); } fn main() {}
true
e8b00c40f28dfd846d205ba45896c9b0d3024d7c
Rust
shaunbennett/lucis-web
/lucis/src/raytrace.rs
UTF-8
7,177
2.6875
3
[ "MIT" ]
permissive
use crate::geometry::volume::VolumetricSolid; use crate::geometry::Ray; use crate::scene::{Color, Intersect, Light, SceneNode, Scene}; use nalgebra::{convert, Affine3, Isometry, Point3, Rotation3, Vector3, U3}; use rand::{thread_rng, Rng}; use web_sys::ImageData; use wasm_bindgen::{JsCast, Clamped}; use wasm_bindgen::...
true
9d3dc0b1f31696965740ad8ca9159c5b5d3db802
Rust
fluxsocial/Holochain-Conductor-Agent-Generator
/src/main.rs
UTF-8
6,023
2.78125
3
[]
no_license
use std::{fs, str, process::{Command, Stdio}}; use clap::{Arg, App}; pub mod conductor_strings; pub mod write; pub mod create; fn get_current_config() -> String { fs::read_to_string("./config.toml").expect("Unable to read file") } pub fn path_exists(path: &str) -> bool { fs::metadata(path).is_ok() } pub fn ...
true
4772038ac86770caf9f9b08ede7c5a9c4762b78e
Rust
gribbet/rust-tide-test
/src/mock.rs
UTF-8
1,555
2.890625
3
[]
no_license
use crate::{ error::Error, model::{CreateUser, User}, service::Service, }; use async_std::sync::{Arc, RwLock}; use async_trait::async_trait; use core::cmp::max; #[derive(Clone)] pub struct MockService { users: Arc<RwLock<Vec<User>>>, } impl MockService { pub fn new() -> Self { MockService ...
true
469d6807275f2914376dd02188073e2465c37df9
Rust
tesuji/rust_inline_bug
/src/y2020/day_03.rs
UTF-8
1,213
3.109375
3
[]
no_license
pub fn solve(){ const INPUT : &str = include_str!("../../inputs/2020/3"); let map : Vec<Vec<bool>> = INPUT .lines() .map(|l| l.chars().map(|c| c == '#').collect::<Vec<bool>>()) .collect(); let mut x3 = 0; let mut trees3 = 0; for line in map.iter() { trees3 += if l...
true
fbae3f6a780307b107c6d41af388772e7d6a3ea3
Rust
jonored/ledger-nanos-sdk
/src/buttons.rs
UTF-8
1,392
3.453125
3
[ "Apache-2.0" ]
permissive
/// Structure keeping track of button pushes /// 1 -> left button, 2 -> right button pub struct ButtonsState { pub button_mask: u8, pub cmd_buffer: [u8; 4], } impl Default for ButtonsState { fn default() -> Self { ButtonsState { button_mask: 0, cmd_buffer: [0u8; 4], ...
true
2720f29778be3f1a49117468d84eef4f5f8dffd6
Rust
bytecodealliance/wasmtime
/crates/test-programs/wasi-tests/src/bin/path_rename_dir_trailing_slashes.rs
UTF-8
1,499
2.78125
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
use std::{env, process}; use wasi_tests::open_scratch_directory; unsafe fn test_path_rename_trailing_slashes(dir_fd: wasi::Fd) { // Test renaming a directory with a trailing slash in the name. wasi::path_create_directory(dir_fd, "source").expect("creating a directory"); wasi::path_rename(dir_fd, "source/",...
true
23a15c9ebb233370593d4f9d91afc008acbe3d81
Rust
crypto-bank/orca
/orca/streams/poloniex/cmd.rs
UTF-8
693
3.171875
3
[]
no_license
use ::currency::{Pair, PairExt}; use ::streams::Command; /// Serializes a stream command. pub fn serialize(cmd: Command) -> String { match cmd { Command::Subscribe(ref pair) => subscribe(pair), Command::Unsubscribe(ref pair) => unsubscribe(pair), } } /// Creates a `subscribe` message for a gi...
true
0174464282eea5eb3b580613d4816ab71ca042b8
Rust
solana-labs/rust-bpf-sysroot
/src/core/src/str/converts.rs
UTF-8
5,716
3.796875
4
[ "Apache-2.0" ]
permissive
//! Ways to create a `str` from bytes slice. use crate::mem; use super::validations::run_utf8_validation; use super::Utf8Error; /// Converts a slice of bytes to a string slice. /// /// A string slice ([`&str`]) is made of bytes ([`u8`]), and a byte slice /// ([`&[u8]`][byteslice]) is made of bytes, so this function ...
true
1c3c6968a0fda2030fd0f7c8e08bd94f4c4554e8
Rust
ptrkrlsrd/Advent-Of-Code-2018
/day-0401/src/main.rs
UTF-8
1,665
3.078125
3
[]
no_license
use std::fs::File; use std::io::{BufRead, BufReader}; use std::collections::HashMap; use regex::Regex; use chrono::*; extern crate chrono; extern crate regex; #[derive(Debug)] enum EventType { Asleep, Awake, } fn main() { let file = File::open("./data.txt").expect("could not read file"); let reader =...
true
e5ed1962220e5bf8e19353e344d1cf564431e3ab
Rust
VETER1309/identity.rs
/identity_core/src/common/context.rs
UTF-8
1,015
2.90625
3
[ "Apache-2.0" ]
permissive
use core::fmt; use identity_diff::Diff; use serde::{Deserialize, Serialize}; use crate::common::{Object, Url}; /// A reference to a JSON-LD context /// /// [More Info](https://www.w3.org/TR/vc-data-model/#contexts) #[derive(Clone, PartialEq, Deserialize, Serialize, Diff)] #[serde(untagged)] pub enum Context { Url...
true
f9e0a6c0f92e6778b2c1f1bf52aa254928c6233a
Rust
CSQ223/osm_ch
/pre/src/graph_helper.rs
UTF-8
8,097
2.671875
3
[ "MIT" ]
permissive
use super::*; /// get all up edges from one node #[allow(dead_code)] pub fn get_edges_from_id(ids: Vec<EdgeId>, edges: &[Way]) -> Vec<Way> { return ids.iter().map(|x| edges[*x]).collect(); } /// get all up edge-ids from one node #[allow(dead_code)] pub fn get_up_edge_ids(node: NodeId, up_offset: &[EdgeId]) -> Vec...
true
677201be06f4ab3f5b0e60813be65a0b43f6463f
Rust
Cutii/enocean
/src/communicator.rs
UTF-8
6,431
2.859375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-unknown" ]
permissive
use crate::enocean::*; use serialport; use std::time::Duration; use std::io; use std::io::Write; use std::sync::mpsc; use crate::ParseEspErrorKind; pub fn start( port_name: String, enocean_event: mpsc::Sender<ESP3>, enocean_command: mpsc::Receiver<ESP3>, ) -> Result<(), std::io::Error> { // Set set...
true
75a6f65353373a896bdb18bc468cf115fc16a574
Rust
JunSuzukiJapan/circle_buffer
/src/lib.rs
UTF-8
11,197
3.78125
4
[ "MIT" ]
permissive
extern crate num; use std::ops::{Index, IndexMut}; use std::slice::{Iter, IterMut}; use num::Zero; /// A circular buffer. pub struct CircleBuffer<T> where T: Clone { capacity: usize, vec: Vec<T>, cur_start: usize, } impl<T> CircleBuffer<T> where T: Clone { /// Creates a new empty `CircleBuffer<T>` wi...
true
476692b79ca5b950d0adcf9ea1ca50648e7d90ba
Rust
mrsekut/PracticeProgrammingLanguage
/Rust/design_pattern/iterator.rs
UTF-8
855
3.328125
3
[]
no_license
// https://qiita.com/mopp/items/3794dc955f7dc9d8ca63#iterator-%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3 #[derive(Debug)] struct Container { buf: Vec<u32>, index: usize, } impl Container { fn new() -> Container { Container { buf: Vec::new(), index: 0, } } fn add(&...
true
745a201a5cb733ee8d5ef7a1b1113d38a0a23c1c
Rust
SchrodingerZhu/toylibc
/src/io/basic.rs
UTF-8
1,921
2.515625
3
[]
no_license
#![allow(non_camel_case_types)] use syscalls::*; use crate::c_style::*; use crate::types::*; #[repr(C)] pub struct _IO_FILE { _IO_read_ptr: *const u8, /* Current read pointer */ _IO_read_end: *const u8, /* End of get area. */ _IO_read_base: *const u8, /* Start of putback and get area. */ ...
true
52f7b90b6c0536a97d41d13b8699d291f47958c2
Rust
MeowningMaster/my_kattis_solution
/modulo/src/main.rs
UTF-8
353
2.828125
3
[]
no_license
use std::{collections::HashSet, io::{stdin, BufRead}}; fn main() { let nums: Vec<i32> = stdin() .lock() .lines() .map(|x| x.unwrap().trim_end().parse().unwrap()) .collect(); let s = nums .into_iter() .fold(HashSet::new(), |mut acc, x| {acc.insert(x % 42); acc});...
true
138ff0a3fd9ed1adfd051e3d0fa33b73edf00b60
Rust
panicbit/repulse
/src/channel.rs
UTF-8
2,059
3.015625
3
[]
no_license
use num_enum::{TryFromPrimitive, IntoPrimitive}; pub const CHANNELS_MAX: usize = 32; #[derive(TryFromPrimitive, IntoPrimitive, Debug, Copy, Clone)] #[repr(u8)] pub enum ChannelPosition { Invalid = u8::MAX, Mono = 0, /// Apple, Dolby call this 'Left' FrontLeft, /// Apple, Dolby call this 'Right' ...
true
e16f6694262e156a86fbfe9511da0ecc27d6d494
Rust
Urgau/rsix
/src/net/socketpair.rs
UTF-8
615
2.625
3
[ "MIT", "Apache-2.0", "LLVM-exception" ]
permissive
use crate::imp; use crate::io::{self, OwnedFd}; use crate::net::{AddressFamily, Protocol, SocketFlags, SocketType}; /// `socketpair(domain, type_ | accept_flags, protocol)` /// /// # References /// - [POSIX] /// - [Linux] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/socketpair.html ///...
true
edd227a7da35d7fb7153f233b5ea2cc97287bee2
Rust
jpatel531/learning-rust
/syntax/generics.rs
UTF-8
973
3.34375
3
[]
no_license
/* example of Option<T> in Rust's stdlib, which is generic */ enum Option<T> { Some(T), None, } // <T> indicates it's a generic type. // Inside the declaration of our enum, wherever we see a T, // we substitute that type for the same type used in the generic. let x : Option<i32> = Some(5); // Rust is happy...
true
b8f43bd09351a558ff36b8b6b4b93d0f0ad873c0
Rust
Acasune/aoj-rust
/ITP1/ITP1-7/itp1-7-a.rs
UTF-8
795
2.71875
3
[]
no_license
use std::{io::*, usize}; fn main() { let stdin = stdin(); let mut lines = stdin.lock().lines(); loop { let line = lines.next().unwrap().unwrap(); let mut args = line.split_whitespace().map(|s| s.parse::<i32>().unwrap()); let m = args.next().unwrap(); let f = args.next().unwrap(); ...
true
c9185c3f68c1b4cd155242fe6b8388f65594417c
Rust
bombless/rustc-chinese
/src/test/run-pass/ranges-precedence.rs
UTF-8
1,309
3.0625
3
[ "MIT", "Apache-2.0", "Unlicense", "LicenseRef-scancode-other-permissive", "BSD-3-Clause", "bzip2-1.0.6", "NCSA", "ISC", "LicenseRef-scancode-public-domain", "BSD-2-Clause" ]
permissive
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // 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 ...
true
3f621cca0b6eb652603bafad2806f1e69146788e
Rust
opensource-assist/fuschia
/src/connectivity/bluetooth/profiles/bt-avrcp/src/packets/player_application_settings/get_value_text.rs
UTF-8
12,428
2.890625
3
[ "BSD-3-Clause" ]
permissive
// Copyright 2019 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 std::u8; use crate::packets::player_application_settings::PlayerApplicationSettingAttributeId; use crate::packets::*; #[derive(Debug)] /// AVRCP 1.6....
true
55b3d525311e41e51bdb317ad384ae61c72fb90c
Rust
MDGSF/JustCoding
/rust-leetcode/leetcode_811/src/solution1.rs
UTF-8
1,094
3.09375
3
[ "MIT" ]
permissive
use std::collections::HashMap; impl Solution { pub fn subdomain_visits(cpdomains: Vec<String>) -> Vec<String> { let mut m = HashMap::new(); for cpdomain in cpdomains.iter() { let space_idx = cpdomain.find(' ').unwrap(); let num: i32 = cpdomain[..space_idx].parse().unwrap(); *m.entry(&cpdoma...
true
aa49f7c7aa7c5efd77b4cc964908f82d9a7f6d88
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/serde_json/src/lexical/bhcomp.rs
UTF-8
4,169
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
use super::bignum::*; use super::digit::*; use super::exponent::*; use super::float::*; use super::math::*; use super::num::*; use super::rounding::*; use core::{cmp, mem}; fn parse_mantissa<F>(integer: &[u8], fraction: &[u8]) -> Bigint where F: Float, { let small_powers = POW10_LIMB; let ...
true
7b8896a3d3bb765283b134ebf74b342ac885ebb5
Rust
SiegeLord/RustAllegro
/examples/user_events.rs
UTF-8
880
2.671875
3
[ "Apache-2.0", "Zlib" ]
permissive
// This file is released into Public Domain. extern crate allegro; use allegro::*; #[derive(Debug)] struct Foo; impl Drop for Foo { fn drop(&mut self) { println!("Foo destructor"); } } allegro_main! { let core = Core::init().unwrap(); let mut source = UserEventSource::new(&core); let q = EventQueue::new(&c...
true
94ca3993771d852d8ef9dea6bd5e89b5be18e786
Rust
norambah1/habitat
/components/net/src/app/dispatcher.rs
UTF-8
7,184
2.5625
3
[ "Apache-2.0" ]
permissive
// Copyright (c) 2017 Chef Software Inc. and/or applicable contributors // // 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 r...
true
24dc744cd2226b5b91674f4cc4aeac78890bddc5
Rust
libp2p/rust-libp2p
/identity/src/peer_id.rs
UTF-8
8,616
2.703125
3
[ "MIT" ]
permissive
// Copyright 2018 Parity Technologies (UK) Ltd. // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), // to deal in the Software without restriction, including without limitation // the rights to use, copy, modify, mer...
true
3dc12b2059872beae027413e965885ae52a34ff3
Rust
winksaville/fuchsia
/third_party/rust_crates/vendor/async-trait/tests/test.rs
UTF-8
4,846
2.75
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
use async_trait::async_trait; #[async_trait] trait Trait { type Assoc; async fn selfvalue(self) where Self: Sized, { } async fn selfref(&self) {} async fn selfmut(&mut self) {} async fn required() -> Self::Assoc; async fn elided_lifetime(_x: &str) {} async fn expli...
true
69953af3daf879e2b80c4193c63f2ad025417b16
Rust
rossmacarthur/sheldon
/src/lock/file.rs
UTF-8
2,332
2.953125
3
[ "Apache-2.0", "MIT" ]
permissive
//! The raw lock file. use std::collections::BTreeMap; use std::fs; use std::path::{Path, PathBuf}; use anyhow::{Context as ResultExt, Error, Result}; use indexmap::IndexMap; use serde::{Deserialize, Serialize}; use crate::config::InlinePlugin; use crate::context::Context; /// A locked `Config`. #[derive(Debug, Des...
true
e04dccd868238d69adaf4cba360604749afe5ab9
Rust
Jimskapt/rust-book-fr
/FRENCH/listings/ch02-guessing-game-tutorial/listing-02-03/src/main.rs
UTF-8
641
2.875
3
[ "Apache-2.0", "MIT", "Unlicense", "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "NCSA" ]
permissive
// ANCHOR: all use std::io; // ANCHOR: ch07-04 use rand::Rng; fn main() { // ANCHOR_END: ch07-04 println!("Devinez le nombre !"); // ANCHOR: ch07-04 let nombre_secret = rand::thread_rng().gen_range(1..101); // ANCHOR_END: ch07-04 println!("Le nombre secret est : {}", nombre_secret); prin...
true
d24bd0d506782de1d09581402a7d8f3a335de702
Rust
0xdeafbeef/nekoton
/nekoton-abi/src/message_builder.rs
UTF-8
1,200
2.765625
3
[ "Apache-2.0" ]
permissive
use anyhow::Result; use ton_abi::{Contract, Function, Token}; use super::{BuildTokenValue, PackAbiPlain}; #[derive(Debug)] pub struct MessageBuilder<'a> { function: &'a Function, inputs: Vec<Token>, } impl<'a> MessageBuilder<'a> { pub fn new(contract: &'a Contract, function_name: &str) -> Result<Self> { ...
true
b0191c8bda734551aea3aff8989d04188cbd1b7a
Rust
dem-net/flatgeobuf
/src/rust/src/http_reader.rs
UTF-8
6,717
2.5625
3
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::header_generated::flat_geobuf::*; use crate::http_client::BufferedHttpRangeClient; use crate::packed_r_tree::{self, PackedRTree}; use crate::properties_reader::FgbFeature; use crate::{NodeItem, HEADER_MAX_BUFFER_SIZE, MAGIC_BYTES}; use byteorder::{ByteOrder, LittleEndian}; use geozero::error::{GeozeroError, ...
true
4bd09680e1fa820f355cfa82333f9a71f56dbca9
Rust
cronning9/math-interpreter
/src/tokens.rs
UTF-8
553
3.46875
3
[]
no_license
use std::fmt::Debug; #[derive(Debug)] pub enum ArithOperators { Plus, Minus, Times, Div, } #[derive(Debug)] pub enum ComparisonOperators { GreaterThan, GreaterThanOrEqual, LessThan, LessThanOrEqual, Equal, } #[derive(Debug)] pub enum TokenType { Identifier(String), // we'l...
true
87b983a8713d0b45fe8106a6d2963107aa2fab28
Rust
dekellum/olio
/src/io/gather.rs
UTF-8
2,570
3.484375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::io; use std::io::{Cursor, Read}; /// A specialized reader presenting a continuous (gathered) `Read` interface /// over N non-contiguous byte buffers. /// /// This is more efficient than the current implementation of /// `std::io::Cursor::chain` for many reads over many buffers. See the /// associated benchmar...
true
1f1b8e1b6d83ceebd91c62f846bdd232d1d96b7d
Rust
sapir/gcc-rust-tests
/src/enums2.rs
UTF-8
401
3.84375
4
[]
no_license
pub enum Option<T> { None, Some(T), } impl<T> Option<T> where T: Copy, { #[inline] pub fn make_an_option(x: T) -> Option<T> { Option::Some(x) } } impl Option<i32> { pub fn unwrap(self) -> i32 { match self { Option::None => 0, Option::Some(x) => x, ...
true
5c189f0b4ff568a0b62adf806b1105e393c254dd
Rust
zCloak-Network/winterfell
/common/src/options.rs
UTF-8
5,621
2.75
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 fri::FriOptions; use math::field::StarkField; use serde::{Deserialize, Serialize}; // TYPES AND INTERFACES // =======================...
true
ebfd04e6740b48f24baca6600bf710b7c5e21706
Rust
gamozolabs/rust_mips_nt4
/src/rand.rs
UTF-8
447
3.1875
3
[]
no_license
//! Xorshift64 use core::cell::Cell; /// Xorshift64 implementation pub struct Rng(Cell<u64>); impl Rng { /// Create a seeded RNG pub const fn new(seed: u64) -> Self { Self(Cell::new(seed)) } /// Get the next RNG value pub fn next(&self) -> u64 { let mut seed = self.0.get(); ...
true
548bbcc1438ec984b5cba05b6a3105050374e817
Rust
Quadriphobs1/rust-lang
/repeated-times/src/main.rs
UTF-8
577
3.765625
4
[]
no_license
/// Count the number of times we have repeasted item in the vec fn main() { let vec = vec![ 1, 2, 3, 3, 4, 2, 3, 2, 3, 4, 5, 3, 4, 5, 2, 4, 5, 6, 3, 5, 6, 4, 2, 4, 6, 7, 4, 4, 5, 6, 7, 5, 4, 5, 8, 89, 9, 8, 7, 6, 5, 5, 6, 7, 8, 8, 6, 5, 4, 5, 6, 7, 8, 8, 9, 8, 4, 5, 6, 4, 3, 4, 5, 6, 4, 3, 4...
true
ebcac9337fddb033a6e9d830ae2be6856b96e0a1
Rust
codota/mac_address
/src/iter/linux.rs
UTF-8
958
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use nix::{ifaddrs, sys::socket::SockAddr}; use {MacAddress, MacAddressError}; use iter::Interface; /// An iterator over all available MAC addresses on the system. pub struct InterfaceIterator { iter: std::iter::FilterMap< ifaddrs::InterfaceAddressIterator, fn(ifaddrs::InterfaceAddress) -> Option<In...
true
08d1aef75314f5419fd7c36ed4228558c10ba640
Rust
neoeinstein/stats_alloc
/tests/nightly.rs
UTF-8
499
2.546875
3
[]
no_license
#![cfg(feature = "nightly")] extern crate stats_alloc; use stats_alloc::{Region, StatsAlloc}; use std::alloc::System; #[global_allocator] static GLOBAL: StatsAlloc<System> = StatsAlloc::system(); #[test] fn example_using_region() { let reg = Region::new(&GLOBAL); let x: Vec<u8> = Vec::with_capacity(1_024); ...
true
2872be35b037acd942cefae66ea781e5636cf565
Rust
launchbadge/sqlx
/sqlx-postgres/src/types/bool.rs
UTF-8
1,077
2.71875
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::decode::Decode; use crate::encode::{Encode, IsNull}; use crate::error::BoxDynError; use crate::types::Type; use crate::{PgArgumentBuffer, PgHasArrayType, PgTypeInfo, PgValueFormat, PgValueRef, Postgres}; impl Type<Postgres> for bool { fn type_info() -> PgTypeInfo { PgTypeInfo::BOOL } } impl...
true
60072589976890c66b30f3fb6de7e4aa3d8fe556
Rust
rust-lang/rustlings
/exercises/hashmaps/hashmaps2.rs
UTF-8
2,638
3.90625
4
[ "MIT" ]
permissive
// hashmaps2.rs // // We're collecting different fruits to bake a delicious fruit cake. For this, // we have a basket, which we'll represent in the form of a hash map. The key // represents the name of each fruit we collect and the value represents how // many of that particular fruit we have collected. Three types of ...
true
8a2d87afed19c143817dec355616dedcdb8ee90b
Rust
jontymorris/The-Prophet
/stocks_core/src/stats.rs
UTF-8
2,576
3.296875
3
[]
no_license
use rgsl::fit::linear; use rgsl::statistics::correlation; pub fn get_percent_change(new_value: f64, previous_value: f64) -> f64 { (new_value - previous_value) / previous_value * 100.0 } pub fn get_best_fit(values: &Vec<f64>) -> (f64, f64) { let mut x_points: Vec<f64> = Vec::with_capacity(values.len()); fo...
true
63fcb0afda49d0f047b9d684c0fa85855fdcaae5
Rust
Daivasmara/rust_book
/04/slice/src/main.rs
UTF-8
899
4
4
[]
no_license
// string literals are slices // let s = "hello world" -> slices, thus immutable fn main() { let s = String::from("Hello world"); // string slices let hello = &s[..5]; // 0-4 let world = &s[6..11]; // 6-10 println!("{} {}", hello, world); let fword = first_word(&s[..]); println!("first wor...
true
ef385571c47c843a42873f6709740cc1297f03d8
Rust
dmelcer9/advent-of-code-2020
/src/1/main.rs
UTF-8
546
2.734375
3
[]
no_license
use std::fs::File; use std::io::prelude::*; use std::io::BufReader; use itertools::Itertools; fn main() -> std::io::Result<()> { let file = File::open("inputs/input1")?; let buf_reader = BufReader::new(file); let lines: Vec<u32> = buf_reader.lines().map(|s| s.unwrap().parse().unwrap()).collect(); if l...
true
e50346ce7d100cf8d59ddd6f843246de4357f449
Rust
DLSLegacy/exercism-rust
/etl/src/lib.rs
UTF-8
316
2.53125
3
[]
no_license
use std::collections::BTreeMap; pub fn transform(input: &BTreeMap<i32, Vec<String>>) -> BTreeMap<String, i32> { input .iter() .flat_map(|(&k, vec)| { vec.into_iter() .map(|v| (v.to_lowercase(), k)) .collect::<Vec<_>>() }) .collect() }
true
f93d94d00b732433527b002a5db18d118ab2ac9d
Rust
odisei369/rust_py_exercises
/ex2_odd_or_even/src/main.rs
UTF-8
584
3.4375
3
[]
no_license
use std::io::{self, Write}; fn main() { let name = read_line("Provide number: "); let value: i32 = name.parse().expect("Can't parse provided number"); println!("Value {} is {:?}", value, if value % 2 == 0 { "even" } else { "odd" }); } fn read_line(message :&str) -> String { print!("{}", message); ...
true
5562dbb18e14173e8931941c07ab28ad6b535d59
Rust
bouzuya/rust-atcoder
/cargo-atcoder/contests/nikkei2019-qual/src/bin/a.rs
UTF-8
219
2.59375
3
[]
no_license
use proconio::input; fn main() { input! { n: usize, a: usize, b: usize, }; let max = std::cmp::min(a, b); let min = (b + a).saturating_sub(n); println!("{} {}", max, min); }
true
76fd597bf3d32e19e16e6ef5fda7e7d4b3dc2e11
Rust
vrkansagara/dotfiles
/pkg/overviews/src/main.rs
UTF-8
2,308
2.765625
3
[ "CC0-1.0" ]
permissive
use reqwest::{ blocking::{get, Client}, StatusCode, }; use serde::Deserialize; use std::{fs, path::Path, process::Command}; const URL: &str = "https://ai7o5ij8d5-dsn.algolia.net/1/indexes/*/queries?&x-algolia-application-id=AI7O5IJ8D5&x-algolia-api-key=7f1a509e834f885835edcfd3482b990c"; const BODY: &str = r#"{"req...
true
a6681f9db0181a7d988691d15e272a706f806374
Rust
museun/comb
/src/adapters/tokens.rs
UTF-8
842
2.8125
3
[ "0BSD" ]
permissive
use crate::*; #[derive(Debug, Clone)] pub struct Tokens<A: Clone + PartialEq>(Vec<A>); impl<A: Clone + PartialEq> Tokens<A> { pub(crate) fn new(list: Vec<A>) -> Self { Self(list) } } impl<A: Clone + PartialEq> Scanner for Tokens<A> { type Input = A; type Output = Vec<A>; fn scan(&self, s...
true
23da78d3697a57a4635ee6ad4983b7a3a341debb
Rust
wotsushi/competitive-programming
/agc/022/b.rs
UTF-8
808
2.78125
3
[ "MIT" ]
permissive
#![allow(non_snake_case)] #![allow(unused_variables)] #![allow(dead_code)] fn main() { let N: i64 = { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse().unwrap() }; let m = std::cmp::min(5000, 2 * ((N - 2) / 2)); let res = ...
true
2bb1c0cf52b0a6c83e8ed66842c9fb5baaeeff77
Rust
marmelab/eratosthenes
/crate/src/lib.rs
UTF-8
1,880
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
#[macro_use] extern crate cfg_if; extern crate web_sys; extern crate wasm_bindgen; use wasm_bindgen::prelude::*; use std::iter::Peekable; cfg_if! { // When the `console_error_panic_hook` feature is enabled, we can call the // `set_panic_hook` function to get better error messages if we ever panic. if #[cf...
true
ab3473d097c3c749d7b820492b1a18525ed7eda4
Rust
asherkin/sm-ext-rs
/examples/basic.rs
UTF-8
559
2.578125
3
[]
no_license
//! Minimal example of a valid SourceMod extension. use sm_ext::{IExtension, IExtensionInterface, IShareSys, SMExtension}; #[derive(Default, SMExtension)] #[extension(name = "Rusty", description = "Sample extension written in Rust")] pub struct MyExtension; impl IExtensionInterface for MyExtension { fn on_extens...
true
7e2a017b99a770db26e936777b1f8bb472c7fff9
Rust
mesalock-linux/crates-io
/vendor/stdweb/src/webapi/date.rs
UTF-8
33,165
3.1875
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT", "CC-BY-SA-3.0" ]
permissive
use webcore::value::Reference; use webcore::try_from::TryInto; /// [(JavaScript docs)](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date) /// https://www.ecma-international.org/ecma-262/6.0/#sec-date-constructor #[derive(Clone, Debug, PartialEq, Eq, ReferenceType)] #[reference(instance...
true
6d62a8c81d8505efb2fd5546386f74eb19fb5089
Rust
brian-gavin/um-32
/src/main.rs
UTF-8
788
2.875
3
[]
no_license
use std::{env, fs}; use um32::{read_scroll, Cpu}; enum Mode { Execute, Disassemble, } struct Opts { mode: Mode, scroll: fs::File, } fn main() { let args = env::args().collect::<Vec<_>>(); let mode = match args[1].as_str() { "-e" => Mode::Execute, "-d" => Mode::Disassemble, ...
true
7b42a03e6cae2adae6ed4063088933c04416e573
Rust
psychon/x11rb
/x11rb-protocol/benches/proto_connection.rs
UTF-8
12,138
2.8125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Benchmark the `x11rb_protocol::Connection` type's method, at varying levels of //! capacity. use criterion::{black_box, criterion_group, criterion_main, BatchSize, Criterion}; use std::{ io::{Read, Write}, mem::{replace, size_of}, net::{TcpListener, TcpStream}, thread, }; use x11rb_protocol::{ ...
true
e02086e6d4e7116865eaf63219bf136d96af16fe
Rust
Sreyas-Sreelal/zas
/src/http/app_manager.rs
UTF-8
1,259
2.828125
3
[ "MIT" ]
permissive
use toml::Value; use std::collections::HashMap; use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; use std::str::FromStr; use crate::error::Error; pub struct AppManager { apps: HashMap<String, u16>, } impl AppManager { pub fn new() -> Result<AppManager, Error> { let config_path = ...
true
7db8e6f842596a8b9321409db89c59201d943102
Rust
PiotrGog/simple-webserver
/multi-threaded-server/src/thread_pool.rs
UTF-8
1,247
3.046875
3
[]
no_license
use std::sync::mpsc; use std::sync::Arc; use std::sync::Mutex; use crate::message::Message; use crate::worker::Worker; pub struct ThreadPool { workers: Vec<Worker>, sender: mpsc::Sender<Message>, } impl ThreadPool { pub fn new(number_of_threads: usize) -> ThreadPool { assert!(number_of_threads > ...
true
a2338c5e14840d2836f49a272e8a86fb1281fa97
Rust
zacharysang/sangzf-compiler
/src/llvm_utils.rs
UTF-8
2,739
2.71875
3
[]
no_license
/* // macro to quickly create c strings from rust string literals // source: https://gist.githubusercontent.com/jayphelps/ee06dad051eb30d10982535958ad059a/raw/eeb9a68eb0fb9653a4b3af40dee75c4558d43238/main.rs // usage: c_str!("hello, world.") #[macro_export] macro_rules! c_str { ($s:expr) => ( // take s and ...
true
7bd7accb825ff83db55c675034aa3caaf9a5a275
Rust
C-W-M-Oliver8012/NeuralNetwork
/src/nn.rs
UTF-8
5,397
2.828125
3
[]
no_license
use crate::matrix::Matrix; pub struct NeuralNetwork { topology: Vec<usize>, weights: Vec<Matrix>, bias: Vec<Matrix>, z: Vec<Matrix>, a: Vec<Matrix>, error_l: Matrix, learning_rate: f64, } impl NeuralNetwork { pub fn new(topology: Vec<usize>, learning_rate: f64) -> Result<NeuralNetwork,...
true
411fcb507b7b57915b10ce33344ed3d585bdcd9a
Rust
donpdonp/stork
/src/main.rs
UTF-8
2,877
2.671875
3
[]
no_license
extern crate clap; use clap::{App, Arg, SubCommand}; mod config; mod protos; mod sjproto; const VERSION: &str = env!("CARGO_PKG_VERSION"); const NAME: &str = env!("CARGO_PKG_NAME"); const COMMANDS: [&'static str; 2] = ["reputation", "checkin"]; enum Commands { Reputation, CheckIn, NoCommand, } fn main() ...
true
b338d9e389a48a7fb710bdefff80668df57e2672
Rust
georust/geo
/geo/src/algorithm/convex_hull/qhull.rs
UTF-8
6,961
2.9375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
use super::{swap_remove_to_first, trivial_hull}; use crate::kernels::{HasKernel, Kernel, Orientation}; use crate::utils::partition_slice; use crate::{coord, Coord, GeoNum, LineString}; // Determines if `p_c` lies on the positive side of the // segment `p_a` to `p_b`. In other words, whether segment // `p_a` to `p_c` i...
true
9f7d3f9ab611eee5f091f4a1ba15021f2dc7f1ff
Rust
kamicut/advent2017
/day2/checksum/src/main.rs
UTF-8
724
3.15625
3
[ "MIT" ]
permissive
extern crate checksum; use std::env; use std::process; /// Get filename from cli args fn parse_args(args: &[String]) -> Result<String, &'static str> { if args.len() < 2 { return Err("not enough arguments"); } let filename = args[1].clone(); Ok(filename) } fn main() { let args: Vec<String...
true
379e6a96b1e02237f1172e9808a12e96489f6315
Rust
foxtrotzulu94/rust-mop
/src/src_music_brainz.rs
UTF-8
6,961
2.53125
3
[]
no_license
//All the functions needed to use the MusicBrainz API (https://musicbrainz.org/doc/Development/XML_Web_Service/Version_2) use mop_structs::{SongFile,BasicMetadata}; use mop_online::{make_get_request, percent_encode}; use xml_wrap::{XmlMap}; use std::{str,time,thread}; use std::io::{Error, ErrorKind, self}; static API...
true
c16caf4d587fd7bb2495633546cc9edb544688e6
Rust
LBdN/dead-pulsar
/render.rs
UTF-8
13,455
2.8125
3
[]
no_license
use ggez::graphics; use ggez::graphics::{DrawParam, Color, Rect, Drawable, DrawMode, Mesh, StrokeOptions}; use ggez::{Context, GameResult}; use crate::unit::*; use crate::text; use std::collections::HashMap; pub struct MeshModel{ pub polygons : Vec::<MeshModelPoly>, mesh_oidx: Option<usize>, pub dirty ...
true
e29607ef8ac6a18614d5075098f104b4cac1ca77
Rust
katharostech/parry
/src/query/distance/distance_ball_convex_polyhedron.rs
UTF-8
972
3.0625
3
[ "Apache-2.0" ]
permissive
use crate::math::{Isometry, Point, Real}; use crate::shape::{Ball, Shape}; /// Distance between a ball and a convex polyhedron. /// /// This function panics if the input shape does not implement /// both the ConvexPolyhedron and PointQuery traits. #[inline] pub fn distance_ball_convex_polyhedron( pos12: &Isometry<...
true
7a3ad59671c8837d8268fd54680524e7f5eabaa9
Rust
mopp/nand2tetris
/projects/06/assembler/src/parser.rs
UTF-8
5,883
3.578125
4
[]
no_license
use std::io::BufRead; #[derive(Debug, PartialEq, Eq)] pub enum CommandType { Address, Compute, Label, } #[derive(Debug)] pub struct Parser<'a, T: BufRead> { contents: &'a mut T, current_line: String, has_next: bool, } impl<'a, T: BufRead> Parser<'a, T> { pub fn new(contents: &'a mut T) ->...
true
59d9d70a0fc6c0939a0e2ce7dc4e37f6a72d9edc
Rust
Sequoja/tRust
/examples/vanitykey.rs
UTF-8
3,382
3.1875
3
[]
no_license
use blake2::{Blake2b, Digest}; use crossbeam::channel; use sha2::Sha512; use sha3::Sha3_512; use std::thread; static MAX_LEN: usize = 1; fn producer(sender: channel::Sender<u128>) { let mut salt_gen = SaltGen { counter: 0 }; while sender.send(salt_gen.new_salt()).is_ok() {} } struct SaltGen { counter: u1...
true
c180bae66c1da4d88582c1129d441ca2daea3137
Rust
divvun/pahkat-client-sdk-swift
/crate/pahkat-common/src/database/user.rs
UTF-8
729
2.828125
3
[ "Apache-2.0" ]
permissive
use uuid::Uuid; use super::super::DatabaseError; use super::Database; use crate::database::models::NewUser; pub fn create_user( database: &Database, username: &str, token: &str, ) -> std::result::Result<usize, DatabaseError> { let parsed_uuid = Uuid::parse_str(token); match parsed_uuid { ...
true
62605253aa3d9981ff1575e8456da4eedc37d625
Rust
czyczk/LeetCode
/rust/lc-58/src/main.rs
UTF-8
352
2.78125
3
[]
no_license
mod solution; use solution::Solution; fn main() { assert_eq!(5, Solution::length_of_last_word("Hello World".to_owned())); assert_eq!( 4, Solution::length_of_last_word(" fly me to the moon ".to_owned()) ); assert_eq!( 6, Solution::length_of_last_word("luffy is sti...
true
6a20559be8e5c70ad5b9297aefc01ca4bd5872c4
Rust
jdegrand/Rust-Maze-Solver
/soln/maze/src/main.rs
UTF-8
9,980
2.75
3
[]
no_license
// @author: Joey DeGrand, jpd3263@rit.edu // Date: 03/23/2021 use std::fmt::Write; use std::fs; use std::env; use std::process; use std::fmt::Display; use std::collections::HashSet; use std::collections::HashMap; use std::collections::VecDeque; use rand::Rng; extern crate colored; use colored::*; fn main() { ...
true
7d3ac6746d0bb01d9b860ee61462994b24486ad7
Rust
waynedupreez1/eeprom34c04-rs
/src/error.rs
UTF-8
396
2.84375
3
[ "Apache-2.0", "MIT" ]
permissive
/// Error Types for library /// /// Wayne du Preez /// /// All possible errors in this crate #[derive(Debug)] pub enum Error<E> { /// I²C bus error I2C(E), /// Too much data passed for a write TooMuchData, /// Memory address is out of range InvalidAddr, /// Quad Convertion Failed Inva...
true
fa1c743a5b12ceee0a49864eb0fe646bd86cbc93
Rust
ukchukx/diesel-sqlite
/src/db/models.rs
UTF-8
2,356
3.0625
3
[]
no_license
use uuid::Uuid; use serde::{Deserialize, Serialize}; use diesel::prelude::*; use super::schema::users; use super::schema::users::dsl::users as user_dsl; #[derive(Debug, Deserialize, Serialize, Queryable, Insertable)] #[table_name = "users"] pub struct User { pub id: String, pub email: Option<String>, pub...
true
cd552e2aed2e25c17afcf26c9a124944fd0a72e9
Rust
Gexon/dotakiller
/src/monster/components.rs
UTF-8
7,998
2.640625
3
[]
no_license
// описание компонент монстра use tinyecs::*; use time::PreciseTime; use ::utility::enums::*; use ::utility::db_query::get_monster_graph; use ::utility::graph_parser::monster_graph_parser; /// Координаты на полигоне. #[derive(Debug, Clone, Copy, PartialEq)] pub struct PositionM { pub x: f32, pub y: f32, ...
true
987d34e204884345d048dc131de5d4a98bd5927e
Rust
amethyst/editor-core
/examples/pong/systems/bounce.rs
UTF-8
3,647
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
use crate::{ audio::{play_bounce, Sounds}, Ball, Paddle, Side, }; use amethyst::{ assets::AssetStorage, audio::{output::Output, Source}, core::transform::Transform, ecs::prelude::{Join, Read, ReadExpect, ReadStorage, System, WriteStorage}, }; use std::ops::Deref; /// This system is responsible ...
true
1497e3bec7cfee7c66a2cc8df3ecaee631de75c1
Rust
seventh-estate/seventh-estate
/src/voter_roster/voter_roster_file.rs
UTF-8
715
2.703125
3
[]
no_license
//! Module for Voter Roster File rows. use std::convert::From; use serde::{Serialize, Deserialize}; use super::VoterInfo; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct VoterRosterFileRow { pub last_name: String, pub first_name: String, pub street_address: String, pub city: String, pub...
true
4382a2aa8435790fd61950b7f911794dd8980bc0
Rust
Lukazoid/lz_diet
/src/node_mut_ext.rs
UTF-8
5,462
2.796875
3
[ "MIT" ]
permissive
use binary_tree::{NodeMut, WalkAction}; use log::{debug, trace}; use std::cell::RefCell; /// Some additional methods for `NodeMut`. pub(crate) trait NodeMutExt: NodeMut { /// Insert `new_node` in-order after `self`. `step_out` will be invoked for /// all nodes in path from (excluding) the point of insertion, t...
true
2ef3d49953083a0330c3b8372b680447b6b0fec0
Rust
richarddeveloper/AlgebraicManipulatorRust
/src/ast/pattern.rs
UTF-8
1,409
2.65625
3
[]
no_license
use env::Path; use envs::{ NameData, Namespaces }; use super::{ Type, ErrAst, ToID, ToIDMut }; use id::renamed::{ PatternID, PatternedID }; #[derive(Debug)] pub struct Patterned<S, T>(pub Pattern<S>, pub T); #[derive(Debug)] pub enum Pattern<S> { Var(S, Type<S>), Atom(Path<S>, Vec<Type<S>>), Comp(Path<S>,...
true
c2178d4133ed21ec7572a38944cae0f5372883d3
Rust
mmisono/rust-pkeys
/examples/main.rs
UTF-8
1,134
2.5625
3
[ "MIT" ]
permissive
use nix::libc::size_t; use nix::sys::mman::{mmap, MapFlags, ProtFlags}; use pkeys::*; use std::ptr; pub fn main() { const ONE_K: size_t = 1024; let pkey = pkey_alloc(0, PkeyAccessRights::PKEY_NONE).unwrap(); // Allocate memory region with a protection key let slice: &mut [u8] = unsafe { let mem...
true
d76975e5d1edb818eae6e649f799b6a350c8b990
Rust
RipleyTom/advent_of_code_2019
/src/Day10/part2.rs
UTF-8
2,676
3.171875
3
[]
no_license
use std::collections::HashSet; use std::fs::File; use std::io::Read; fn gcd(a: i64, b: i64) -> i64 { let (mut tmp_a, mut tmp_b) = (a, b); while tmp_b != 0 { let t = tmp_b; tmp_b = tmp_a % tmp_b; tmp_a = t; } if tmp_a < 0 { -tmp_a } else { tmp_a } } pub ...
true
08e829dd65313c9e41bcd9fa1e01e0081f4b5527
Rust
sec-bit/zkp-toolkit
/math/tests/fft.rs
UTF-8
9,543
2.78125
3
[ "Apache-2.0", "MIT" ]
permissive
use curve::bls12_381::{Fr, G1Projective}; use math::fft::domain::*; use math::fft::polynomial::*; use math::fft::{DensePolynomial, EvaluationDomain, SparsePolynomial}; use math::{test_rng, Field, One, PrimeField, UniformRand, Zero}; use rand::Rng; #[test] fn vanishing_polynomial_evaluation() { let rng = &mut test_...
true
cb5a8e98aad99c13f460b4780bdb2e3489a4086b
Rust
Lukas-Sturm/privacy_backend
/src/player.rs
UTF-8
3,241
2.828125
3
[]
no_license
use crate::message::{FromPlayerMessage, ToPlayerMessage}; use async_std::net::SocketAddr; use async_std::net::TcpStream; use async_tungstenite::WebSocketStream; use futures::channel::mpsc::*; use futures::*; use tungstenite::Message; pub struct Player { pub name: String, pub stream: WebSocketStream<TcpStream>,...
true
e6bbda08a4cf1746077f63e13e322f5a6ef26e4c
Rust
phasetr/mathcodes
/fundamental_for_CFD/chap4/src/fs.rs
UTF-8
880
2.875
3
[]
no_license
use std::error; use std::fs::File; use std::io::prelude::*; use std::io::BufWriter; pub fn write_csv( dir_name: &str, n: &i64, node: &usize, xs: &Vec<f64>, us: &Vec<f64>, ues: &Vec<f64>, uls: &Vec<f64>, urs: &Vec<f64>, fs: &Vec<f64>, ) -> Result<(), Box<dyn error::Error>> { let ...
true
bb2e36fb6ff68e7d3a6629d8c80c61e885d9f83d
Rust
jangernert/readability
/src/dom.rs
UTF-8
5,333
3.03125
3
[ "MIT" ]
permissive
use std::rc::Rc; use html5ever::tendril::StrTendril; use markup5ever_rcdom::NodeData::{Element, Text}; use markup5ever_rcdom::{Handle, Node}; use html5ever::Attribute; use std::str::FromStr; pub fn get_tag_name(handle: Handle) -> Option<String> { match handle.data { Element { ref name, .. } => Some(name.l...
true
d132369b08ac7e0595c4b8c6895a006b91304dcf
Rust
tomaka/asset_store
/examples/basic_web.rs
UTF-8
465
2.828125
3
[]
no_license
extern crate asset_store; use asset_store::from_url; use asset_store::AssetStore; fn main() { // Make a new asset store with google as the root let mut store = from_url("http://www.google.com/"); // Asynchronously load this file. store.load("basic_file.rs"); // Block until the file is loaded. ...
true
cfbfc90a47fa7d7c42121d28a5ffaec8b581057a
Rust
tsturzl/rs-textsearch
/src/search.rs
UTF-8
2,543
2.890625
3
[ "MIT" ]
permissive
extern crate futures_cpupool; use futures_cpupool::CpuPool; use futures_cpupool::CpuFuture; use std::collections::HashMap; use std::sync::Arc; use std::sync::RwLock; use global::Global; use index::Index; pub struct Search { pub indices: Arc< RwLock< HashMap< String, Arc<RwLock<Global>> > > >, //...
true
054cb3bee4570cc26fc6af513a957b8fec45b2fa
Rust
greymd/rust-pcre
/examples/pcredemo.rs
UTF-8
4,194
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright 2015 The rust-pcre authors. // // 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 your // option. This file may not be copied, modified, or distributed // except ac...
true
99ae4a115dca95548ec8f2d1a757617d8e158a1c
Rust
KaloyanYosifov/rust-awk
/src/lines.rs
UTF-8
2,362
3.9375
4
[]
no_license
use crate::line::Line; type LineList = Vec<Line>; #[derive(Debug)] pub struct Lines { lines: LineList, } impl Lines { pub fn new(lines: LineList) -> Self { Self { lines } } } impl Lines { pub fn len(&self) -> usize { self.lines.len() } pub fn total_lines_...
true
f517764bcd304162a20892cb8df6ec01666e125a
Rust
nestordemeure/gambit
/gambit/src/memory/measure.rs
UTF-8
2,021
3.375
3
[ "Apache-2.0" ]
permissive
use crate::distribution::Distribution; use crate::search::{Node, Tree}; use std::mem::size_of; /// counts the number of (tree, nodes, distr) in a tree fn count_elements<Distr: Distribution>(tree: &Tree<Distr>) -> (usize, usize, usize) { match tree { Tree::Node(box Node { children, .. }) => { ...
true