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
57e1e77043e4baa5b11433154ae492b36e0ba285
Rust
svenstaro/minitraderoute
/src/cli.rs
UTF-8
646
2.59375
3
[ "MIT" ]
permissive
use simplelog::{Config, LevelFilter, SimpleLogger}; use structopt::StructOpt; #[derive(StructOpt, Debug)] #[structopt(name = "Minitraderoute")] pub struct Opt { /// Verbose mode (-v, -vv, -vvv) #[structopt(short, long, parse(from_occurrences))] pub verbose: u8, } pub fn parse_cli() { // Parse commandl...
true
e86dd210d7b019873be0e836ef8c083b9bb5cf72
Rust
AlterionX/totality-rs
/totality-events/src/hal/mod.rs
UTF-8
2,697
2.671875
3
[]
no_license
pub mod axis; pub mod button; pub mod change; pub mod pos; pub use self::axis as a; pub use self::button as b; pub use self::pos as p; use crate::cb::{Categorized, ValueStore}; use std::collections::HashMap; #[derive(Debug, Hash, Copy, Clone, PartialEq, Eq)] pub enum C { A(a::C), P(p::C), B(b::C), Ig...
true
688a4110528e08088873615b090fe78088bc5eb8
Rust
cesbo/bitwrap
/tests/convert.rs
UTF-8
1,673
3.1875
3
[]
no_license
#![no_std] use { core::convert::{ TryFrom, Infallible, }, bitwrap::*, }; #[test] fn test_readme_convert() { #[derive(Debug, PartialEq, Clone, Copy)] enum Coffee { Water, Latte, Cappuccino, Espresso, Americano, } impl Default for Cof...
true
742575ec61be3566c9669bff112e85454f6f9b38
Rust
rmorillo/backpool-rust
/src/backpool.rs
UTF-8
1,301
4.125
4
[]
no_license
pub struct LookBehindPool<T>{ capacity: u64, pool: Vec<T>, } impl<T> LookBehindPool<T>{ pub fn new(capacity: usize) -> LookBehindPool<T> { let m: Vec<T> = Vec::new(); LookBehindPool { capacity: capacity as u64, pool: m} } pub fn item(&self, index: usize) -> &T{ &self.pool[...
true
ee7f3026cd3cb6598d61ca6f7b6ffce465a9537f
Rust
pikajude/marsipan
/src/codec.rs
UTF-8
885
2.546875
3
[]
no_license
use bytes::BytesMut; use MarsError; use damnpacket; use damnpacket::Message; use tokio_io::codec::{Decoder,Encoder}; #[derive(Debug)] pub struct DamnCodec; impl Decoder for DamnCodec { type Item = Message; type Error = MarsError; fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self...
true
8b6e52e592fc42906bd3a21681cd29669a2f2ff4
Rust
ibenberge/abi_stable_crates
/abi_stable/src/prefix_type/layout.rs
UTF-8
1,856
2.9375
3
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0", "MIT" ]
permissive
use crate::{ sabi_types::{CmpIgnored,VersionStrings}, std_types::StaticStr, }; /// Represents the layout of a prefix-type,for use in error messages. #[repr(C)] #[derive(Debug, Copy, Clone, PartialEq, StableAbi)] pub struct PTStructLayout { pub name: StaticStr, pub generics:CmpIgnored<StaticStr>, ...
true
29313b1bcf4587f06258055fbeebae9ebe51f29e
Rust
iamsingularity/klocka
/server/src/push_target_manager.rs
UTF-8
1,593
3.109375
3
[]
no_license
use std::sync::{Arc, Mutex}; use std::fs::{File, OpenOptions}; use std::io::{Result, BufRead, BufReader, ErrorKind, Write}; use std::collections::HashSet; const FILE_PATH: &'static str = "push_targets.txt"; #[derive(Clone)] pub struct PushTargetManager { endpoints: Arc<Mutex<HashSet<String>>> } impl PushTargetMa...
true
8c4dfb03c859d5f1fa244449339a89564fa86c84
Rust
njskalski/sly-editor
/src/tests/cursor_set.rs
UTF-8
13,391
2.96875
3
[ "Apache-2.0" ]
permissive
/* Copyright 2018 Google LLC 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software dis...
true
d52cdacdfc76d26ce520f5d40683c8982794e8c7
Rust
agerasev/ringbuf
/src/traits/consumer.rs
UTF-8
13,597
3.265625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use super::{ delegate::DelegateMut, observer::{DelegateObserver, Observer}, utils::modulus, }; use crate::utils::{slice_assume_init_mut, slice_assume_init_ref, write_uninit_slice}; use core::{iter::Chain, mem::MaybeUninit, ptr, slice}; #[cfg(feature = "std")] use std::io::{self, Write}; /// Consumer part o...
true
a17559c4ef753a10462de466d3770ab94dd2df1a
Rust
czyczk/LeetCode
/rust/lc-131/src/solution.rs
UTF-8
942
3.15625
3
[]
no_license
pub struct Solution {} impl Solution { pub fn partition(s: String) -> Vec<Vec<String>> { let s = s.as_bytes(); let n = s.len(); let mut f = vec![vec![true; n]; n]; for i in (0..n).rev() { for j in i + 1..n { f[i][j] = s[i] == s[j] && f[i + 1][j -...
true
f3a43d0550c2289ac503de281a0dbd4f349a04fa
Rust
psinghal20/linkerd2-proxy
/linkerd/app/inbound/src/require_identity_for_ports.rs
UTF-8
1,205
2.5625
3
[ "Apache-2.0" ]
permissive
use indexmap::IndexSet; use linkerd2_app_core::{admit, transport::tls}; use std::sync::Arc; /// A connection policy that drops #[derive(Clone, Debug)] pub struct RequireIdentityForPorts { ports: Arc<IndexSet<u16>>, } #[derive(Debug)] pub struct IdentityRequired(()); impl<T: IntoIterator<Item = u16>> From<T> for ...
true
0dbbddde79ffef221ef498bc2373960321e642de
Rust
marco-c/gecko-dev-wordified
/third_party/rust/time/src/error/conversion_range.rs
UTF-8
970
2.890625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/ / ! Conversion range error use core : : fmt ; use crate : : error ; / / / An error type indicating that a conversion failed because the target type could not store the / / / initial value . # [ derive ( Debug Clone Copy PartialEq Eq ) ] pub struct ConversionRange ; impl fmt : : Display for ConversionRange { fn fmt ( ...
true
54288219704100fa5690b6fae4e23cffa1488cf9
Rust
tinnguyenhuuletrong/Learning
/rust-playground/stdlib/string.rs
UTF-8
671
3.65625
4
[]
no_license
fn main() { let a = String::from("Hello"); let b = String::from("World"); let c = a + " " + &b; println!("{} {}", b, c); // Caution // Slice string let d : &str = &b[0..1]; println!("{}", d, e); // Raised error b/c unicode char size variant // thread 'main' panicked at 'byte index 1 is not a char ...
true
c4378c60105fa876785b7a4110ba7f19b88898ab
Rust
austinprete/chipper
/src/display.rs
UTF-8
1,118
2.875
3
[]
no_license
use minifb::Window; use std::rc::Rc; use std::cell::RefCell; use crate::SCALE_FACTOR; pub struct Display { pub(crate) window: Rc<RefCell<Window>>, height: usize, width: usize, buffer: Vec<u32>, } impl Display { pub fn new(window: Rc<RefCell<Window>>) -> Display { let (width, height) = (*wi...
true
3dd8b728e01644e34d76be174b3ddefd8453b04b
Rust
ytakasugi/introduction_to_rust
/basic/chapter07/chapter0709/toy_vec/examples/toy_vec_01.rs
UTF-8
975
3.484375
3
[]
no_license
use toy_vec::ToyVec; fn main() { let mut v = ToyVec::new(); // 所有権が`push`メソッドにムーブする v.push("Java Finch".to_string()); // 所有権が`push`メソッドにムーブする v.push("Budgerigar".to_string()); // 要素数未満なので、`Some(&"Budgerigar".to_string())`を返す // 1. `get`メソッドの呼び出し元である`v`が所有する`ToyVec`構造体について、その参照`&self`が引数として渡...
true
caeae9fc117afc30f547f5d71a766a528c8d7cb2
Rust
LexxFedoroff/dottorrent-rs
/src/lib.rs
UTF-8
1,009
2.890625
3
[]
no_license
//! A small rust library for parsing and inspecting .torrent files. //! //! # Example //! //! ```rust //! use std::os; //! use dottorrent::Torrent; //! //! fn main() { //! let args = os::args(); //! for file in args.slice_from(1).iter() { //! println!("{}:", file); //! let p = Path::new(file.as_slice()); /...
true
37fb618102a0bee20f468c90e927e6342a212b23
Rust
minirobotdan/deno-rust-test
/src/lib.rs
UTF-8
435
3.46875
3
[]
no_license
#[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } #[test] fn square_works() { assert_eq!(crate::square(2), 4); } } /// Prints Hello, World! fn main() { println!("Hello, {name}!", name="World"); println!("My name is {0}, {1} {0}", "Bond", "James");...
true
85e7044569d7eba5719678f5b413afdf692cea83
Rust
calum/rust-unic
/unic/ucd/normal/src/lib.rs
UTF-8
2,347
2.53125
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2012-2015 The Rust Project Developers. // Copyright 2017 The UNIC 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 // <L...
true
6a27d802bce4b0ac2bcd0e4747c8cdafb169682f
Rust
dmweis/pointcloud_playground
/src/lib.rs
UTF-8
5,182
3.65625
4
[]
no_license
use std::ops::{Add, Sub}; use std::error::Error; use std::fs; use std::slice::Iter; #[derive(Debug, PartialEq, Copy, Clone)] pub struct Vector3 { pub x: f32, pub y: f32, pub z: f32, } impl Vector3 { pub fn new(x: f32, y: f32, z: f32) -> Vector3 { Vector3 {x, y, z} } } impl Add for Vector3...
true
93f378ed08b04eb1fc639a29135eb87d130da364
Rust
rust-wii/ogc-rs
/src/cache.rs
UTF-8
2,932
2.625
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::ffi; const CACHELINE_SIZE: usize = 32; /// Enable L1 data-cache. pub fn dc_enable() { unsafe { ffi::DCEnable() } } /// Disable L1 data-cache. pub fn dc_disable() { unsafe { ffi::DCDisable() } } /// Invalidate L1 data-cache. /// /// Marks the state of each data cache block as invalid without writi...
true
584f04d8cebb3f96e83796a632bff081df8033d5
Rust
laanwj/k210-pac
/src/dvp/axi.rs
UTF-8
4,152
2.734375
3
[ "ISC" ]
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::AXI { #[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
be56cad79eba7cb190470a79952e7ee15ef35b04
Rust
Phirefly9/Advent-of-Code-2018
/day2/src/main.rs
UTF-8
2,043
3.25
3
[]
no_license
extern crate itertools; use std::fs; use itertools::Itertools; fn main() { let contents = fs::read_to_string("input.txt").unwrap(); let chars_map: Vec<Vec<(char, i32)>> = contents.lines() // adbdadcd = [(a, 2), (b, 1), (c, 1), (d, 4)] ...
true
dfff290abb4ee3680c77b2a5024288e5e690b099
Rust
felixzhuologist/lambdacube
/src/syntax/mod.rs
UTF-8
550
2.59375
3
[]
no_license
pub mod kind; pub mod term; pub mod ty; pub use self::kind::Kind; pub use self::term::{ArithOp, BoolOp, Term}; pub use self::ty::Type; #[derive(Clone, Debug, PartialEq, Eq)] pub enum Command { Binder(Binder), Term(Box<Term>), } #[derive(Clone, Debug, PartialEq, Eq)] pub enum Binder { VarBind(String, Term...
true
e7c4e470d880f73f390b4aecd9b4adeba0996b67
Rust
blindley/stdex
/src/io/bitio/bitwriter_lsb.rs
UTF-8
6,894
3.578125
4
[]
no_license
use std::io::Write; use crate::io::write_u8; use super::Bit; /// Adapts an output stream to write one or more bits at a time pub struct BitWriterLSB<W: Write> { writer: W, buffer: u32, mask: u32, } impl<W: Write> BitWriterLSB<W> { pub fn new(writer: W) -> BitWriterLSB<W> { BitWriterLSB { ...
true
864344840950937f6c9697ad91b3f163882ee3d1
Rust
tommcgurl/learn-rust-live
/projects/chapter-10-generics-traits-lifetimes/traits/src/main.rs
UTF-8
3,317
3.859375
4
[]
no_license
use std::fmt::Display; // Trait definition without a default implementation. // pub trait Summary { // fn summarize(&self) -> String; // } pub trait Summary { fn summarize_author(&self) -> String; fn summarize(&self) -> String { format!("(Read more from {}...)", self.summarize_author()) } } p...
true
cb34257d7c818071f5779cb9a87c1544c7c989b4
Rust
huayl/pelikan
/src/rust/session/src/buffer.rs
UTF-8
4,887
3.234375
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Copyright 2021 Twitter, Inc. // Licensed under the Apache License, Version 2.0 // http://www.apache.org/licenses/LICENSE-2.0 //! A very simple buffer type that can be replaced in the future. use core::borrow::{Borrow, BorrowMut}; /// A growable byte buffer pub struct Buffer { buffer: Vec<u8>, read_offset:...
true
35ec8ec82033ba57bb06fa7050037389f4a0056a
Rust
gnoliyil/fuchsia
/third_party/rust_crates/vendor/event-listener-2.5.1/src/lib.rs
UTF-8
31,119
3.4375
3
[ "BSD-2-Clause", "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
//! Notify async tasks or threads. //! //! This is a synchronization primitive similar to [eventcounts] invented by Dmitry Vyukov. //! //! You can use this crate to turn non-blocking data structures into async or blocking data //! structures. See a [simple mutex] implementation that exposes an async and a blocking inte...
true
c5f70da7efd36d8795e2adcd980b9f1925ac0fbb
Rust
DoNotDoughnut/voxel-rs
/common/src/player.rs
UTF-8
4,606
2.9375
3
[ "MIT", "CC-BY-4.0" ]
permissive
use crate::world::ChunkPos; use serde::Deserialize; /// The input of a player #[derive(Debug, Clone, Copy)] pub struct PlayerInput { pub key_move_forward: bool, pub key_move_left: bool, pub key_move_backward: bool, pub key_move_right: bool, pub key_move_up: bool, pub key_move_down: bool, pu...
true
5514f5259bd418fcf261be962d7327b3eac2e84f
Rust
move-z/adventofcode2018
/src/bin/day09.rs
UTF-8
3,697
3.34375
3
[]
no_license
use adventofcode2018::*; use std::cell::RefCell; use std::rc::Rc; use lazy_static::lazy_static; use regex::Regex; fn first(player_num: usize, max_value: usize) -> usize { let mut players = vec![0; player_num]; let mut board = List::new(0); for cur in 1..=max_value { if cur % 23 == 0 { ...
true
47a056b8a954070597ef58ba2606f7de12c8e5f8
Rust
zeroday0619/ipinfo
/src/models/country.rs
UTF-8
889
2.703125
3
[ "MIT" ]
permissive
use std::fmt::{Display, Formatter}; use reqwest::Error; use serde::Deserialize; use crate::kwabang::fetchers::fetch_country; use crate::models::internal::country_internal::{ CountryContinent, CountryCountry, CountryRegisteredCountry, }; use crate::models::KwabangType; #[derive(Deserialize)] pub struct Country { ...
true
8a95f04c974e67dba2c894cfe2e4982a8d2863af
Rust
fabura/icu4x
/components/decimal/src/format.rs
UTF-8
2,263
2.65625
3
[ "Apache-2.0", "ICU", "MIT", "LicenseRef-scancode-unicode" ]
permissive
// This file is part of ICU4X. For terms of use, please see the file // called LICENSE at the top level of the ICU4X source tree // (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ). //! Lower-level types for decimal formatting. use crate::grouper; use crate::options::*; use crate::provider::*; use...
true
0f92d4dceb543c661ff58d35649009e4fe4866e5
Rust
isgasho/fundsp
/src/audiounit.rs
UTF-8
3,033
3.171875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::audionode::*; use super::*; /// AudioUnit processes audio data block by block at a synchronous rate. /// Once constructed, it has a fixed number of inputs and outputs that can be queried. /// If not set otherwise, the sample rate is presumed the system default DEFAULT_SR. pub trait AudioUnit { /// Reset...
true
02a7d59d5833cbb8250c78da2cd11c80c4864058
Rust
callmeahab/mvt
/src/mapgrid.rs
UTF-8
8,813
3.28125
3
[ "Apache-2.0", "MIT" ]
permissive
// mapgrid.rs // // Copyright (c) 2019-2020 Minnesota Department of Transportation // //! BBox, TileId and MapGrid structs. //! use crate::error::Error; use pointy::{Pt64, Transform64}; use std::fmt; /// A bounding box is an axis-aligned rectangle. /// /// It is defined by two corners: north_west and south_east. /// ...
true
1515829d44e878c49ac2c5465f4ef4b62d01fa61
Rust
nodebotanist/rust-programming-language-book
/ch4/src/main.rs
UTF-8
1,122
4.125
4
[ "MIT" ]
permissive
fn main() { let x = 5; let y = x; println!("y is {} and x is {}", x, y); let s1 = String::from("Hello"); let s2 = s1; // s1 is now invalid let s3 = s2.clone(); // println!("{}", s1); won't work println!("s2 is {} and s3 is {}", s2, s3); let s = String::from("World"); take_own...
true
b8ea03fe6f5de743cd758875bdc0c90d5503fc8e
Rust
holmesmr/nicegit-rs
/src/tree.rs
UTF-8
1,657
2.984375
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
use {GitDirectory, DirectoryEntry, TreeEntryExt}; use std::cmp::Ordering; use git2::Tree; /// A set of extension methods for the `Tree` type in `git2`. pub trait TreeExt { /// Get a list of all the named entries at this level in the tree. fn entry_names(&self) -> Vec<String>; /// Get a higher level, pre-s...
true
e2f0ee6867a7e6b0176ab4367751ff3918c981fd
Rust
lirsacc/brokkr
/examples/scheduler.rs
UTF-8
2,745
2.953125
3
[ "MIT" ]
permissive
// This is pretty basic cron-based scheduler. // // The scheduler will attempt to push tasks to the queue at // regular interval / times (any cron expression is supported) // without guarantee that the tasks are executed at these times. // If your worker pool has capacity at that time it should be close // enough for m...
true
fbd44625faf78cefa92df3819d10da5cfa0985d5
Rust
modelflat/practice-again
/src/xor.rs
UTF-8
600
3.578125
4
[]
no_license
use std::iter::Iterator; /// Performs XOR encoding on an array of bytes, using a given key. pub fn xor_inplace(bytes: &mut [u8], key: &[u8]) { for (i, b) in bytes.iter_mut().enumerate() { *b ^= key[i % key.len()]; } } #[cfg(test)] mod tests { use super::*; #[test] pub fn test_xor_applied_...
true
40afaa1736206a59ac6463a74ba7d2a00c45d78a
Rust
sebm/checkers
/src/main.rs
UTF-8
3,680
3.328125
3
[]
no_license
use std::io; mod board; use board::{BoardSquare, initial_board, draw_board}; fn available_moves(board: &[[BoardSquare; 8]; 8], x: usize, y: usize) -> Vec<(usize, usize)> { let check_forward = |moves: &mut Vec<(usize, usize)>| { if y > 0 { match board[x+1][y-1] { BoardSquare::Em...
true
55d67afa48ee5d46c46e1e233d7b3c47dce36e28
Rust
KDahir247/Rust-Learning-Rendering
/examples/clear-color/main.rs
UTF-8
2,143
2.625
3
[ "MIT" ]
permissive
use util; use glium; use glium::backend::glutin::glutin::event::{Event, WindowEvent}; use glium::Surface; fn main() { use glium::glutin; println!("SuperLuminal Performance Enabled: {}", superluminal_perf::enabled()); // Set name of current thread for superluminal profiler superluminal_perf::set_cur...
true
ab2f286bf55ed46d1556aaf9846f9cb2b23675e7
Rust
eliaslevy/rust-hyperscan
/hyperscan/src/chimera/pattern.rs
UTF-8
5,730
3.09375
3
[]
no_license
use std::fmt; use std::iter::FromIterator; use std::str::FromStr; use anyhow::{bail, Error}; use bitflags::bitflags; use derive_more::{Deref, DerefMut, From, Index, IndexMut, Into, IntoIterator}; use crate::chimera::ffi; bitflags! { /// Pattern flags #[derive(Default)] pub struct Flags: u32 { ///...
true
5c2761774a4afd4663d580642366d8f00fe0b40c
Rust
bch29/tracer
/src/tracer.rs
UTF-8
965
2.828125
3
[]
no_license
use types::*; use partition::*; use object::*; pub struct Scene { params: SceneParams, objects: Partition<Box<Object>>, eye_pos: P3, image_tl: P3, } impl Scene { fn trace_partition(&self, part: &Partition<Box<Object>>, ray: Ray) -> RayResult { // If the objects can be partitioned, do it an...
true
adee9de85e7bedf12b5ca6abfb6ce4fe40494e92
Rust
bytecodealliance/wasmtime
/tests/host_segfault.rs
UTF-8
10,629
2.90625
3
[ "LLVM-exception", "Apache-2.0" ]
permissive
// To handle out-of-bounds reads and writes we use segfaults right now. We only // want to catch a subset of segfaults, however, rather than all segfaults // happening everywhere. The purpose of this test is to ensure that we *don't* // catch segfaults if it happens in a random place in the code, but we instead // bail...
true
b1236ac9ba58cf963304ce8621fb8f121dac8c25
Rust
sile/mpeg2ts
/src/ts/pmt.rs
UTF-8
7,363
2.578125
3
[ "MIT" ]
permissive
use crate::es::StreamType; use crate::ts::psi::{Psi, PsiTable, PsiTableHeader, PsiTableSyntax}; use crate::ts::{Pid, VersionNumber}; use crate::{ErrorKind, Result}; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use std::io::{Read, Write}; /// Program Map Table. #[allow(missing_docs)] #[derive(Debug, Clone, ...
true
3a06c4d0f841c1f0560349715ed42de2bcae9b02
Rust
leahferrell/intel_8080_emulator
/src/architecture/model/condition_codes.rs
UTF-8
2,235
3.53125
4
[]
no_license
#[derive(Debug, Eq, PartialEq, Default)] pub struct ConditionCodes { pub z: bool, pub s: bool, pub p: bool, pub cy: bool, pub ac: bool } impl ConditionCodes { pub fn as_binary(&self) -> u8 { let _7 = if self.s {0x80} else {0x00}; let _6 = if self.z {0x40} else {0x00}; l...
true
c0df7fde27e11fd676e7fac2e52a1b4e44f70262
Rust
gabrielNT/aoc2020
/src/day14.rs
UTF-8
5,059
3.296875
3
[]
no_license
use regex::Regex; use std::collections::HashMap; const MEMORY_SIZE: usize = 100000; // Is there an address bigger than this in the input? const MAX_36_BITS: u64 = u64::max_value() >> (64 - 36); #[derive(Debug, PartialEq)] pub struct Instruction { value: u64, address: usize, } #[derive(Debug, PartialEq)] pub ...
true
8212d08b3d6fb455f5e748f0a5d3d666e1fb6e40
Rust
Jorch72/kristforge
/src/extensions.rs
UTF-8
1,465
2.734375
3
[]
no_license
use ::ocl::{Device, DeviceType}; use ::ocl::error::Result as OclResult; use ::ocl_extras::full_device_info::FullDeviceInfo; use ::std::cmp::{max, min}; use ::std::ffi::CStr; /// Kristforge-specific extensions for `ocl::Device` pub trait DeviceExtensions { /// Get the desired vector width to use for mining with this d...
true
0d04191dd01f3a20ed0f943d9a128334a69a04b4
Rust
yoshihitoh/ut-cli
/src/cmd/parse/run.rs
UTF-8
2,022
2.765625
3
[ "MIT" ]
permissive
use std::fmt::{Debug, Display}; use std::io; use anyhow::Context; use chrono::{Offset, TimeZone}; use clap::ArgMatches; use crate::find::FindByName; use crate::precision::Precision; use crate::provider::DateTimeProvider; use crate::read::{read_next, ReadError}; #[derive(Debug)] pub struct ParseRequest<P> { provi...
true
c2efb7dd002bb01a04d91ac7bb9ddd328b38e88c
Rust
togglebyte/netlib
/src/net/uds.rs
UTF-8
2,153
2.578125
3
[ "MIT" ]
permissive
use std::convert::TryFrom; use std::path::Path; use std::net::Shutdown; use std::os::unix::net::{UnixStream as StdUnixStream, UnixListener as StdUnixListener, SocketAddr}; use std::os::unix::io::FromRawFd; use super::socket::Socket; use crate::{Interest, PollReactor, Reaction, Reactor, Result}; // -------------------...
true
4702dbf0d0d72ea4d0e425f5c1f9bba1fde169e3
Rust
richwandell/rust-algorithms
/src/bin/neural_network.rs
UTF-8
5,378
2.75
3
[]
no_license
extern crate ndarray; use std::ops::Mul; use ndarray::{arr2, Array, Array2, ArrayBase, Ix, OwnedRepr}; use ndarray::Ix2; use ndarray_rand::rand_distr::Uniform; use ndarray_rand::RandomExt; use ndarray_stats::QuantileExt; struct NeuralNetwork { W1: Array2<f64>, W2: Array2<f64>, y_hat: Array2<f64>, Z2:...
true
14c315deea649496ee5ba7f810198e454b08aa22
Rust
AlisCode/ld44
/src/resources/selection.rs
UTF-8
532
3.25
3
[ "MIT" ]
permissive
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)] pub enum SelectInfo { None, Player, } impl Default for SelectInfo { fn default() -> Self { SelectInfo::None } } #[derive(Debug, Default)] pub struct Selection { pub select_info: Option<SelectInfo>, pub just_selected: bool, } impl Sele...
true
f11a90c71d1fa6b6beb0f0f20eebd7a8c158abf0
Rust
AmaranthineCodices/win32_notification
/src/lib.rs
UTF-8
8,639
3.140625
3
[ "MIT" ]
permissive
use std::cell::RefCell; use std::ffi::OsString; use std::fmt; use std::os::windows::ffi::{OsStrExt, OsStringExt}; use winapi::shared::guiddef::GUID; use winapi::shared::winerror; use winapi::um::combaseapi::CoCreateGuid; use winapi::um::errhandlingapi::GetLastError; use winapi::um::shellapi::{self, Shell_NotifyIconW, N...
true
97ba348e6f5b8f93fefc4c6b23cb23ce9dc1a8d2
Rust
vaisakhsaikripa/fd
/src/main.rs
UTF-8
15,849
2.734375
3
[ "MIT" ]
permissive
#[macro_use] extern crate clap; extern crate ansi_term; extern crate atty; extern crate regex; extern crate ignore; extern crate num_cpus; pub mod lscolors; pub mod fshelper; mod app; use std::env; use std::error::Error; use std::io::Write; use std::ops::Deref; #[cfg(unix)] use std::os::unix::fs::PermissionsExt; use ...
true
645c531023dbd9a5a4f753db286be5a6fde68d1c
Rust
gengkev/adventofcode-2017
/24.rs
UTF-8
3,091
3
3
[]
no_license
use std::env; use std::collections::HashMap; use std::collections::hash_map::RandomState; use std::collections::VecDeque; use std::fs::File; use std::io::BufRead; use std::io::BufReader; use std::process::exit; use std::time::Instant; type PipeChain = Vec<(i32, i32)>; type PipeMap = HashMap<i32, PipeChain, RandomState...
true
e040a6500a0e1dde6dc911ea7900043b26e720ed
Rust
joshgarnett/adventofcode2018
/src/day2/mod.rs
UTF-8
2,258
3.4375
3
[]
no_license
use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader}; pub fn part1(filename: &str) -> i32 { let file = File::open(filename).expect("file not found"); let mut two_letters = 0; let mut three_letters = 0; let mut letters: HashMap<char, i32> = HashMap::new(); for line in...
true
9c701aff455078f7aaee0461161581717961670d
Rust
ElPicador/rust_db
/src/row.rs
UTF-8
2,161
3.296875
3
[]
no_license
use std::io; use std::io::Error; use std::io::ErrorKind; use std::ops::Deref; use std::io::BufWriter; use std::io::BufReader; use std::io::Write; use std::io::Read; pub struct Row { pub id: u32, pub username: String, pub email: String, } impl Row { pub fn read(mut input: BufReader<u8>) -> io::Result<...
true
9301300b11e0baf8a2a162f8cf8b454756547e5e
Rust
clap-rs/clap
/tests/derive/raw_idents.rs
UTF-8
456
2.84375
3
[ "MIT", "Apache-2.0" ]
permissive
use clap::Parser; #[test] fn raw_idents() { #[derive(Parser, Debug, PartialEq)] struct Opt { #[arg(short, long)] r#type: String, } assert_eq!( Opt { r#type: "long".into() }, Opt::try_parse_from(["test", "--type", "long"]).unwrap() ); assert_...
true
bd5d31fd1285df13d940b52166dbaf3da9e0bf34
Rust
roysmeding/stm32f334
/src/hrtim_timb/rstbr/mod.rs
UTF-8
46,943
2.703125
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
#[doc = r" Value read from the register"] pub struct R { bits: u32, } #[doc = r" Value to write to the register"] pub struct W { bits: u32, } impl super::RSTBR { #[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
1a952d0f85d8374bce5c9dd91e40a26ae7371295
Rust
ph0llux/tar-rs
/src/streamer.rs
UTF-8
36,381
2.921875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::other; #[cfg(unix)] use std::os::unix::prelude::*; #[cfg(windows)] use std::os::windows::prelude::*; use std::collections::HashMap; use std::fs::{self}; use std::io::{self, Read, Result, Seek, SeekFrom}; use std::path::{Path, PathBuf}; use std::str; use crate::header::{prepare_header, Header, HeaderMode};...
true
083f63b5dbd6efeed2ea2ba868262da8313e709f
Rust
makandat/RustLib
/src/lib.rs
UTF-8
1,278
3.75
4
[]
no_license
// コマンドライン引数 pub mod a { use std::env; // コマンドライン引数の数を得る。 pub fn args_count() -> i32 { let argv: Vec<String> = env::args().collect(); (argv.len() - 1) as i32 } // コマンドライン引数のリストを得る。 pub fn args() -> Vec<String> { let mut argv: Vec<String> = env::args().collect(); argv.remove(0); argv ...
true
ae7b1481afbba161686da5115459a7b3b1493f0e
Rust
dakom/awsm-web
/crate/src/dom/resize.rs
UTF-8
6,987
2.625
3
[ "MIT", "Apache-2.0" ]
permissive
use wasm_bindgen::prelude::*; use web_sys::{Element, DomRect}; use js_sys::Array; use std::convert::TryInto; /// Temporary placeholder until https://github.com/rustwasm/wasm-bindgen/issues/2289 /// We don't care about the callback params, so it's left out #[wasm_bindgen] extern "C" { #[wasm_bindgen(js_name = Resiz...
true
b9a582405d3ca12ccfc60e23e2f212f5fa18c20a
Rust
wjlewis/taste-of-lambda
/src/source.rs
UTF-8
751
3.265625
3
[]
no_license
use std::fmt; #[derive(Clone, PartialEq)] pub struct Span { pub start: usize, pub end: usize, } impl Span { pub fn new(start: usize, end: usize) -> Self { Span { start, end } } pub fn combine_with(self, other: Self) -> Self { let start = usize::min(self.start, other.start); ...
true
cd23d2236bf16c7d24f0aab89db6164a1702e4b8
Rust
hamadu/competitive-rust
/src/atcoder/agc025/agc025_d.rs
UTF-8
4,380
2.828125
3
[]
no_license
// https://atcoder.jp/contests/agc025/tasks/agc025_d // #![allow(unused_imports)] use std::io::*; use std::fmt::*; use std::str::*; use std::cmp::*; use std::collections::*; macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); input_inner!{iter, $($r)*} ...
true
283f5c2d88876267717b094a489d15a92b6021a7
Rust
CNife/leetcode
/rust/finished/src/repeated_string_match.rs
UTF-8
681
3.34375
3
[]
no_license
pub fn repeated_string_match(a: String, b: String) -> i32 { let mut buffer = String::with_capacity(3 * a.len() + b.len()); while buffer.len() < b.len() { buffer.push_str(&a); } while buffer.len() <= 2 * a.len() + b.len() { if buffer.contains(&b) { return (buffer.len() / a.len...
true
04b1d682835883cfe56e4c827304c4bb9155926d
Rust
rcore-os/rcore-fs
/rcore-fs-sefs/src/structs.rs
UTF-8
3,286
2.9375
3
[ "MIT" ]
permissive
//! On-disk structures in SEFS use alloc::str; use core::fmt::{Debug, Error, Formatter}; use core::mem::{size_of, size_of_val}; use core::slice; use static_assertions::const_assert; /// On-disk superblock #[repr(C)] #[derive(Debug)] pub struct SuperBlock { /// magic number, should be SFS_MAGIC pub magic: u32,...
true
08909fb3d5080c8b414202bf93ebe96b78d885cb
Rust
Global19-atlassian-net/rusty
/cli_mini/src/main.rs
UTF-8
2,411
3.671875
4
[]
no_license
use structopt::StructOpt; // search for a pattern in a file and disoplay the lines that contain(s) it. #[derive(StructOpt, Debug)] struct Cli { // pattern to look for pattern: String, // path where file to read files #[structopt(parse(from_os_str))] path: std::path::PathBuf, // like string but f...
true
4a9b2367ed8edcd89a01f983be9a69b70e7eb11e
Rust
Pyxxil/rust-lc3-as
/src/token/tokens/br.rs
UTF-8
2,455
2.875
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use crate::{ listing, notifier::{self, DiagType, Diagnostic, Highlight}, token::{ tokens::{ expected, too_few_operands, traits::{Assemble, Requirements}, }, Token, }, types::{Listings, SymbolTable}, }; token!(Br, n: bo...
true
e9697cd494ac028cd5194e2ae6b378520ffcdf46
Rust
nrjais/migrator
/src/backend/postgres.rs
UTF-8
2,558
2.515625
3
[]
no_license
use super::migration_column_names; use crate::executor::{Backend, Direction, MigrationEntry}; use crate::Result; use migration_column_names::{CHECKSUM, ID}; use postgres::{Client, NoTls, Row}; pub struct PostgresBackend { client: Client, } impl Default for PostgresBackend { fn default() -> Self { Self...
true
43b55fd8eaa3bd10ea03018084a30e9509ffd9b8
Rust
LuRsT/breezometer_dummy_api
/src/serializers.rs
UTF-8
2,780
2.53125
3
[ "MIT" ]
permissive
use serde::Serialize; #[derive(Serialize)] pub struct PollenCount { pub pollenCountInfo: PollenCountInfo, } #[derive(Serialize)] pub struct PollenCountInfo { pub date: String, pub index_id: String, pub index_display_name: String, pub types: PollenTypes, pub plants: PlantTypes, } #[derive(Seri...
true
a4280ffad338c38df6a31901102b1ad8127efe58
Rust
MarvinKlemp/fs-totp-client
/src/main.rs
UTF-8
1,196
2.859375
3
[]
no_license
#[macro_use] extern crate text_io; extern crate ring; use std::env; mod command; use command::Command; use command::encrypt::EncryptCommand; use command::decrypt::DecryptCommand; use command::command_handler::CommandHandler; fn print_flush(output: &str) { use std::io; use std::io::prelude::*; print!("{}...
true
983d9595b50d4e0506fa1aa7ea7fdb993917bdef
Rust
tiburin/mas
/src/main.rs
UTF-8
12,603
3.015625
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::collections::HashSet; use std::fs; const OFF: &str = "word.off"; const ON: &str = "word.on"; const MATCH: &str = ""; const MATCHEND: bool = true; const SORT_BY_POPULAR: bool = false; const MUST_CONTAINS_WORDS: bool = false; const SPANISH: bool = false; type Tipo = HashSet<String>...
true
6feaa8f0677c70e7ea409f6f33860d3df0a16690
Rust
TheRuskyTeam/Rusky.old
/src/commands/moderation.rs
UTF-8
3,431
2.984375
3
[ "MIT" ]
permissive
use serenity::builder::CreateEmbed; use crate::{ constants::{ colors::{BLUE, MATERIAL_RED}, emotes::RUSKY_CHECK, }, errors::NoneError, get_arg, slash, utils::{guild::get_guild_owner, message::yes_no_menu}, }; pub struct BanCommand; slash!(BanCommand => (@name: "ban") (@d...
true
7f5d83a85552e869b3b9668b012fed6a8d26c614
Rust
asomers/mockall
/mockall/tests/automock_generic_arguments.rs
UTF-8
383
2.578125
3
[ "Apache-2.0", "MIT" ]
permissive
// vim: tw=80 //! generic methods with generic arguments #![deny(warnings)] use mockall::*; #[automock] trait A { fn foo<T: 'static>(&self, t: T); } #[test] fn returning() { let mut mock = MockA::new(); mock.expect_foo::<u32>() .returning(|_x: u32| ()); mock.expect_foo::<i16>() .retur...
true
fb05334063aaf194d159eda3735b04ca31c6d5a4
Rust
cfcosta/menu
/src/main.rs
UTF-8
2,418
3.1875
3
[]
no_license
use std::str; use std::collections::HashMap; use std::error::Error; use std::fs; use std::process::{Command, Stdio}; use std::io::prelude::*; use serde::{ Serialize, Deserialize }; use serde_yaml; #[derive(Debug, PartialEq, Serialize, Deserialize)] pub struct Config { defaults: DefaultConfig } #[derive(Debug, Part...
true
b9104bac69808376caa5846b578dc50b00c8afad
Rust
DNature/rover
/crates/rover-client/tests/schema.rs
UTF-8
51,566
2.8125
3
[ "MIT" ]
permissive
use graphql_client::Response; use rover_client::introspection::Schema; use std::convert::TryFrom; use std::fs::File; #[cfg(test)] mod tests { use super::*; use indoc::indoc; use pretty_assertions::assert_eq; use rover_client::query::graph::introspect; pub type IntrospectionResult = introspect::int...
true
5f6d74334bed554b8be92b14a3936e31eb5f7383
Rust
elbaro/ps-util
/src/runner.rs
UTF-8
8,185
2.53125
3
[]
no_license
use crate::sandbox; use crate::sandbox::Limitation; use colored::*; use std::fs::File; use std::io::Read; use std::os::unix::process::CommandExt; use std::path::Path; use std::process::{Command, Stdio}; use std::time::Duration; use wait_timeout::ChildExt; use walkdir::WalkDir; use error_chain::error_chain; error_chai...
true
7bebdcb01ddf5b3200c54bf91388e826197d7463
Rust
zargony/advent-of-code-2017
/src/day13.rs
UTF-8
3,492
3.25
3
[]
no_license
#![cfg_attr(feature = "nightly", feature(test))] #[macro_use] extern crate nom; use std::str::FromStr; use nom::digit; #[derive(Debug, PartialEq)] struct Layer { depth: u32, range: u32, } impl FromStr for Layer { type Err = nom::ErrorKind; fn from_str(s: &str) -> Result<Self, Self::Err> { ...
true
072e0becbb117d3ab93552dc008cd58f4d3d89e3
Rust
Luni-4/libass-rs
/libass/src/style.rs
UTF-8
2,545
2.515625
3
[ "ISC" ]
permissive
use bitflags::bitflags; use std::ffi::CString; use std::os::raw::c_int; use libass_sys as ffi; pub struct Style { pub name: CString, pub font_name: CString, pub font_size: f64, pub primary_color: u32, pub secondary_color: u32, pub outline_color: u32, pub back_color: u32, pub bold: bool...
true
5c00d1f97da9bf2a458c2cb957779c34c42b52b7
Rust
iCodeIN/suckit
/tests/external.rs
UTF-8
2,297
2.765625
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
//! Tests for using --ext-depth mod fixtures; use fixtures::get_file_count_with_pattern; use std::fs::read_dir; use std::process::Command; use std::process::Stdio; use std::sync::Once; const PAGE: &'static str = "tests/fixtures/index.html"; const IP: &'static str = "0.0.0.0"; static START: Once = Once::new(); #[tes...
true
f4fc2e8c129cdc3eb8b67f94e6ca3a26ed6a9543
Rust
teliosdev/slip
/slip-compile/src/syn/roll.rs
UTF-8
4,661
3.0625
3
[]
no_license
use super::*; use std::cmp::{Eq, PartialEq}; use std::hash::{Hash, Hasher}; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Roll<T: Node> { contents: Vec<T>, area: Span, } impl<T: Node> Roll<T> { pub fn empty() -> Roll<T> { Roll { contents: vec![], area: Span::i...
true
06d83d8bb448b1134e1e16ec30689f4cfecc52c6
Rust
ccmlm/rs-merkle
/src/merkle_tree.rs
UTF-8
20,246
3.171875
3
[ "MIT" ]
permissive
use crate::{partial_tree::PartialTree, utils, utils::indices, Hasher, MerkleProof}; /// [`MerkleTree`] is a Merkle Tree that is well suited for both basic and advanced usage. /// /// Basic features include the creation and verification of Merkle proofs from a set of leaves. /// This is often done in various cryptocurr...
true
e935de775b0e92ee90b8092c2b90fce4eed9ef21
Rust
ultracold273/leetcode-rs
/src/contest_182/pr3.rs
UTF-8
1,563
2.953125
3
[]
no_license
use std::collections::HashMap; struct UndergroundSystem { db_i: HashMap<String, Vec<(i32, i32)>>, db_o: HashMap<String, Vec<(i32, i32)>>, } impl UndergroundSystem { fn new() -> Self { UndergroundSystem { db_i: HashMap::new(), db_o: HashMap::new() } } fn check_in(&mut self, id: i32, ...
true
9d0392a5ca7fc1dc02bafca1f0996582070e3c6c
Rust
modeverv/RustBook201912
/mojiretsu/src/main.rs
UTF-8
3,263
3.625
4
[]
no_license
fn main() { println!("Hello, world!"); // 00 println!("{}",reverse("abc")); // 01. 「パタトクカシーー」 println!("{}",odd_chars("パタトクカシーー")); // 02. 「パトカー」+「タクシー」=「パタトクカシーー」 println!("{}",concat_alternately("パトカー", "タクシー")); // 03. 円周率 println!("{:?}",pi_from_text()); // 04. 元素記号 prin...
true
21f941caef2d7ea8b3a38c7500af676e2b1ea3b8
Rust
n4o847/procon-rust
/accepted/arc123_a.rs
UTF-8
269
2.5625
3
[]
no_license
use proconio::{fastout, input}; #[fastout] fn main() { input! { a: i64, b: i64, c: i64, } let x = b - a; let y = c - b; let ans = if x > y { x - y } else { (y - x) / 2 + (y - x) % 2 * 2 }; println!("{}", ans); }
true
64d04cf9d4c5773c729672e8a491624736777f34
Rust
jjyr/restricted-sparse-merkle-tree
/src/tree.rs
UTF-8
12,301
2.984375
3
[ "MIT" ]
permissive
use crate::{ collections::{BTreeMap, VecDeque}, error::{Error, Result}, merge::{hash_leaf, merge}, merkle_proof::MerkleProof, traits::{Hasher, Store, Value}, vec::Vec, EXPECTED_PATH_SIZE, H256, }; use core::{cmp::max, marker::PhantomData}; /// A branch in the SMT #[derive(Debug, Eq, Partial...
true
1aaf12676f7497a5eb731b8d6dd59bd0fbcd867f
Rust
Joylei/qute
/ctrl/src/hal/sio.rs
UTF-8
1,955
3.171875
3
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
use super::port::{open, Port}; use crate::Result; pub struct Controller { index_port: Box<dyn Port>, data_port: Box<dyn Port>, pnp: bool, } impl Controller { #[inline] pub fn new(index_port: Box<dyn Port>, data_port: Box<dyn Port>) -> Self { Self { index_port, ...
true
cc15c2b6a8c93787943a81f2d75e61ef65a942b1
Rust
gnoliyil/fuchsia
/src/storage/fshost-rust/src/crypt/zxcrypt.rs
UTF-8
3,350
2.515625
3
[ "BSD-2-Clause" ]
permissive
// Copyright 2022 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::{format_sources, get_policy, unseal_sources, KeyConsumer}, crate::device::Device, anyhow::{anyhow, bail, Context, Error}, devi...
true
4ea51c00fc20a8d001ac50b1c0c956e57251334d
Rust
intrepion/create-a-backend-api-with-rust-and-postgres
/emply/src/employees/routes.rs
UTF-8
1,072
2.828125
3
[ "MIT" ]
permissive
use crate::employees::{Employee}; use actix_web::{get, web, HttpResponse, Responder}; #[get("/employees")] async fn find_all() -> impl Responder { HttpResponse::Ok().json(vec![ Employee { id: 1, first_name : "Ola".to_string(), last_name: "John Ajiboye".to_string(), ...
true
63efddaf579cdb4f862126171cbcef8b6676d806
Rust
j-browne/advent-of-code
/2022/src/keep_away.rs
UTF-8
7,335
3.109375
3
[]
no_license
use std::{ collections::{BinaryHeap, HashMap}, mem, ops::{AddAssign, DivAssign, MulAssign, Rem}, }; #[derive(Debug, Clone)] pub struct KeepAway { monkeys: Vec<Monkey>, with_reducing: bool, } impl KeepAway { #[must_use] pub fn new(s: &str, with_reducing: bool) -> Self { let mut monk...
true
973e0fe5cf03eb25494b6748fa5e50f967452068
Rust
tayu0110/calculator
/src/main.rs
UTF-8
4,428
3.609375
4
[]
no_license
use std::{ io::{Write, stdout}, process::exit }; fn main() { println!("Hello!! This is the calculator program."); println!("Please input numerical expressions following prompts."); println!("\tExit the program\t-> input \"exit\""); println!("\tView the manual \t-> input \"help\""); while c...
true
e7297b20fb6700e70171233a371d60329fc1f26e
Rust
conner-s/ch12_minigrep
/src/minigrep_config.rs
UTF-8
2,298
3.515625
4
[]
no_license
use std::error::Error; use std::fs; use std::env; pub struct Config { pub search_string: String, pub search_source_file: String, pub env_sensitivity: bool, } impl Config { pub fn new(args: &[String]) -> Result<Config, &'static str>{ if args.len() < 3{ return Err("There are n...
true
3f68873ffd6a59e9fd3cf4732b70755fc05071b8
Rust
basiliqio/ciboulette
/src/body/request_body.rs
UTF-8
21,512
2.75
3
[ "Apache-2.0", "MIT" ]
permissive
use super::*; use serde::de::{Deserializer, Visitor}; use std::fmt::Formatter; /// ## Object holder `json:api` version #[derive(Debug, Clone, Getters, MutGetters, Deserialize, Serialize)] #[getset(get = "pub", get_mut = "pub")] pub struct CibouletteJsonApiVersion<'request> { version: Cow<'request, str>, } impl<'re...
true
b153eeaca1a1b3e19052aa66bcb77407e4b71fb4
Rust
isgasho/rg3d
/src/gui/text.rs
UTF-8
4,700
2.6875
3
[ "MIT" ]
permissive
use crate::{ gui::{ builder::CommonBuilderFields, VerticalAlignment, HorizontalAlignment, event::{RoutedEventHandlerType, RoutedEventHandler}, Drawable, Thickness, draw::{ FormattedText, DrawingContext, FormattedTextBuilder,...
true
fe2b7139f6131a48cc6a783d1d87782e61afea4d
Rust
arizuk/programming-contest-solutions
/atcoder/ABC141/E/main.rs
UTF-8
3,862
2.921875
3
[]
no_license
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read...
true
58726f4815a798ea722837a10191562730292f40
Rust
gnoliyil/fuchsia
/src/connectivity/wlan/lib/common/rust/src/security/wpa/credential.rs
UTF-8
7,284
3.09375
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 hex; use std::convert::{TryFrom, TryInto}; use std::fmt::Debug; use std::str; use thiserror::Error; pub const PSK_SIZE_BYTES: usize = 32; pub const PA...
true
9968c674f2b9f368e374f378967446039b683b5f
Rust
rarewin/my-studies
/rust/rust-by-example/expression/src/main.rs
UTF-8
236
3.015625
3
[ "BSD-2-Clause" ]
permissive
fn main() { let x = 5; let y = { let x_squared = x * x; let x_cubed = x * x * x; x_squared * x_cubed }; println!("{:?}", y); let z = { y * 5 }; println!("{:?}", z); }
true
300b3924332ac14b983543a7247db0cfdf63ba36
Rust
blueluna/probe-rs
/probe-rs/src/flashing/error.rs
UTF-8
1,903
2.90625
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use thiserror::Error; use crate::config::FlashRegion; use crate::error; /// Describes any error that happened during the or in preparation for the flashing procedure. #[derive(Error, Debug)] pub enum FlashError { #[error("The execution of '{name}' failed with code {errorcode}")] RoutineCallFailed { name: &'st...
true
0e59734ff846cf7c7c3f8062a1ae4b54b382aa43
Rust
saboco/learning-rust
/variables/src/main.rs
UTF-8
799
3.609375
4
[]
no_license
fn main() { println!("*********** Mutable variables ***********"); mutable_variables(); println!("*****************************************"); println!("*************** Constants ***************"); constants(); println!("*****************************************"); println!("*************** ...
true
6b02dbce2b66dd82dc683aee202d5cb477a0cccf
Rust
asomers/mockall
/mockall/tests/automock_generic_static_method.rs
UTF-8
641
2.515625
3
[ "Apache-2.0", "MIT" ]
permissive
// vim: tw=80 //! generic static methods with generic arguments #![deny(warnings)] use mockall::*; use std::sync::Mutex; lazy_static! { static ref A_MTX: Mutex<()> = Mutex::new(()); } #[automock] trait A { fn bar<T: 'static>(t: T) -> u32; } #[test] fn returning() { let _m = A_MTX.lock().unwrap(); l...
true
9e75a63c625727c85d5245fec25cbd7a714984b1
Rust
nthnptt/Learn-Rust
/Section 13/gen.rs
UTF-8
1,074
3.796875
4
[]
no_license
use std::cmp::Ordering; // from documentation #[derive(Debug, Copy, Clone)] struct Integer { number: u32, } // from documentation impl PartialOrd for Integer { fn partial_cmp(&self, other: &Self) -> Option<Ordering> { self.number.partial_cmp(&other.number) } } // from documentation impl PartialEq f...
true
319a43744192a16e762d155fc0faacadf189f2ec
Rust
janhrastnik/adventofcode
/aoc2022/src/day7.rs
UTF-8
4,375
2.8125
3
[]
no_license
use crate::shared::files; use std::collections::HashMap; pub fn solve() { part_one(); part_two(); } fn part_one() { if let Ok(lines) = files::shared::read_lines("./input/day7.txt") { let mut pc: HashMap<String, usize> = HashMap::new(); pc.insert("".to_string(), 0); let mut path: Ve...
true