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
e8890cea89b788d9ae1e943c225d9268c42d8674
Rust
Bruno02468/casa_do_panico
/cdp_api/src/config.rs
UTF-8
2,184
3.03125
3
[ "Unlicense" ]
permissive
//! Implements configuration for the API. use std::convert::{TryFrom, TryInto}; use std::error::Error; use config::{Config, ConfigError}; use serde::{Serialize, Deserialize}; /// Encodes the information in an API config file. #[derive(Debug, Clone, Serialize, Deserialize)] struct ApiConfigFile { /// List of addres...
true
09219eabc73650cc3ab1ccc54018e2dc5880bb61
Rust
erikwco/mimir
/src/objecttype/mod.rs
UTF-8
3,669
2.671875
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2017 mimir developers // // 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. All files in the project carrying such notice may not be copied, // ...
true
8f35480de68bb525a0e7a64c51a2cbb7c9832e28
Rust
gnoliyil/fuchsia
/src/lib/ui/carnelian/src/scene/facets.rs
UTF-8
23,838
2.5625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2021 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::LayerGroup; use crate::{ color::Color, drawing::{ linebreak_text, measure_text_size, path_for_rectangle, path_for_rounded_rectan...
true
6e8f625f29fcc788b935e745e3436d41670197ab
Rust
jasonish/evebox
/src/querystring.rs
UTF-8
12,173
3.046875
3
[ "MIT" ]
permissive
// SPDX-FileCopyrightText: (C) 2021 Jason Ish <jason@codemonkey.net> // // SPDX-License-Identifier: MIT use anyhow::Result; use nom::branch::alt; use nom::bytes::complete::{escaped, tag, take_while1}; use nom::character::complete::{multispace0, one_of}; use nom::sequence::{delimited, preceded}; use nom::IResult; #[de...
true
ceb8443beeb8b8d837374d3fecf62e30ed177547
Rust
IamNator/go-cosmwasm
/src/error/rust.rs
UTF-8
6,002
2.90625
3
[ "Apache-2.0" ]
permissive
use errno::{set_errno, Errno}; use cosmwasm_vm::VmError; use snafu::Snafu; use crate::memory::Buffer; #[derive(Debug, Snafu)] pub enum Error { #[snafu(display("Null/Empty argument: {}", name))] EmptyArg { name: String, #[cfg(feature = "backtraces")] backtrace: snafu::Backtrace, },...
true
f9e96b6c1234a25403311c5012d72186fdd43848
Rust
sriv1211/rust-network-tools
/src/lib.rs
UTF-8
1,224
2.625
3
[]
no_license
//! An assortment of network "tool" examples using libpnet use std::net::{Ipv4Addr, Ipv6Addr}; use pnet::datalink::{MacAddr, NetworkInterface}; /// ARP functions like monitoring & making requests, and an ArpCache pub mod arp; /// NDP functions like monitoring & making requests, and an NdpCache pub mod ndp; /// Rout...
true
9a053dfae7c6e5e6dc2b8205a9d142cc7e322414
Rust
brookst/ProjectEuler
/src/problem1.rs
UTF-8
438
2.765625
3
[]
no_license
#[cfg(test)] extern crate test; fn problem1() -> isize { let mut x: isize = 0; let v: Vec<isize> = (0is..1000).collect(); for i in (0..v.len()) { if v[i] % 5 == 0 || v[i] % 3 == 0 { x += v[i]; } } x } pub fn main() { println!("Problem1: {}", problem1()); } #[test] fn test1() { mai...
true
5b3e38b7b1685df90665b5e362ee1d1fc6f7b174
Rust
dutchmartin/embedded-graphics
/embedded-graphics/src/style/styled.rs
UTF-8
1,081
3.28125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ geometry::{Dimensions, Point, Size}, transform::Transform, }; /// Styled. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Default)] pub struct Styled<T, S> { /// Primitive. pub primitive: T, /// Style. pub style: S, } impl<T, S> Styled<T, S> { /// Creates a ...
true
2bb0aefe226bf507a0b5ff2076bd421a9131bb77
Rust
sebpuetz/toponn
/toponn-utils/src/bin/toponn-prepare.rs
UTF-8
3,295
2.703125
3
[ "Apache-2.0" ]
permissive
use std::env::args; use std::fs::File; use std::path::Path; use std::process; use conllx::ReadSentence; use failure::Error; use getopts::Options; use serde_derive::Serialize; use stdinout::{Input, OrExit, Output}; use toponn::{Collector, NoopCollector, Numberer, SentVectorizer}; use toponn_utils::{CborWrite, Config, ...
true
c4afc40f54a3f9867e15d226febd443544c9404d
Rust
plotters-rs/plotters
/plotters/src/chart/mesh.rs
UTF-8
19,333
2.625
3
[ "MIT" ]
permissive
use std::marker::PhantomData; use super::builder::LabelAreaPosition; use super::context::ChartContext; use crate::coord::cartesian::{Cartesian2d, MeshLine}; use crate::coord::ranged1d::{BoldPoints, LightPoints, Ranged, ValueFormatter}; use crate::drawing::DrawingAreaErrorKind; use crate::style::{ AsRelative, Color...
true
3f40e806ca784f440c5d14f67a1dab4d47000953
Rust
dirvine/rustneat
/src/species_evaluator.rs
UTF-8
3,608
3.03125
3
[ "MIT" ]
permissive
use crossbeam::{self, Scope}; use environment::Environment; use num_cpus; use organism::Organism; use specie::Specie; use std::sync::mpsc; use std::sync::mpsc::{Receiver, Sender}; /// Calculate fitness and champions for a species pub struct SpeciesEvaluator<'a> { threads: usize, environment: &'a mut Environmen...
true
50f6c30fa3bb2ee4b05b0130bbda1fbb3b1d2e76
Rust
pandaman64/rlox
/tests/smoke_test.rs
UTF-8
2,588
3.09375
3
[]
no_license
use rlox::run; #[test] fn test_closure() { let input = r#" fun greet(name) { fun hi() { print name; } return hi; } var john = greet("John"); var bob = greet("Bob"); john(); bob(); "#; run(input, &mut vec![]).unwrap(); } #[test] fn test_negate() { let input = r#"print -(3); // expect: -...
true
3d0f1b07705e116b947519504c6f4857de9992a2
Rust
bqqbarbhg/adventofcode
/2022/15/part2.rs
UTF-8
2,479
2.796875
3
[]
no_license
#[macro_use] extern crate scan_fmt; mod common; use common::{Point, Beacon, parse}; use rayon::prelude::*; fn beacon_sdf(beacon: &Beacon, p: Point) -> i64 { let (dx, dy) = (p.0 - beacon.origin.0, p.1 - beacon.origin.1); dx.abs() + dy.abs() - (beacon.distance + 1) } fn edge_sdf(extent: i64, p: Point) -> i64 { ...
true
04b9ff3e5f2ec68e84f9557235e9e593f96e867e
Rust
tempbottle/rust_os
/Kernel/Core/vfs/node.rs
UTF-8
9,702
2.890625
3
[ "BSD-2-Clause" ]
permissive
// "Tifflin" Kernel // - By John Hodge (thePowersGang) // // Core/vfs/node.rs //! VFS vode management use prelude::*; use super::Path; use sync::mutex::LazyMutex; use lib::byte_str::{ByteStr,ByteString}; use core::sync::atomic::{self,AtomicUsize}; pub type InodeId = u64; pub enum IoError { NoSpace, NoNodes, ReadFai...
true
a81a617f2e4a9db17249eca7fdf16bd2c4ef7dcf
Rust
MacTuitui/nannou
/generative_design/oscillation_figures/m_2_2_01.rs
UTF-8
6,902
2.609375
3
[]
permissive
// M_2_2_01 // // Generative Gestaltung – Creative Coding im Web // ISBN: 978-3-87439-902-9, First Edition, Hermann Schmidt, Mainz, 2018 // Benedikt Groß, Hartmut Bohnacker, Julia Laub, Claudius Lazzeroni // with contributions by Joey Lee and Niels Poldervaart // Copyright 2018 // // http://www.generative-gestaltung.de...
true
06dd783b43e5e56be65be00c58cbdbd37ea8117e
Rust
Daivasmara/rust_book
/08/string/src/main.rs
UTF-8
2,123
4.125
4
[]
no_license
fn main() { let s1 = String::from("hello "); let s2 = "world!".to_string(); // the same thing as using String::from let mut foo = String::from("foo"); foo.push_str("bar"); println!("{}", foo); foo.push('s'); // push takes only char not string println!("{}", foo); let s3 = s1 + &s2; //...
true
b1d68e01e29ed819095df16593fc86d4fd1bf9bf
Rust
ilover311/tantivy
/src/collector/top_score_collector.rs
UTF-8
6,198
2.90625
3
[ "MIT" ]
permissive
use super::Collector; use collector::top_collector::TopCollector; use collector::top_collector::TopSegmentCollector; use collector::SegmentCollector; use collector::TopDocsByField; use fastfield::FastValue; use schema::Field; use DocAddress; use DocId; use Result; use Score; use SegmentLocalId; use SegmentReader; /// ...
true
64423cf465aa7b5fe34eae303dc67a52907f8efa
Rust
64kramsystem/ray_tracer_challenge-completed
/library/src/space/camera_test.rs
UTF-8
2,900
2.765625
3
[ "CC0-1.0" ]
permissive
use demonstrate::demonstrate; demonstrate! { describe "Camera" { use crate::*; use crate::interface::*; use crate::math::*; use crate::lang::math::sqrt; use crate::properties::*; use crate::space::*; use std::f64::consts::PI; context "pixel size" { ...
true
379bc24d5493f5228a47872d4a0c83cb3c27a6de
Rust
Schenk75/CS110L-code
/lecture-4/linked-list/src/main.rs
UTF-8
3,123
4.09375
4
[ "MIT" ]
permissive
use std::fmt; struct Node { value: u32, next: Option<Box<Node>>, } pub struct LinkedList { head: Option<Box<Node>>, size: usize, } impl Node { fn new(value: u32, next: Option<Box<Node>>) -> Node { Node {value, next} } } impl LinkedList { fn new() -> LinkedList { LinkedLis...
true
4323df021d3ac76c9f565385e040285d103ad7a6
Rust
watchexec/watchexec
/crates/lib/src/signal.rs
UTF-8
4,272
2.65625
3
[ "Apache-2.0" ]
permissive
//! Event source for signals / notifications sent to the main process. use async_priority_channel as priority; use tokio::{select, sync::mpsc}; use tracing::{debug, trace}; use watchexec_signals::Signal; use crate::{ error::{CriticalError, RuntimeError}, event::{Event, Priority, Source, Tag}, }; /// Compatibility ...
true
8a0829a1481b1039829f5d5872a36c145db05729
Rust
Orca-bit/DataStructureAndAlgorithm
/src/dp/_221_maximal_square.rs
UTF-8
1,065
3.171875
3
[]
no_license
struct Solution; impl Solution { pub fn maximal_square(matrix: Vec<Vec<char>>) -> i32 { let n = matrix.len(); let m = matrix[0].len(); let mut dp = vec![vec![0; m]; n]; let mut res = 0_i32; for i in 0..n { if matrix[i][0] == '1' { dp[i][0] = 1; ...
true
6646f4e6a7d02c89c701228004f41a16e226d78c
Rust
HeroicKatora/oxide-auth
/oxide-auth-poem/src/error.rs
UTF-8
1,188
3.21875
3
[ "MIT", "Apache-2.0" ]
permissive
use poem::error::{BadRequest, InternalServerError, Unauthorized}; use thiserror::Error; /// Errors that may be generated by this crate. /// - Request /// - Authorization /// - Header /// - Server /// - This is the general server error. #[derive(Clone, Debug, Error)] pub enum OxidePoemError { /// This is returne...
true
48e7371db98d0080e2f0ffc9f08ff56ff4ab7251
Rust
nguyenminhhieu12041996/casper-node
/node/src/components/linear_chain_sync/metrics.rs
UTF-8
2,806
2.515625
3
[ "Apache-2.0" ]
permissive
use std::time::Instant; use prometheus::{Histogram, HistogramOpts, Registry}; #[derive(Debug)] pub struct LinearChainSyncMetrics { get_block_by_hash: Histogram, get_block_by_height: Histogram, get_deploys: Histogram, request_start: Instant, } const GET_BLOCK_BY_HASH: &str = "linear_chain_sync_get_blo...
true
783e5d187597bdf8a42d7b12e5703fea5a0a1fe1
Rust
i10416/ods
/chapter03/src/selist.rs
UTF-8
12,480
2.875
3
[ "MIT" ]
permissive
#![allow(clippy::many_single_char_names,clippy::explicit_counter_loop)] use chapter01::interface::List; use chapter02::boundeddeque::Array as BDeque; use std::cell::RefCell; use std::rc::{Rc, Weak}; type Link<T> = Option<Rc<RefCell<Node<T>>>>; type Wink<T> = Option<Weak<RefCell<Node<T>>>>; type Loc<T> = (Link<T>, usiz...
true
c1795771720af323404f5a2c4aa06612db43945e
Rust
bevyengine/bevy
/crates/bevy_reflect/src/impls/smol_str.rs
UTF-8
838
2.671875
3
[ "Apache-2.0", "MIT", "Zlib", "LicenseRef-scancode-free-unknown", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-other-permissive" ]
permissive
use crate::std_traits::ReflectDefault; use crate::{self as bevy_reflect}; use bevy_reflect_derive::impl_reflect_value; impl_reflect_value!(::smol_str::SmolStr(Debug, Hash, PartialEq, Default)); #[cfg(test)] mod tests { use crate::{FromReflect, Reflect}; use smol_str::SmolStr; #[test] fn should_partia...
true
f4b3f288fd47af676ba6ce43353830bc035129ed
Rust
simdimdim/BB01
/src/retriever/finder.rs
UTF-8
7,740
2.78125
3
[ "MIT" ]
permissive
use crate::Label; use select::{ document::Document, predicate::{Child, Descendant, Name, Or, Text}, }; #[cfg(feature = "trait_ojb_ser")] use serde_traitobject::{Deserialize as des, Serialize as ser}; use std::cell::Ref; pub type Doc<'a> = Ref<'a, Option<Document>>; type Cnt = Option<Vec<String>>; #[cfg(featur...
true
00fa1e97d04d975a8d9eadd8db43ff270c126466
Rust
carbidegames/common
/rivr/src/panels/stack.rs
UTF-8
4,558
2.796875
3
[ "Apache-2.0", "MIT" ]
permissive
use { nalgebra::{Point2}, cassowary::{ WeightedRelation::*, strength::{STRONG}, Expression, Variable, Constraint, }, attributes::{PanelSize, PanelBox, Orientation}, input::{FrameCollision}, panels::{Panel}, rendering::{Renderer}, Ui, PanelId, Error, PanelVariable...
true
ef5cb3166ca87e390f0c8220c0b3a840de6965e8
Rust
Blockstream/gdk
/subprojects/gdk_rust/gdk_rust/src/error.rs
UTF-8
1,454
2.53125
3
[ "OpenSSL", "MIT" ]
permissive
use gdk_common::error::Error as CommonError; use gdk_common::exchange_rates; use gdk_common::model::ExchangeRateError; use gdk_common::ureq; use gdk_electrum as electrum; #[derive(thiserror::Error, Debug)] pub enum Error { #[error("{0}")] Other(String), #[error(transparent)] JsonFrom(#[from] serde_jso...
true
7032616ab7eff59ad0dc7a37bc8fb4390a4d2606
Rust
dai-dao/learn_rust
/fts-search/tests/searchindex_test.rs
UTF-8
1,124
2.546875
3
[]
no_license
use std::io::{self, BufReader}; use std::fs::File; pub use fts_search::boolparser::*; pub use fts_search::fts::*; #[test] fn test_search() -> io::Result<()> { let f = File::open("small.xml")?; let reader = BufReader::new(f); let feed = get_feed(reader).unwrap(); // let fts = make_index(feed.doc...
true
e778e92554051f33eef405932495eacf0e3983ed
Rust
marco-c/gecko-dev-comments-removed
/third_party/rust/lazy_static/src/inline_lazy.rs
UTF-8
1,143
2.609375
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
extern crate core; extern crate std; use self::std::prelude::v1::*; use self::std::cell::Cell; use self::std::hint::unreachable_unchecked; use self::std::sync::Once; #[allow(deprecated)] pub use self::std::sync::ONCE_INIT; pub struct Lazy<T: Sync>(Cell<Option<T>>, Once); impl<T: Sync> Lazy<T> { #[allow(d...
true
312a8593c6b9ec1d38624e1d7143f15d52cac72e
Rust
k-jun/atcoder-abc
/src/abc60_d.rs
UTF-8
1,042
2.921875
3
[]
no_license
use std::io::*; use std::str::FromStr; pub fn read<T: FromStr>() -> T { let stdin = stdin(); let stdin = stdin.lock(); let token: String = stdin .bytes() .map(|c| c.expect("failed to read char") as char) .skip_while(|c| c.is_whitespace()) .take_while(|c| !c.is_whitespace()) ...
true
cb32192f24630ad6857b37d43dc7fc57542175e0
Rust
Heinmci/EulerProject
/src/problems/problem_004.rs
UTF-8
780
3.421875
3
[]
no_license
pub fn solve(limit1: u32) -> u32 { let mut max = 0; for i in (0..limit1 + 1).rev() { for j in (0..i + 1).rev() { let mult = i * j; if mult > max && is_palydrome(mult) { max = mult; } } } max } fn is_palydrome(number: u32) -> bool { ...
true
927bc5b54b489f524c56271fa0948db882d229b1
Rust
mswdwk/bincode
/compatibility/src/lib.rs
UTF-8
3,288
2.515625
3
[ "MIT", "Apache-2.0" ]
permissive
#![cfg(test)] use ::rand::Rng; use bincode_1::Options; mod membership; mod misc; mod rand; mod sway; pub fn test_same_with_config<T, C, O>(t: &T, bincode_1_options: O, bincode_2_config: C) where T: bincode_2::Encode + bincode_2::Decode + serde::Serialize + serde::de::DeserializeOwned ...
true
fe952c90866185b236b99f31ed4d14fd210e231e
Rust
PotatoParser/pngifier
/src/util/chunk.rs
UTF-8
1,416
2.96875
3
[ "MIT" ]
permissive
extern crate crc32fast; use crc32fast::Hasher; use std::io; use std::io::prelude::*; use std::convert::TryInto; use crate::util; use util::ReadFile; #[derive(Debug)] pub struct Chunk { header: Vec<u8>, data: Vec<u8>, crc: Vec<u8>, pub total_data: usize } impl Chunk { // Read entire chunk: length + content + cr...
true
979d5c0a83facfaa06cd94fbd3db84239dc57a0d
Rust
JackToaster/bf-llvm
/src/compiler/jit.rs
UTF-8
1,573
2.546875
3
[]
no_license
use inkwell::OptimizationLevel; use inkwell::builder::Builder; use inkwell::context::Context; use inkwell::execution_engine::{ExecutionEngine, JitFunction}; use inkwell::module::Module; use inkwell::targets::{InitializationConfig, Target}; use std::{error::Error, io::{self, Read, Write}}; use crate::parser::ast::ASTBr...
true
e9514f8d5eeb5eeeeb4c88be05f75fc1aad62993
Rust
sugyan/leetcode
/others/october-leetcoding-challenge/week-1/3484/lib.rs
UTF-8
528
3.390625
3
[]
no_license
pub struct Solution {} impl Solution { pub fn bitwise_complement(n: i32) -> i32 { let mut m = 1; while m < n { m = (m << 1) + 1 } m - n } } #[cfg(test)] mod tests { use super::*; #[test] fn example_1() { assert_eq!(2, Solution::bitwise_complemen...
true
32e5a1ee1394a659a35cdd89dd3f7baf507a6c11
Rust
wintercooled/gdk
/subprojects/gdk_rust/gdk_electrum/src/pset.rs
UTF-8
8,729
2.515625
3
[ "OpenSSL", "MIT" ]
permissive
use crate::error::Error; use bitcoin::hashes::hex::{FromHex, ToHex}; use elements::encode::{deserialize, serialize}; use elements::pset; use elements::pset::PartiallySignedTransaction; use elements::script::Builder; use elements::Transaction; use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize)] pub struc...
true
aad65ab2019de40fc80077132a91a4a2abfd8a9a
Rust
doraneko94/numerical
/examples/simequation.rs
UTF-8
2,255
2.796875
3
[]
no_license
use ndarray::*; use ndarray_linalg::*; fn main() { let a = arr2(&[[ 2.0, -4.0, 6.0], [ -1.0, 7.0, -8.0], [ 1.0, 1.0, -2.0]]); let b = arr1(&[ 1.0, 0.0, 3.0]); println!("*** simultaneous equations ***"); println!(" 2x - 4y + 6z = 1"); println!("- x + 7y...
true
99f881e82cf4688be7ba8a37c3cf3e693e3acdd8
Rust
ftilde/rust-x86asm
/src/test/instruction_tests/instr_setng.rs
UTF-8
4,595
2.53125
3
[ "MIT" ]
permissive
use instruction_def::*; use test::run_test; use Operand::*; use Reg::*; use RegScale::*; use RegType::*; use {BroadcastMode, Instruction, MaskReg, MergeMode, Mnemonic, OperandSize, Reg, RoundingMode}; #[test] fn setng_1() { run_test( &Instruction { mnemonic: Mnemonic::SETNG, operand...
true
f25115eb4e76a29ec340c636111f2c9733237a64
Rust
196Ikuchil/nes_emulator
/src/nes/apu/square.rs
UTF-8
6,311
3.125
3
[ "MIT" ]
permissive
use super::constants::*; use super::super::types::{Data, Addr}; #[derive(Debug)] pub struct Square { index: usize, // $4000 is_length_counter_enabled: bool, is_envelope_enabled: bool, is_envelope_loop_enabled: bool, envelope_period_and_volume: usize, // $4001 is_sweep_enabled: bool, sweep_unit_divide...
true
e5253daf2840bb8312fcf75267713e262cae4bb3
Rust
boa-dev/boa
/boa_engine/src/object/internal_methods/array.rs
UTF-8
9,147
2.78125
3
[ "MIT", "Unlicense" ]
permissive
use crate::{ error::JsNativeError, object::JsObject, property::{PropertyDescriptor, PropertyKey}, string::utf16, Context, JsResult, }; use super::{InternalObjectMethods, ORDINARY_INTERNAL_METHODS}; /// Definitions of the internal object methods for array exotic objects. /// /// More information: /...
true
838068004ba7a3bc800411f0abc0208740e5b150
Rust
wasmerio/wasmer
/tests/compilers/traps.rs
UTF-8
13,655
2.515625
3
[ "MIT" ]
permissive
use anyhow::Result; use std::panic::{self, AssertUnwindSafe}; use wasmer::*; #[compiler_test(traps)] fn test_trap_return(config: crate::Config) -> Result<()> { let mut store = config.store(); let wat = r#" (module (func $hello (import "" "hello")) (func (export "run") (call $hello)) ...
true
11968dfe90b9c52912ea8fdb521bdf07b6c662a5
Rust
synac-chat/synac-rs
/src/listener.rs
UTF-8
1,539
3.21875
3
[ "MIT" ]
permissive
use common::{self, Packet}; use failure::Error; use std::io::{ErrorKind as IoErrorKind, Read}; /// A non-blocking listener pub struct Listener { size: bool, buf: Vec<u8>, i: usize } impl Default for Listener { fn default() -> Self { Listener { size: true, buf: vec![...
true
76b293122691ffc11c1a9a9920009e3b90fb554c
Rust
tedbyron/golem
/lib/src/automaton.rs
UTF-8
9,298
2.890625
3
[ "Apache-2.0" ]
permissive
use rand::Rng; use std::cmp::Ordering; use std::{iter, mem}; use wasm_bindgen::prelude::*; use crate::rules::Rules; /// A 2D cellular automaton with a finite number of cells. #[wasm_bindgen(inspectable)] #[derive(Clone, Debug)] pub struct Automaton { rows: usize, cols: usize, cells: Vec<u8>, cells_ste...
true
cce6ec6cfc8c20037fe8c4731ec37c62d1b520c3
Rust
KerrMetric/rust-chain
/utils/src/hash.rs
UTF-8
273
2.71875
3
[]
no_license
use crypto::sha2::Sha256; use crypto::digest::Digest; pub fn sha256(target: String) -> String { let mut hasher = Sha256::new(); hasher.input_str(&target); hasher.result_str() } pub fn generate(target: String) -> String { format!("0x{}", sha256(target)) }
true
56874c598d5cd80052020dfcfd18efd35ed130cf
Rust
danshiovitz/adventofcode
/2022/day03/src/main.rs
UTF-8
2,560
3.078125
3
[ "LicenseRef-scancode-public-domain" ]
permissive
extern crate common; use std::collections::HashSet; use common::framework::{parse_lines, run_day, BaseDay, InputReader}; struct Sack { first: HashSet<char>, second: HashSet<char>, } struct Day03 { vals: Vec<Sack>, } fn priority(ch: char) -> i32 { if ch >= 'a' && ch <= 'z' { return (ch as u3...
true
7b5de3c44e95f02cc04cbe86abb201ab258c701b
Rust
openqrnch/blather
/src/types/kvlines.rs
UTF-8
3,190
3.296875
3
[]
no_license
//! A key/value pair list with stable ordering and non-unique keys. use std::convert::From; use std::fmt; use bytes::{BufMut, BytesMut}; use crate::err::Error; /// Representation of a key/value pair in `KVLines`. #[derive(Debug, Clone, Default, PartialEq, Eq)] pub struct KeyValue { key: String, value: String } ...
true
408a3ada273fadd2b722fc9d05c60625d086e8b3
Rust
robsmith11/krust
/src/kbindings.rs
UTF-8
18,887
2.765625
3
[ "MIT" ]
permissive
use lazy_static::lazy_static; use libc; use std; use std::mem::zeroed; use std::slice; use std::ptr; use std::fmt; use std::ffi; use std::collections::HashMap; use std::sync::Mutex; pub type S = *const libc::c_char; pub type C = libc::c_char; pub type G = libc::c_uchar; pub type H = libc::c_short; pub type I = libc::c...
true
be147f7d2e7afb53b9cdfa40e5e2f9c4b7052b3d
Rust
wilcoxky/rust-hw01
/src/problem3.rs
UTF-8
1,863
3.59375
4
[]
no_license
/// Solves for the sequence of moves required to move all discs from peg 1 to /// peg 3, using peg 2 as an intermediary. enum Position { Left, Right, Middle } struct Tower { position: Position, disks: Vec<u32> } pub fn hanoi(num_discs: u32) -> Vec<(u8, u8)> { // Edge Cases let mut solutio...
true
05eb699fee629b599e5f342cd9e1e530453fc959
Rust
marianoheller/aoc2020
/src/puzzles/day_10/src/main.rs
UTF-8
2,486
3.15625
3
[]
no_license
use std::{cmp::max, collections::HashMap}; use utils::read_lines; pub fn solve_p1(_adapters: &Vec<i64>) -> i64 { let mut adapters = _adapters.clone(); let last_val = adapters[adapters.len() - 1]; adapters.push(last_val + 3); let result = adapters .iter() .enumerate() .map(|(i,...
true
d123f299b2ed7ee93dbaf0bdd9e3dc000dd2d7b3
Rust
lubaozhen/swc
/crates/rplugin/src/lib.rs
UTF-8
3,696
3.09375
3
[ "MIT", "Apache-2.0" ]
permissive
//! AST processing plugin system. //! //! Designed as a general crate, to support using it from other libraries too. //! This depends on the [abi_stable] crate. //! //! # Why new crate? //! //! I (kdy1) wants to pass the AST data to plugin without having to change the //! type of AST nodes. //! //! e.g. Using [RBox](ab...
true
c8915309947952033e05754cb22afa07581ea340
Rust
insanebits/rust-mysql-client
/src/gui/component_store.rs
UTF-8
686
3
3
[]
no_license
/// /// Holds GUI widgets /// use std::collections::HashMap; use gtk; use gui; pub struct ComponentStore<'a> { components: HashMap<String, Box<gtk::WidgetTrait + 'a>>, } impl <'a>ComponentStore<'a> { pub fn new() -> ComponentStore<'a> { ComponentStore { components: HashMap::new() } } } impl gui::Component...
true
1e0f46308deb74cf9f45ba418100861fdc9f7c0f
Rust
VictorKoenders/rust_game
/server/src/file_handler.rs
UTF-8
1,019
2.75
3
[]
no_license
use shared::User; use std::fs::OpenOptions; use std::io::Read; use bincode::rustc_serialize::{encode, decode}; use bincode::SizeLimit; #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] pub struct UserPassword { pub user_id: u32, pub password: String, } #[allow(dead_code)] // TODO: Implement pub struct Fil...
true
e86eb0725e1182476c731f3bec804ec42522e70a
Rust
ricky26/leg-rs
/src/lib.rs
UTF-8
20,676
2.703125
3
[ "MIT" ]
permissive
#![feature(plugin)] #![plugin(regex_macros)] //! A library for running simple ARM emulators. //! //! This module contains parsers for ARM/THUMB machine-code, along //! with a trait for dispatching the parsed instructions and a //! 'simple' emulator which uses this trait. use std::{mem, result, error, fmt, ops}; #[ma...
true
3f16fbdd9d2bf86b0c82770f34ccabeb9070d4db
Rust
peterhinson/multican
/src/can_socketcan.rs
UTF-8
1,740
2.921875
3
[ "MIT" ]
permissive
use crate::{CanMessage, CanNetwork}; use socketcan::{CANFrame, CANSocket}; use std::time; /// SocketCAN adapter for mulitcan pub struct SocketCanNetwork { socket: CANSocket, pub bus: u8, } impl CanNetwork for SocketCanNetwork { fn send(&self, msg: CanMessage) { trace!("Sending {:?}", msg); ...
true
e7c08847a183a84759aa6ab6dc53ce5480a68c01
Rust
vlbos/rust-cookbook-code
/ch10-encoding-charsets/src/main.rs
UTF-8
2,240
2.890625
3
[ "Unlicense" ]
permissive
// use percent_encoding::{utf8_percent_encode, percent_decode, AsciiSet, CONTROLS}; // use std::str::Utf8Error; // /// https://url.spec.whatwg.org/#fragment-percent-encode-set // const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); // fn main() -> Result<(), Utf8Error> { // let...
true
207511bb83912c169c020675b6f4673707d1249d
Rust
zaeleus/noodles
/noodles-gtf/examples/gtf_view.rs
UTF-8
504
2.671875
3
[ "MIT" ]
permissive
//! Validates and prints all records in a GTF file. //! //! The result matches the output of `grep --invert-match "^#" <src>`. use std::{ env, fs::File, io::{self, BufReader}, }; use noodles_gtf as gtf; fn main() -> io::Result<()> { let src = env::args().nth(1).expect("missing src"); let mut rea...
true
ef4ddaa0022135f4f9448ad155e69dafec0014b8
Rust
ravron/grit
/src/buf_utils.rs
UTF-8
1,499
3.375
3
[]
no_license
use anyhow::Result; use std::str; /// Some nice helper functions for working with buffers, allowing us to add methods to the buffers /// rather than having to pass the buffers into a function (nice syntactic sugar). /// /// Inspired by the bites::Buf trait. This should probably extend Buf and use its `chunk`, /// `adv...
true
0864afaad45bf580fb182bbe60985221d1ca487f
Rust
dmitry-pechersky/algorithms
/leetcode/55_Jump_Game.rs
UTF-8
725
3.4375
3
[]
no_license
struct Solution {} impl Solution { pub fn can_jump(nums: Vec<i32>) -> bool { let n = nums.len(); let mut max_jump = 0usize; for i in 0..n { if max_jump < i { return false; } if i + nums[i] as usize > max_jump { max_jump = ...
true
d1b5368f0070f1b3dacb41c4e21d81792eb9b31d
Rust
hongry18/rust-tutorial
/rust-learning-path/rust-memory-management/ch02-learn-about-borrowing/src/main.rs
UTF-8
758
3.875
4
[]
no_license
fn print_greeting(msg: &String) { println!("Greeting: {}", msg); } /* // panic code fn change(msg: &String) { msg.push_str("1"); } */ fn change(msg: &mut String) { msg.push_str(", !"); } fn main() { let greeting = String::from("Hello"); let greeting_reference = &greeting; println!("Greeting: ...
true
057a2981dff3519bfb5e38739f50fb7ddd45d735
Rust
chimzycash/project-cleanup
/src/main.rs
UTF-8
1,856
2.515625
3
[ "MIT" ]
permissive
use std::io::{ stdin, stdout, Write }; use std::process; use colored::*; mod settings; mod languages; mod file_utils; mod find_paths; mod get_stats; mod filter_paths; mod remove_paths; mod spinner; use crate::settings::Settings; use crate::get_stats::format_size; fn main() { // If on Windows, we need to enable th...
true
f3d110ec4b24dca01c1c115b9e12cd53090bd99e
Rust
zhiburt/tabled
/tabled/src/settings/padding/mod.rs
UTF-8
5,206
3.59375
4
[ "MIT" ]
permissive
//! This module contains a [`Padding`] setting of a cell on a [`Table`]. //! //! # Example //! #![cfg_attr(feature = "std", doc = "```")] #![cfg_attr(not(feature = "std"), doc = "```ignore")] //! use tabled::{Table, settings::{Padding, Style, Modify, object::Cell}}; //! //! let table = Table::new("2022".chars()) //! ...
true
fd8d9097129908b4eda0759e3f79f66557ab1181
Rust
cdyfng/aoc2019
/src/day03.rs
UTF-8
2,034
3.21875
3
[]
no_license
use std::collections::HashSet; const INPUT: &str = include_str!("../inputs/day03.txt"); fn parse(input: &str) -> HashSet<(i32, i32)>{ let mut pos = (0, 0); let mut result = HashSet::new(); for step in input.trim().split(",") { let (dir, dist_str) = step.split_at(1); let dist: usize = dist_str.parse()...
true
00894b6c8a5dcd246b28232f23a1a60ad7b73577
Rust
rusticata/asn1-rs
/tests/krb5.rs
UTF-8
3,553
2.984375
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! Test implementation for Kerberos v5 //! //! This is mostly used to verify that required types and functions are implemented, //! and that provided API is convenient. use asn1_rs::*; use hex_literal::hex; const PRINCIPAL_NAME: &[u8] = &hex!("30 81 11 a0 03 02 01 00 a1 0a 30 81 07 1b 05 4a 6f 6e 65 73"); /// Princ...
true
14dfcb65c9c21ddcb0b3da53cdf22e0f9843f2aa
Rust
ecafkoob/ockam
/implementations/rust/ockam/ockam_core/src/compat.rs
UTF-8
4,948
2.828125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
//! A facade around the various collections and primitives needed //! when using "std", "no_std + alloc" or "no_std" targets. //! //! When importing from the standard library: //! //! 1. always prefer core::<mod> over std::<mod> where it's //! available. (e.g. std::fmt::Result -> core::fmt::Result) //! 2. use ...
true
f5442bd8c760b48bb9c97f4e1b58c24266006fd3
Rust
nishikawaakira/rust_file_updates
/src/main.rs
UTF-8
2,434
3.484375
3
[]
no_license
use std::collections::HashMap; use std::fs; use std::io; use std::path::Path; use std::env; use chrono::{DateTime, TimeZone, Local}; fn main() { let args: Vec<String> = env::args().collect(); if args.len() < 2 { println!("ディレクトリ名を指定してください"); return; } let mut fileinfo: FileInfo = File...
true
8edce6a3d7176e0b782723b56d308946d8859ef7
Rust
uazu/stakker
/src/test/test.rs
UTF-8
4,589
3.1875
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Since 1.67 `RUST_TEST_THREADS=1` no longer runs all tests in a //! single thread. Since the Stakker single-threaded tests require //! that, we can no longer use `RUST_TEST_THREADS=1`. See: //! https://github.com/rust-lang/cargo/issues/11896 and //! https://github.com/rust-lang/rust/issues/104053. //! //! So the s...
true
7138ba9af4415ec9a6f9507d4d36739373188e52
Rust
Guleri24/dota2_webapi_bindings
/src/lib.rs
UTF-8
11,778
3.09375
3
[ "MIT" ]
permissive
//! The crate serves as an bindings to the official (outdated) //! [dota2 webapi](https://dev.dota2.com/forum/dota-2/spectating/replays/webapi/60177-things-you-should-know-before-starting?t=58317) //! The crate has been made so you can call make calls directly and get a result back in a Struct. //! //! Read the full li...
true
5c2f18ad6cd57e8469652ff5eb8ebbabc73524a0
Rust
zRedShift/aoc-2018
/aoc16/src/main.rs
UTF-8
7,409
2.765625
3
[]
no_license
use std::collections::HashSet; use std::fmt; use std::fs::File; use std::io::{BufRead, BufReader, Error as IoError}; use std::iter; use std::ops::{Index, IndexMut}; use std::path::Path; use std::str::FromStr; use lazy_static::lazy_static; use regex::Regex; const INSTRUCTION_COUNT: usize = 16; type Instruction = fn(&...
true
1740183b152693926dd815aea49d3cd70d39065d
Rust
frankegoesdown/LeetCode-in-Go
/Algorithms/0145.binary-tree-postorder-traversal/binary-tree-postorder-traversal_test.go
UTF-8
841
2.546875
3
[ "MIT" ]
permissive
package problem0145 import ( "fmt" "testing" "github.com/aQuaYi/LeetCode-in-Go/kit" "github.com/stretchr/testify/assert" ) // tcs is testcase slice var tcs = []struct { pre, in, post []int }{ { []int{1, 2, 3}, []int{1, 3, 2}, []int{3, 2, 1}, }, { []int{1, 2, 4, 5, 3, 6, 7}, []int{4, 2, 5, 1, 6, ...
true
f07b8e04f67ed7f3448ee86d07b80568d6a1fb50
Rust
swissChili/kernel8
/src/mmio/mod.rs
UTF-8
528
2.609375
3
[]
no_license
use core::intrinsics::volatile_load; use core::intrinsics::volatile_store; pub const UART_DR: u32 = 0x3F201000; pub const UART_FR: u32 = 0x3F201018; pub const BASE: u32 = 0x3F000000; pub fn write(reg: u32, val: u32) { unsafe { volatile_store(reg as *mut u32, val) } } pub fn read(reg: u32) -> u32 { ...
true
cf2e7520c7759e96e29d16382b74bce2b1421ef7
Rust
jaynus/balls
/game/render_glow/src/shader.rs
UTF-8
2,956
2.75
3
[]
no_license
use glow::HasContext; use regex::Regex; use rl_core::math::Mat4; use std::path::Path; const INCLUDE_DIRECTIVE: &str = "#include ((<[^>]+>)|\"([^\"]+)\")"; pub struct ShaderProgram { pub handle: <glow::Context as HasContext>::Program, } fn process_includes(include_path: &Path, src: &str) -> String { let mut f...
true
4cac00a804dbe7f4d99bee6f4181e069893085f9
Rust
hamadakafu/kyopro
/src/bin/abc224c.rs
UTF-8
940
2.734375
3
[]
no_license
#![allow(clippy::comparison_chain)] #![allow(clippy::collapsible_if)] use std::cmp::Reverse; use std::cmp::{max, min}; use std::collections::{BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; use std::fmt::Debug; use itertools::Itertools; use whiteread::parse_line; const ten97: usize = 1000_000_007; /// 2の逆元 mod te...
true
d65f0ff567963368dedf55fb4b97d0c50ee4aa46
Rust
Jason-Cooke/rustls
/src/quic.rs
UTF-8
6,898
2.546875
3
[ "ISC", "Apache-2.0", "MIT" ]
permissive
/// This module contains optional APIs for implementing QUIC TLS. use crate::client::{ClientConfig, ClientSession, ClientSessionImpl}; use crate::msgs::enums::{ContentType, ProtocolVersion, AlertDescription}; use crate::msgs::handshake::{ClientExtension, ServerExtension}; use crate::msgs::message::{Message, MessagePayl...
true
75a83d9e7764e33f57b148ea8b5ecf92c933f541
Rust
robhardwick/o64
/src/envelope.rs
UTF-8
3,547
3.015625
3
[]
no_license
use rand::rngs::SmallRng; use rand::Rng; const RATIO_A: f32 = 0.3; const RATIO_DR: f32 = 0.0001; #[derive(Debug, Clone, Copy)] enum EnvelopeState { Attack, Decay, Sustain, Release, Off, } #[derive(Debug, Clone, Copy)] struct EnvelopeStateParams { coefficient: f32, base: f32, } #[derive(D...
true
fa592a4f58efe2818ac521f9f51d40b268fded3b
Rust
feroldi/rappel
/src/bigint.rs
UTF-8
1,960
3.828125
4
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::ops::Add; // TODO: Implement arbitrary size. // Should be something like `enum { Small(u128), Big(Vec<u128>) }`. #[derive(Clone, Copy, Debug, PartialEq)] struct BigInt { high: u128, low: u128, } impl Add for BigInt { type Output = BigInt; fn add(self, other: BigInt) -> BigInt { let (...
true
cc07121604cea778256f94e9337211551c230ebc
Rust
carwynellis/learning-rust
/syntax_and_semantics/src/examples/mutability.rs
UTF-8
2,336
4.1875
4
[]
no_license
use std::cell::Cell; use std::cell::RefCell; use std::sync::Arc; pub fn mutability() { println!("Mutability\n"); // Variables are immutable by default. // Mutability can be declared with the mut keyword. let mut x = 1; println!("x is {}", x); x = 2; println!("x is {} after assignment", x)...
true
08b0de48ff7cd7d5fb042523c379f62d45116259
Rust
MikeMKH/the-rust-programming-language
/ch10/examples/src/lib.rs
UTF-8
2,394
3.796875
4
[ "Apache-2.0" ]
permissive
#[cfg(test)] mod tests { use super::*; #[test] fn it_finds_largest_copy() { let list = vec![1, 9, 3]; assert_eq!(largest_copy(&list), 9); } #[test] fn it_finds_largest_clone() { let list = vec![1, 9, 3]; assert_eq!(largest_clone(&list), 9); } #[test] ...
true
450c3ccdd015fd7840a65435a4d1d952c81713bc
Rust
jduan/cosmos
/rust_sandbox/leetcode_30_challenges/src/day14.rs
UTF-8
2,571
4
4
[ "MIT" ]
permissive
/// Perform String Shifts /// /// You are given a string s containing lowercase English letters, and a matrix shift, where /// shift[i] = [direction, amount]: /// /// direction can be 0 (for left shift) or 1 (for right shift). /// amount is the amount by which string s is to be shifted. /// A left shift by ...
true
a694752be84b17dc96571aaa66030a1369b44310
Rust
ngundotra/solana-szn-program
/src/processor.rs
UTF-8
7,911
2.59375
3
[]
no_license
//! Does something important use::{ // arrayref::{array_mut_ref, array_ref, array_refs, mut_array_refs}, solana_program::{ entrypoint::{ProgramResult}, program_error::{ProgramError}, account_info::{ next_account_info, AccountInfo, }, pubkey::Pub...
true
e357f0d98743b1b021b3c56ca5ffcc9aaa377dcc
Rust
storiqaamericanteam/stores
/src/models/authorization/rule.rs
UTF-8
482
2.796875
3
[]
no_license
//! enum for authorization use std::fmt; use stq_static_resources::ModerationStatus; // Any - gives all permissions. #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub enum Rule { Any, ModerationStatus(ModerationStatus), } impl fmt::Display for Rule { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ...
true
87415abe72e3c74927348f0976a52b9f7942e81e
Rust
HadrienG2/coursera-crypto
/src/hash/sha_256.rs
UTF-8
11,404
2.5625
3
[]
no_license
//! This module is an implementation of the SHA-256 hashing algorithm use padding::PaddingScheme; use padding::merkle_damgard::MDPadding512u32; // Logical functions used by SHA-256 (function names taken from NIST standard) fn ch(x: u32, y: u32, z: u32) -> u32 { (x & y) ^ (!x & z) } // fn maj(x: u32, y: u32, z: u...
true
cfcc639f1a9c3717056a389f14eff75432df294f
Rust
sbnair/toy-rust-ipfs
/src/util.rs
UTF-8
758
2.671875
3
[]
no_license
use rust_multihash as multihash; use std::fs::{self, File}; use std::io; use std::path::Path; pub fn hash<'a>(data: &'a [u8]) -> multihash::Multihash { multihash::multihash(data, multihash::HashType::SHA2_256) } pub fn file_exists<P: AsRef<Path>>(path: P) -> io::Result<bool> { match fs::metadata(path) { ...
true
a087b69ee3d7cd3aae214ab0a9042578cd663a5a
Rust
gmmorris/jg
/tests/array_member.rs
UTF-8
7,467
2.96875
3
[ "MIT" ]
permissive
#[cfg(test)] mod cli { use std::process::Command; use assert_cmd::prelude::*; #[test] fn should_match_array_with_string_value() { let mut cmd = Command::main_binary().unwrap(); cmd.arg(r#".video.mimes[~="application/javascript"]"#); let mut stdin_cmd = cmd.with_stdin(); ...
true
db14368aa4541bdacebcd7a2fe992eed68f76f80
Rust
weezy20/rust-learning
/coffee-machine/src/coffee/engine.rs
UTF-8
811
3.453125
3
[]
no_license
pub struct CoffeeEngine { pub water: u32, pub milk: u32, pub beans: u32, } impl CoffeeEngine { pub fn new(w: u32, m: u32, c: u32) -> CoffeeEngine { CoffeeEngine { water: w, milk: m, beans: c, } } pub fn add_water(&mut self, fill_water: u32) -...
true
32c64a28f05878341ff401c31018b4f49123be5d
Rust
rustkas/error-index
/main_tests/tests/e0069.rs
UTF-8
639
2.609375
3
[ "MIT" ]
permissive
/* cargo test --test e0069 cargo test --test e0069 with_error -- --nocapture cargo test --test e0069 without_error1 -- --nocapture */ /* The compiler found a function whose body contains a return; statement but whose return type is not (). */ // I lot of problems with recursion_limit #[cfg(test)] mod tests { #[t...
true
86d9cac364ae5a2606228745584a73d12501cd70
Rust
dabreegster/nanoserde
/tests/ser_de.rs
UTF-8
874
3.03125
3
[]
no_license
use nanoserde::{DeBin, DeJson, SerBin, SerJson}; #[test] fn ser_de() { #[derive(DeBin, SerBin, DeJson, SerJson, PartialEq)] pub struct Test { pub a: i32, pub b: f32, c: Option<String>, d: Option<String>, e: Option<std::collections::HashMap<String, String>>, } le...
true
8b9c18a7c7ea01a631031c11b003311ca46f5836
Rust
changhe3/nom-json-parser
/src/repr.rs
UTF-8
7,148
3.171875
3
[ "MIT" ]
permissive
use crate::utils::{escape, PadAdapter}; use derive_more::From as DmFrom; use itertools::Itertools; use shrinkwraprs::Shrinkwrap; use std::borrow::Cow; use std::collections::BTreeMap; use std::fmt::Display; use std::fmt::{Error, Formatter, Write}; use std::iter::FromIterator; /// A struct representing a JSON value. //...
true
8f690a89bf4af5e9126ae276483f71c9c107f327
Rust
ftsujikawa/rust-sample
/ch08/code8-12/src/main.rs
UTF-8
152
3.015625
3
[]
no_license
fn main() { struct Color(f32, f32, f32); let yello = Color(1.0,1.0,0.0); println!("R:{:.2} G:{:.2} B:{:.2}", yello.0, yello.1, yello.2); }
true
9cc089754e3bc6eecf17e41c0d6eaae376c4091e
Rust
hipstermojo/movieapp
/src/utils.rs
UTF-8
1,113
2.75
3
[]
no_license
use argonautica::{Error, Hasher,Verifier}; use std::error; use std::fmt; #[derive(Debug, Clone)] pub struct ExistingUserError; impl fmt::Display for ExistingUserError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "User already exists") } } impl error::Error for ExistingUserEr...
true
9e8ee5fa51e2e4c4cbd0aeb5a690942f6203dd82
Rust
erdos-project/erdos
/erdos/src/scheduler/channel_manager.rs
UTF-8
12,900
2.625
3
[ "Apache-2.0" ]
permissive
use async_trait::async_trait; use serde::Deserialize; use std::{any::Any, collections::HashMap, sync::Arc}; use tokio::sync::{mpsc, Mutex}; use crate::{ communication::{Pusher, PusherT, RecvEndpoint, SendEndpoint}, dataflow::{ graph::{Job, JobGraph}, stream::StreamId, Data, Message, Rea...
true
8fef619f8ca148e460a9f14a99fd98073de459b0
Rust
Brekcel/Villkiss
/src/commandpool.rs
UTF-8
2,219
2.515625
3
[ "MIT" ]
permissive
use std::{ cell::RefCell, iter::once, mem::MaybeUninit, }; use gfx_hal::{ command::{ CommandBuffer, OneShot, Primary, }, pool::{ CommandPool as HAL_CommandPool, CommandPoolCreateFlags, }, pso::PipelineStage, Device, Graphics, Submission, }; use crate::{ gfx_back::Backend, util::TakeExt, Fence,...
true
14ec44ef0ef827a10562f9a1a26a39c895dd7319
Rust
SamuelSchlesinger/rust-udp-playtime
/src/consumer.rs
UTF-8
2,798
3.125
3
[]
no_license
pub struct ConsumerHandle<Message, Environment> { sender: std::sync::mpsc::SyncSender<Message>, join_handle: std::thread::JoinHandle<Message>, phantom_environment: std::marker::PhantomData<Environment>, } impl<Message, Environment> ConsumerHandle<Message, Environment> where Message: Send, Environme...
true
40139f9da5d7974beba759e78df76fe97e1b8502
Rust
mun-lang/mun
/crates/mun_hir/src/ty/lower.rs
UTF-8
11,632
2.734375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Methods for lower the HIR to types. pub(crate) use self::diagnostics::LowerDiagnostic; use crate::resolve::{HasResolver, TypeNs}; use crate::ty::{Substitution, TyKind}; use crate::{ arena::map::ArenaMap, code_model::StructKind, diagnostics::DiagnosticSink, name_resolution::Namespace, primitive_...
true
5a3179cb407521df676221e5b837974d924a1753
Rust
jiehuali/kapp
/gl_context/src/windows/mod.rs
UTF-8
21,199
2.6875
3
[ "Zlib", "MIT", "Apache-2.0" ]
permissive
use std::io::Error; use std::mem::size_of; use std::os::raw::{c_float, c_int, c_uint, c_void}; use std::ptr::null_mut; use lawrencium::*; mod utils_windows; use utils_windows::*; use crate::common::*; pub struct GLContext { context_ptr: HGLRC, pixel_format_id: i32, _pixel_format_descriptor: PIXELFORMATDE...
true
d08f4e8b7f746dfc9ce152b002a0ace0996dd423
Rust
ethereumproject/evm-rs
/src/eval/run/environment.rs
UTF-8
1,810
2.78125
3
[ "Apache-2.0" ]
permissive
//! Environment instructions use bigint::{H256, M256}; use sha3::{Digest, Keccak256}; use super::State; use crate::{Address, Memory, Patch}; pub fn calldataload<M: Memory, P: Patch>(state: &mut State<M, P>) { pop!(state, index); let index: Option<usize> = if index > usize::max_value().into() { None ...
true
2490c9a18b381dac83ae9fd72054b95e3da06cf1
Rust
harthur/tract
/core/src/ops/invariants.rs
UTF-8
11,376
2.890625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::model::{TypedModel, TypedNode}; use crate::prelude::*; use itertools::Itertools; use std::collections::{HashMap, HashSet}; use std::fmt; #[derive(Clone, Default)] pub struct Invariants { element_wise: bool, pub axes: TVec<AxisInfo>, } impl Invariants { pub fn none() -> Invariants { Inva...
true
5bca0ff7fe9b898ccd0d4dbffa4b9b428a1322f3
Rust
MattiasBuelens/wasm-streams
/src/writable/into_underlying_sink.rs
UTF-8
2,562
2.78125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::cell::RefCell; use std::pin::Pin; use std::rc::Rc; use futures_util::{Sink, SinkExt}; use js_sys::Promise; use wasm_bindgen::prelude::*; use wasm_bindgen_futures::future_to_promise; #[wasm_bindgen] pub(crate) struct IntoUnderlyingSink { inner: Rc<RefCell<Inner>>, } impl IntoUnderlyingSink { pub fn n...
true
546e81f9e8c26a6aee060aadf6c3c8bc07bb5609
Rust
andreasots/eris
/src/aiomas/codec.rs
UTF-8
3,662
2.734375
3
[ "Apache-2.0" ]
permissive
use std::collections::HashMap; use std::fmt::{Formatter, Result as FmtResult}; use anyhow::Error; use bytes::{Bytes, BytesMut}; use futures::{Sink, SinkExt, Stream, TryStreamExt}; use serde::de::{Error as DeserializationError, Visitor}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::{se...
true
4cd7195dc0089175f9d9c138d237a5bedc88fde5
Rust
Dynisious/bitio
/src/lib.rs
UTF-8
931
2.734375
3
[]
no_license
//! Bit level reading and writing. //! //! To access [BitReader](./struct.BitReader.html) or `BitWriter` types use `--features std` //! //! Author --- DMorgan //! Last Moddified --- 2019-12-30 #![cfg_attr(not(feature = "std",), no_std,)] #![feature(const_fn, const_transmute, never_type, try_trait, nll,)] #![deny(m...
true