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
6f9d6bd362b1afa523e7b15e5abef4eea9765e41
Rust
LinkTed/dbus-message-parser
/tests/message/encode.rs
UTF-8
2,165
2.625
3
[ "BSD-3-Clause" ]
permissive
use dbus_message_parser::message::Message; use dbus_message_parser::value::Value; use std::convert::TryInto; #[test] fn method_call() { let mut msg = Message::method_call( "destination.address".try_into().unwrap(), "/object/path".try_into().unwrap(), "interface.name".try_into().unwrap(), ...
true
7406742e860be7aecd50e78ac3df0c2ce482036c
Rust
stormasm/hn-api-examples
/examples/top_n_items.rs
UTF-8
2,245
3.046875
3
[ "MIT" ]
permissive
use hn_api::types::Item; use hn_api::HnClient; fn process_items(api: &HnClient, item_ids: Vec<u32>) { for item_id in item_ids { let item_json = api.get_json(item_id).unwrap(); match item_json.as_ref() { "null" => println!("{} null", item_id), _ => { let item:...
true
4573b4f1b2da4ada8bcd5b8955d67fcdef47330d
Rust
jdkaplan/advent-of-code
/2022/src/bin/day10.rs
UTF-8
1,667
3.25
3
[]
no_license
const INPUT: &str = include_str!("../../input/day10.txt"); fn main() { let instructions = parse(INPUT); let mut crt = Crt::new(); for i in instructions { crt.run(i); } println!("Part 1: {}", crt.strength); println!("{}", crt.image); } #[derive(Debug, Copy, Clone)] enum Instruction {...
true
0ef48b3692cf3e216f9abaa0ff92b4048855aeaf
Rust
carlossless/yargb
/src/cpu/stack.rs
UTF-8
2,528
2.84375
3
[]
no_license
use cpu::CPU; use registers::Flag::{ Z, C }; impl CPU { pub fn stack_ret_nz(&mut self) -> usize { if !self.regs.get_flag(Z) { self.regs.pc = self.stack_pop(); return 5 } 2 } pub fn stack_ret_nc(&mut self) -> usize { if !self.regs.get_flag(C) { ...
true
58524032b1bd4ea0ef0ec44fd9219605072f473f
Rust
afkim14/Universal-Canvas
/server/src/responder.rs
UTF-8
1,715
2.71875
3
[]
no_license
//! Contains implementation for responding to client requests. extern crate sharing_is_caring; use self::sharing_is_caring::*; use canvas::{Canvas, Pixel}; // REQUEST CONSTANTS /// The expected key when clients ask for the entire board initially. const RETRIEVE_BOARD :&str = "RETRIEVE_BOARD"; const TITLE_KEY: &str ...
true
2a8f0547e5d25253add0d588b2236363bf099ec0
Rust
fabianschuiki/moore
/src/svlog/lib.rs
UTF-8
9,108
2.546875
3
[ "Apache-2.0", "MIT" ]
permissive
// Copyright (c) 2016-2021 Fabian Schuiki //! The SystemVerilog implementation of the moore compiler. //! //! This crate implements a query-based compiler for the SystemVerilog language. //! It strives to be a complete implementation of IEEE 1800-2017, mapping any //! input source text to the equivalent LLHD code. //!...
true
cb0ea7b44a6e03397a22d3791a3fa4936f087e92
Rust
tocklime/aoc-2019-rs
/src/utils/iter.rs
UTF-8
171
2.828125
3
[]
no_license
pub fn all_ix_pairs(arr_len: usize) -> impl Iterator<Item = (usize, usize)> { (0..arr_len - 1).flat_map(move |ix1| (ix1 + 1..arr_len).map(move |ix2| (ix1, ix2))) }
true
704a98adbf97ccc48c584890379b46ea239eff81
Rust
hannobraun/vndf-2016
/source/rust/vndf/src/client/graphics/renderer.rs
UTF-8
2,751
2.75
3
[ "CC0-1.0" ]
permissive
use client::console::Console; use client::graphics::SHIP_SIZE; use client::graphics::frame_state::FrameState; use client::graphics::draw::{ ConsoleDrawer, ShipDrawer, PlanetDrawer, GridDrawer, PathDrawer, }; use client::graphics::camera::{Camera}; use client::interface::Frame; use client::window::Wi...
true
0e23464163adbe5cbe251e9f0dd6183bd13febf0
Rust
exterm/rust-experiments
/structs.rs
UTF-8
2,235
4.09375
4
[ "MIT" ]
permissive
#[derive(Debug)] struct Person<'a> { name: &'a str, age: u8, } // A unit struct struct Nil; // A tuple struct struct Pair(i32, f32); // A struct with two fields #[derive(Debug)] struct Point { x: f32, y: f32, } // Structs can be reused as fields of another struct #[derive(Debug)] struct Rectangle { ...
true
712a7a0531a861ff71bfd84357bd1f403f78c820
Rust
rsbisho2/rust-checkers
/src/renderer.rs
UTF-8
2,764
3.15625
3
[]
no_license
extern crate termion; pub mod renderer { use termion::{color, style,raw::IntoRawMode}; use std::io::{Write, stdout}; use crate::Game; pub struct Renderer{ playable_square : char, unplayable_square: char, white_piece: char, unwhite_piece: char, origin_x: u16, origin_y: u16, ...
true
5b3abe8ff2d9f009c6f312c646b490c11c35aa16
Rust
yanchith/rusterizer
/examples/loader.rs
UTF-8
3,533
2.84375
3
[ "MIT" ]
permissive
use std::error::Error; use std::fs::{self, File}; use std::io::BufReader; use glam::{Vec2, Vec3, Vec4}; use image::{self, imageops, ImageFormat}; use rusterizer::image::Image; use wavefront_obj::obj::{self, ObjSet, Object, Primitive}; use crate::attr::Attribute; pub fn load_image(path: &str) -> Result<Image, Box<dyn...
true
e6f16a5fba8e0d979f2dacc4d0ad7691e430757e
Rust
sbstp/merovingian_legacy
/src/main.rs
UTF-8
2,409
2.53125
3
[]
no_license
#![feature(nll)] #![feature(conservative_impl_trait)] #![feature(universal_impl_trait)] #[macro_use] extern crate lazy_static; #[macro_use] extern crate maplit; extern crate reqwest; extern crate serde; #[macro_use] extern crate serde_derive; extern crate serde_json; extern crate sha2; extern crate slab; #[macro_use] ...
true
2f82ab8d916fb4f95b00d6bec6c9640c6b615325
Rust
falconre/raptor
/lib/analysis/ksets/kset_value.rs
UTF-8
10,335
3.359375
3
[]
no_license
use crate::error::*; use crate::ir; use std::cmp::Ordering; use std::collections::BTreeSet; use std::fmt; #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub enum KSetValue { Top(usize), Value(BTreeSet<ir::Constant>), Bottom(usize), } impl KSetValue { pub fn value(&self) -> Option<&BTreeSet<ir::Constant>...
true
ca430c3c433f0de936327d444347c0c4ed83f203
Rust
ibutra/aoc20
/src/day3.rs
UTF-8
1,224
3.359375
3
[]
no_license
use crate::common::read_file_lines; pub fn part1() { let count = calculate_trees_on_slope(3, 1); println!("Trees on route: {}", count); } pub fn part2() { let slopes = vec![(1, 1), (3, 1), (5, 1), (7, 1), (1, 2)]; let mut product : i64 = 1; for (x, y) in slopes { let count : i64 = calculat...
true
49c29190f0740d13ac9dd6631a74438de3f16edc
Rust
matago/adventofcode-2020
/src/days/day02.rs
UTF-8
2,115
3.015625
3
[]
no_license
use futures::stream::StreamExt; use recap::Recap; use serde::Deserialize; use tokio::io::AsyncBufReadExt; use tokio::{fs::File, io::BufReader}; use crate::days::utils::Part; const FILEPATH: &str = "./input/day02.txt"; #[derive(Debug, Deserialize, Recap)] #[recap(regex = r#"(?x) (?P<min>\d+) - (?P<max>\d+)...
true
4f709965e03c7d5b54ea0ce86b7f13f6a08f3558
Rust
analog-hors/game-util-rs
/src/desktop/sound.rs
UTF-8
1,580
2.546875
3
[ "MIT" ]
permissive
use std::fs::File; use std::io::BufReader; use std::sync::mpsc::channel; use futures::channel::mpsc::UnboundedReceiver; use futures::StreamExt; use rodio::source::Buffered; use rodio::{Decoder, OutputStream, Sink, Source}; use crate::sound::SoundCommand; pub(crate) type InternalSound = Buffered<Decoder<BufReader<Fil...
true
d71b39ae9b8319d4b9f31c16fea15298494bb776
Rust
CAD97/tinyc
/crates/parser/src/token_set.rs
UTF-8
1,620
3.1875
3
[]
no_license
use { crate::TokenKind, std::{ iter::FromIterator, ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign}, }, }; #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub(crate) struct TokenSet(u128); impl TokenSet { pub(crate) const EMPTY: TokenSet = TokenSet(0); pub(crate) fn new(kind: To...
true
6a76e2d428093444def898846782cdfd076f66aa
Rust
dat2/cryptopals-rust
/src/set3.rs
UTF-8
13,385
2.53125
3
[ "MIT" ]
permissive
use std::collections::VecDeque; use std::time::{SystemTime, UNIX_EPOCH}; use std::{u8, u16}; use rand::{self, Rng}; use rand::distributions::{IndependentSample, Range}; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use errors::*; use prelude::*; use set1::{decrypt_single_byte_xor_cipher, break_repeating_...
true
588d0a277aeb9d3177a77999a37faeb46462179e
Rust
teo8192/stupid-mips-assembler
/src/ma.rs
UTF-8
14,136
3
3
[]
no_license
extern crate regex; use regex::Regex; use std::collections::HashMap; use std::error::Error; use std::fs; use std::str::FromStr; #[derive(Debug, Clone)] enum Ins { J, Beq, Bne, Lui, Slt, Lw, Sw, Add, Addu, Addi, Addiu, Sub, Subu, And, Or, Nor, Break, ...
true
22f6a191ce15c9c2ddb0dcdbe4579f67ecf0e7cd
Rust
jcpince/algorithms
/leetcode/maximum-product-subarray.rs
UTF-8
3,643
2.96875
3
[ "MIT" ]
permissive
extern crate json; use algo_tools::load_json_tests; struct Solution; struct SolutionHelper { res : i32, current : i32, prod_neg : i32, idx : usize, first_neg_idx : usize, } impl SolutionHelper { pub fn new() -> SolutionHelper { SolutionHelper { res : 0, curren...
true
86be5d4d4d0ced9d1707773840e4106182681377
Rust
Garfield-Chen/pelite
/src/resources/version_info.rs
UTF-8
14,752
3
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
/*! Version Information. See [Microsoft's documentation](https://docs.microsoft.com/en-us/windows/desktop/menurc/version-information) for more information. */ use std::{char, cmp, fmt, mem, slice}; use std::collections::HashMap; use crate::image::VS_FIXEDFILEINFO; use crate::{Error, Result, _Pod as Pod}; use crate:...
true
3cd7c7e766c6b4b3f2df2fc832994ed80b538095
Rust
Byron/and-rs
/src/lib/src/scaffolding/gen.rs
UTF-8
3,198
2.796875
3
[]
no_license
use quick_error::ResultExt; use regex::{Captures, Regex}; use std::path::Path; use std::io::Write; use std::fs::{File, create_dir_all}; use super::super::Context; use super::error::{PathToWriteTo, Error}; const SUBTITUTION_KEY: &'static str = r#"\$\{(\w+)\}"#; fn dotted_package_name_to_package_path(name: &str) -> St...
true
3253a2725a8ff6304653009a709c84dba21f815a
Rust
tbre90/fta
/src/main.rs
UTF-8
553
2.546875
3
[ "Unlicense" ]
permissive
use fta::Converter; fn main() { let args: Vec<String> = std::env::args().collect(); if args.len() != 2 { println!("Usage: fta <name of inputfile>"); return; } let maybecnv = Converter::new(args[1].clone()); let cnv = match maybecnv { Ok(t) => t, Err(err) => { ...
true
5498e5601a98076666f62618ddbcc407e52a07cc
Rust
mesalock-linux/crates-io
/vendor/object/src/write/elf.rs
UTF-8
53,587
2.5625
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use std::mem; use std::vec::Vec; use crate::elf; use crate::endian::*; use crate::pod::{bytes_of, BytesMut, WritableBuffer}; use crate::write::string::*; use crate::write::util::*; use crate::write::*; use crate::AddressSize; #[derive(Default, Clone, Copy)] struct ComdatOffsets { offset: usize, str_id: Option...
true
7a9e74345626424fafef3e41eb70ff6db34250d0
Rust
openshift/cincinnati
/cincinnati/src/plugins/internal/edge_add_remove.rs
UTF-8
33,455
2.734375
3
[ "Apache-2.0" ]
permissive
//! This plugin adds and removes Edges from Nodes based on metadata labels. use crate as cincinnati; use crate::conditional_edges::{ConditionalEdge, ConditionalUpdateEdge, ConditionalUpdateRisk}; use std::collections::HashMap; use self::cincinnati::plugins::prelude::*; use self::cincinnati::plugins::prelude_plugin_im...
true
a2fe92d3cfab8035287b275f8b9f016400915645
Rust
gnoliyil/fuchsia
/src/connectivity/wlan/lib/common/rust/src/security/wep.rs
UTF-8
6,246
2.796875
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. //! IEEE Std 802.11-2016 WEP descriptors and credentials. //! //! **WEP is insecure and support will be removed. This module is provided for legacy support...
true
8ad3dc9fdf16486d6f85067ff1ad83da7facef8d
Rust
aleksandrpak/algo
/src/data_structures/heap/fibonacci.rs
UTF-8
11,572
2.875
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
// Based on http://www.keithschwarz.com/interesting/code/?dir=fibonacci-heap use std::mem; use std::rc::Rc; use std::cell::{RefCell, Ref}; use std::cmp::Ordering; pub struct FibonacciHeap<T: PartialOrd> { size: usize, min: Link<T>, tree_table: Vec<Link<T>>, to_visit: Vec<Link<T>>, } struct Entry<T: P...
true
51ac0a302cbdaed75f4f0f408b46bef9825ec542
Rust
jbradberry/advent-of-code
/2020/day06-1/src/main.rs
UTF-8
532
3.171875
3
[]
no_license
use std::io; use std::io::prelude::*; fn read() -> Vec<Vec<String>> { let mut buffer = String::new(); io::stdin().read_to_string(&mut buffer).unwrap(); buffer.split("\n\n") .map(|g| g.lines().map(String::from).collect()) .collect() } fn main() { let answers = read(); let sum: u...
true
7edd2701d1c7d3f8da5a05ac963c8230fb8bc761
Rust
aguang-xyz/leetcode-rust
/src/solution/s0016_3sum_closest.rs
UTF-8
1,845
3.203125
3
[]
no_license
pub struct Solution; impl Solution { pub fn three_sum_closest(nums: Vec<i32>, target: i32) -> i32 { // Map nums from [-1000, 1000] to [0, 2000]. let nums: Vec<i32> = nums.into_iter().map(|num| num + 1000).collect(); let target = target + 3000; // f[i][j][k] indicates whether we hav...
true
60c4904f5057a2b3b30e143aa9531b6c434e4645
Rust
Krout0n/vecmat-rs
/src/vector/ops/base.rs
UTF-8
5,628
3
3
[ "MIT", "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{ traits::{NormL1, NormL2, NormLInf}, Vector, }; use core::{ cmp::PartialOrd, iter::IntoIterator, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Rem, RemAssign, Sub, SubAssign}, }; use num_traits::{Float, Zero}; impl<T, const N: usize> Neg for Vector<T, N> where T: Neg<Ou...
true
cecffaebb2ae5cf4866ce372a1f70d0ceb5a9bfe
Rust
mesalock-linux/crates-io
/vendor/raw-cpuid/examples/topology.rs
UTF-8
7,007
2.984375
3
[ "Apache-2.0", "Unlicense", "BSD-3-Clause", "0BSD", "MIT" ]
permissive
//! An example that uses CPUID to determine the system topology. //! //! Intel Topology is a pretty complicated subject (unfortunately): //! https://software.intel.com/en-us/articles/intel-64-architecture-processor-topology-enumeration/ extern crate core_affinity; extern crate raw_cpuid; use raw_cpuid::{CpuId, Extende...
true
297edc3f5f597f82314618a2c4298ce0afbfd653
Rust
toddself/truncate_string_at_whitespace
/src/lib.rs
UTF-8
2,449
3.609375
4
[ "Apache-2.0" ]
permissive
fn find_char_bytes_len(ch: &char) -> i32 { let mut b = [0; 4]; ch.encode_utf8(&mut b); let mut clen = 0; for a in b.iter() { clen += match a { 0 => 0, _ => 1, } } clen } pub fn truncate_text(text: &str, tlen: usize) -> &str { if text.len() <= tlen { ...
true
1b57cf04c4acbe2d4d41786f820ec6616a21c73c
Rust
BurntSushi/fst
/src/raw/node.rs
UTF-8
29,288
3
3
[ "MIT", "Unlicense" ]
permissive
use std::cmp; use std::fmt; use std::io; use std::ops::Range; use crate::bytes; use crate::raw::build::BuilderNode; use crate::raw::common_inputs::{COMMON_INPUTS, COMMON_INPUTS_INV}; use crate::raw::{ u64_to_usize, CompiledAddr, Output, Transition, EMPTY_ADDRESS, }; /// The threshold (in number of transitions) at...
true
d0b80ebb3361d2344e05079c27ae3ad338da0cad
Rust
oxidecomputer/target-gen
/src/chip_family.rs
UTF-8
1,024
3
3
[]
no_license
use crate::raw_flash_algorithm::RawFlashAlgorithm; use crate::Chip; use serde::{Deserialize, Serialize}; use std::collections::HashMap; /// This describes a chip family with all its variants. #[derive(Debug, Clone, Serialize, Deserialize)] pub(crate) struct ChipFamily { /// This is the name of the chip family in b...
true
b30df6fdbd0e3adb2628dca255c5d725ad934d1c
Rust
underoot/thebook
/temperature/src/main.rs
UTF-8
300
3.625
4
[]
no_license
fn main() { println!("Value is {}", to_fahrenheit(-273.15)); } const CONVERT_FACTOR: f64 = (212.0 - 32.0) / 100.0; const ICE_POINT: f64 = 32.0; fn to_fahrenheit(deg: f64) -> f64 { deg * CONVERT_FACTOR + ICE_POINT } fn to_celsius(deg: f64) -> f64 { (deg - ICE_POINT) / CONVERT_FACTOR }
true
2c2855138d2245e3b8e179578d641b759c8096e4
Rust
shellforge/rs-sudoku-bruteforce
/brute_solver_lib/src/puzzle_state.rs
UTF-8
3,125
3.34375
3
[]
no_license
#[derive(PartialEq, Debug, Clone)] pub struct Piece { pub established: bool, pub value: u64, } pub type Grid = Vec<Vec<Piece>>; #[derive(Debug, Clone, Default)] pub struct PuzzleState { pub grid: Grid, pub row: usize, pub col: usize, } impl PuzzleState { pub fn with_values(input: serde_json::...
true
90f1cbcc0596ef8fdde02c2ae00d544cc2ae048b
Rust
ctm/v_escape
/v_shellescape/src/lib.rs
UTF-8
3,053
3.5
4
[ "MIT", "Apache-2.0" ]
permissive
//! # Quick start //! //! ```rust //! extern crate v_shellescape; //! use v_shellescape::{unix, windows}; //! //! print!("{}", unix::ShellEscape::from("linker=gcc -L/foo -Wl,bar")); //! print!("{}", windows::ShellEscape::from("linker=gcc -L/foo -Wl,bar")); //! ``` //! #[macro_use] extern crate v_escape; use std::env;...
true
72e271789f713877b0926c6b86f4231522de4bde
Rust
max-heller/rust-smt-ir
/amzn-smt-string-fct-updater/src/transpiler.rs
UTF-8
8,098
2.71875
3
[ "MIT", "Apache-2.0" ]
permissive
//! Module with functionality for modernizing some string functions in SMTLIB. //! This updates the notation from an older version of the SMTLIB language, to //! the modern syntax compatible with CVC5. // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 use amzn...
true
3b6b2db1461a1f45327cdfd8b11ddca1ad505cb3
Rust
risboo6909/aoc2020
/problems/src/problem1/mod.rs
UTF-8
1,437
3.09375
3
[ "MIT" ]
permissive
use std::collections::HashSet; use failure::{format_err, Error}; use utils::{result, split_by_lines, ProblemResult, RetTypes}; const YEAR: usize = 2020; fn find_pair_sum(input: &[usize], expected: usize, start_from: usize) -> Option<(usize, usize)> { let mut lookup: HashSet<usize> = HashSet::new(); for n in...
true
f55328cd996616a9a7d462f9c6b4954c2be071da
Rust
rust-chainblock/blockchain7
/crypto/digestible/test-utils/tests/sanity.rs
UTF-8
7,165
2.578125
3
[]
no_license
//! Test that our AST nodes are mapping to the append bytes calls that we //! expect. This is basically a test that the default implementations of //! `append_primitive` etc. in the DigestTranscript crate match the spec, and //! that nothing else went wrong wiring all this stuff up. use mc_crypto_digestible::DigestTran...
true
6326e0ecabb8b8658b7a70344c9b3b86d890d891
Rust
ho1messi/gomoku
/libs/backend/src/board.rs
UTF-8
5,442
2.921875
3
[]
no_license
use std::collections::HashMap; use super::cross_point::*; use super::utils::*; use self::MoveDirection::*; #[derive(Hash, Eq, PartialEq, Copy, Clone, Debug)] pub enum MoveDirection { MdUp, MdDown, MdLeft, MdRight, MdUpLeft, MdUpRight, MdDownLeft, MdDownRight, } #[derive(Eq, PartialEq...
true
62e3c21d855bbcb8d8d44f56c64b87d08718ed23
Rust
chromium/chromium
/third_party/rust/proc_macro2/v1/crate/tests/test_fmt.rs
UTF-8
1,312
2.640625
3
[ "Apache-2.0", "MIT", "LicenseRef-scancode-unknown-license-reference", "GPL-1.0-or-later", "LGPL-2.0-or-later", "BSD-3-Clause" ]
permissive
#![allow(clippy::from_iter_instead_of_collect)] use proc_macro2::{Delimiter, Group, Ident, Span, TokenStream, TokenTree}; use std::iter; #[test] fn test_fmt_group() { let ident = Ident::new("x", Span::call_site()); let inner = TokenStream::from_iter(iter::once(TokenTree::Ident(ident))); let parens_empty =...
true
15622bf731103f6d9b0c29e49af883d632612906
Rust
hoangpq/scooby
/src/postgres/general/expression.rs
UTF-8
2,199
3.3125
3
[]
no_license
use std::{ fmt::{self, Display, Formatter}, iter::{Copied, Map}, slice, }; use crate::tools::{IntoIteratorOfSameType, IntoNonZeroArray}; use super::{Alias, Column}; /// Expression and things that can be converted into one #[derive(Debug, Clone, Eq, PartialEq)] pub struct Expression(String); impl From<&s...
true
7c6ac9b111f386b6f858e535ce4911117747fb94
Rust
mgeisler/paper
/src/mode/edit.rs
UTF-8
2,058
3.203125
3
[ "MIT" ]
permissive
//! Implements functionality for the application while in edit mode. use super::{Initiation, Operation, Output, Pane, Position}; use crate::ui::ESC; use crate::Mrc; /// The [`Processor`] of the edit mode. #[derive(Debug)] pub(crate) struct Processor { /// The [`Pane`] of the application. pane: Mrc<Pane>, /...
true
e02ed49ebb4533bf33fd8019e1f3b865ce808a14
Rust
mpizenberg/wasm-png
/src/lib.rs
UTF-8
1,629
2.640625
3
[]
no_license
use png_decoder::png::{decode_no_check, decode_no_check_bis}; use std::io::Read; use wasm_bindgen::prelude::*; #[wasm_bindgen] pub struct WasmPng { file_buffer: Vec<u8>, } #[wasm_bindgen] pub struct ImgSize { pub width: usize, pub height: usize, } /// Public methods, exported to JavaScript. #[wasm_bindge...
true
e47a6ff6245aaa55f1f85670a8c5a30d95b0e9fb
Rust
suryapandian/rust
/examples/01.basics/014_bitwise.rs
UTF-8
697
3.28125
3
[]
no_license
fn main(){ let value = 0b11110011u8; println!("this is the int value of the binary {}", value); println!("value with 8 bit precision in case of binary {:8b}",value); println!(" the not operator ! of value {:8b} is {:8b}", value, !value); println!("bitwise and & of {:8b} & {:8b} is {:8b}", value, !value , value &...
true
335e8b069d81f45b263455910aaa8f33ec266638
Rust
ejmg/rsass
/tests/spec/core_functions/selector/mod.rs
UTF-8
21,249
2.59375
3
[ "Apache-2.0", "MIT" ]
permissive
//! Tests auto-converted from "sass-spec/spec/core_functions/selector" #[allow(unused)] use super::rsass; // From "sass-spec/spec/core_functions/selector/append.hrx" mod append { #[allow(unused)] use super::rsass; mod classes { #[allow(unused)] use super::rsass; #[test] fn d...
true
44dc05f783e685b9c871c0a06317dc079abb376e
Rust
digitlimit/cargo-user-app
/src/main.rs
UTF-8
539
2.953125
3
[]
no_license
// This declaration will look for a file named `app.rs` or `app/mod.rs` and will // insert its contents inside a module named `my` under this scope mod app; use app::models::user::User; use app::models::profile::Profile; fn main() { let user: User = User::new( 1, "frankemeks77@yahoo.com" ); ...
true
e6aa9931cb28a5ed0a1a7af1abdc20ab077cb133
Rust
YoshikawaMasashi/toid
/src/data/music_info/chord_progression.rs
UTF-8
1,511
3.125
3
[]
no_license
use std::collections::BTreeMap; use std::ops::Bound::{Included, Unbounded}; use serde::{Deserialize, Serialize}; use super::{Beat, Chord}; #[derive(Serialize, Deserialize, Clone, Debug)] pub struct ChordProgression { chords: BTreeMap<Beat, Chord>, pub length: Beat, } impl ChordProgression { pub fn new()...
true
9d4e4b463526adfc4a39dbaa9c21e98ec0674bc1
Rust
samhwang/spongetext
/rust/src/spongify.rs
UTF-8
940
3.640625
4
[]
no_license
use rand::prelude::*; fn spongify(input: String) -> String { let input_string = input.trim().to_lowercase(); let mut output = String::from(""); for character in input_string.chars() { if (rand::random()) { output.push(character.to_ascii_uppercase()); } else { output....
true
e8d97f73195b081a0ef2ca33ebe3dfc8b817f141
Rust
chris-morgan/abandoned-partially-complete-harfbuzz-api-port-to-idiomatic-rust
/util.rs
UTF-8
355
2.640625
3
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "Apache-2.0" ]
permissive
// Scale seems to have this weird 16.16 arrangement. TODO find out more about it. #[repr(C)] struct Fixed(i32); impl From<f64> for Fixed { fn from(f: f64) -> Fixed { Fixed(((1i32 << 16) as f64 * f) as i32) } } impl From<Fixed> for f64 { fn from(fixed: Fixed) -> f64 { fixed.0 as f64 * 1.0f...
true
51eaac01b9e8317cea1239f2e62986f7dc35a855
Rust
monkeylyf/interviewjam
/str/leetcode_longest_palindrome.rs
UTF-8
1,218
3.6875
4
[]
no_license
/** * Given a string which consists of lowercase or uppercase letters, find the * length of the longest palindromes that can be built with those letters. * * This is case sensitive, for example "Aa" is not considered a palindrome here. * * Note: * Assume the length of given string will not exceed 1,010. * * Ex...
true
a6ae459208198b428369a6936af84f7911b98ce0
Rust
Hoffs/zoomzoom
/word_break/src/lib.rs
UTF-8
4,392
3.890625
4
[]
no_license
pub fn word_break(s: String, word_dict: Vec<String>) -> bool { let mut words = std::collections::HashMap::new(); for x in word_dict { words.insert(x, 0 as i8); } // create vec for storing found words // [t, f, f, f, ,f], where len = string+1, 0 marks the start and is always true // when...
true
2c7f3b7ced8ce58e8ade8c6a0ce5b4edc096b1a0
Rust
jlgerber/rustyRabbitEgs
/5-topics/rust/topic/src/location.rs
UTF-8
406
2.875
3
[]
no_license
use strum::{EnumString, AsRefStr}; /// A studio location #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, EnumString, AsRefStr)] pub enum Location { #[strum(serialize="playa", serialize="dd")] Playa, #[strum(serialize="vancouver", serialize="bc")] Vancouver, #[strum(serialize="portland", serialize="...
true
62fcc2fbea6fd868cea915d879024b9c476da17c
Rust
dremonkey/lodestone-linestring
/src/lib.rs
UTF-8
3,732
3.265625
3
[]
no_license
/// The main crate for lodestone-linestring /// /// ## Overview /// /// Takes coordinates and returns a new LineString GeoJson feature. /// Inspired by [turf-linestring](https://github.com/Turfjs/turf-linestring). // Standard lib crates use std::str::FromStr; // Third party crates extern crate geojson; extern crate ...
true
72749b773235d436d2b4f541ed8cad37f3cdf058
Rust
enso-org/enso
/lib/rust/prelude/src/rc.rs
UTF-8
982
3.171875
3
[ "AGPL-3.0-only", "Apache-2.0", "AGPL-3.0-or-later" ]
permissive
//! This module defines utilities for working with the `Rc` and `Weak` types. use super::option::*; use std::rc::Rc; use std::rc::Weak; // TODO[WD,AO]: Think about merging it with `OptionOps`. /// Mapping methods to the `Weak` type. pub trait WeakOps { type Target; fn for_each<U, F>(self, f: F) where F...
true
7c7bc4a22479e6a9e5dc56acf928342c461ac1be
Rust
pnnl/lamellar-runtime
/src/array/iterator/local_iterator/map.rs
UTF-8
1,289
2.984375
3
[ "BSD-3-Clause" ]
permissive
use crate::array::iterator::local_iterator::*; #[derive(Clone, Debug)] pub struct Map<I, F> { iter: I, f: F, } impl<I, F> Map<I, F> where I: IndexedLocalIterator, { pub(crate) fn new(iter: I, f: F) -> Map<I, F> { Map { iter, f } } } impl<B, I, F> LocalIterator for Map<I, F> where I: In...
true
d156816f2e0d450d40510405e63d97eda06a12fd
Rust
Autumn-Fox/rust-guessing-game
/src/main.rs
UTF-8
1,522
3.78125
4
[]
no_license
fn main() { println!("Think of a number between 1 and 100"); let answer = recursive_guess(1, 100); println! ("Your answer is {}.", answer); } fn recursive_guess(min:i32, max:i32) -> i32 { let difference = max - min; let guess = get_input(min, max); if difference <= 1 { if guess == "Y"....
true
94792bc47a0aed9ee3f8c2de17d367aece26a478
Rust
gcfbn/learning_rust
/graphs/algorithms/src/kruskal.rs
UTF-8
2,902
3.40625
3
[]
no_license
use graph::Graph; use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct UnionFind { parent: Vec<u32>, rank: Vec<u8>, } impl UnionFind { /// n - count of disjoint sets. pub fn new(n: u32) -> Self { let rank = vec![0; (n + 1) as usize]; let mut parent = Vec::with_capacity(n as usi...
true
c273959771416fad0f00b2d7457b323aad35ff98
Rust
o2sh/onefetch
/build.rs
UTF-8
2,473
3.03125
3
[ "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use lazy_static::lazy_static; use regex::Regex; use std::collections::HashMap; use std::env; use std::error::Error; use std::fs::{self, File}; use std::path::Path; use tera::{Context, Tera}; fn main() -> Result<(), Box<dyn Error>> { #[cfg(windows)] { let mut res = winres::WindowsResource::new(); ...
true
988f432387439ddadb68ab3978bb70bee332c725
Rust
donaldducky/advent-of-code
/2019/day14/src/main.rs
UTF-8
9,259
3.3125
3
[]
no_license
use itertools::Itertools; use std::collections::HashMap; use std::fmt; use std::fs; #[derive(Debug, Eq, PartialEq, Hash, Clone)] struct Chemical { id: String, quantity: u64, } #[derive(Debug, Eq, PartialEq, Hash, Clone)] struct Reaction { input_chemicals: Vec<Chemical>, output_chemical: Chemical, } i...
true
4d51c3f8c7c50ca5de9bfed2449c20bcdf3c8c58
Rust
LoungeCPP/pir-8-emu
/tests/vm/ports/ports/install_handler/err.rs
UTF-8
1,499
3.015625
3
[ "MIT" ]
permissive
use pir_8_emu::vm::{PortHandlerInstallError, PortHandler, Ports}; use std::num::NonZeroU8; static PORTS: &[u8] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; #[derive(Debug, PartialEq, Eq)] struct Handler(u8); impl PortHandler for Handler { fn port_count(&self) -> NonZeroU8 { NonZeroU8::new(self.0).unwrap() } ...
true
60a8bc108040d82e7701fbaeecf32f11136278a2
Rust
muni-corn/sparrow
/src/bin/sparrowd.rs
UTF-8
7,192
2.78125
3
[]
no_license
//! Runs a daemon that periodically checks for the next event in the user's PomodoroSchedule, notifying //! them with libnotify before and once an event starts. use clap::{App, Arg}; use notify::Watcher; use sparrow::{ methods::pomodoro::{PomodoroSchedule, PomodoroScheduleEntry}, SparrowError, UserData, }; use...
true
1c293a43291cac1b10b0f63ed220544f4110df7a
Rust
kkress/adventofcode-2015
/15/src/main.rs
UTF-8
4,429
3
3
[ "MIT" ]
permissive
use std::cmp::max; use std::fs::File; use std::io::prelude::*; use std::io::BufReader; #[derive(Debug)] struct Cookie { total_capacity: i32, ingredients: Vec<Ingredient>, } impl Cookie { fn new(capacity: i32, ingredients: Vec<Ingredient>) -> Cookie { Cookie { total_capacity: capacity, ...
true
bb1eb6c91b9d07b6e5d2dc0bd1b3ca5627a3da3f
Rust
mishajw/incredi-panel
/src/window/config.rs
UTF-8
1,585
2.765625
3
[]
no_license
use crate::anchor::Anchor; use crate::config; use crate::error::*; use std::rc::Rc; use std::time::Duration; use sfml::graphics::Font; /// Configuration for a window #[allow(missing_docs)] pub struct Config { pub grid_width: u32, pub grid_height: u32, pub grid_size: u32, pub font: Rc<Font>, pub f...
true
b214ecba61462f5a95307b918d45c18b08ad5a46
Rust
pluie-org/ykre
/src/ykre/echo.rs
UTF-8
3,361
2.640625
3
[ "MIT" ]
permissive
use crate::ykre::*; use colored::*; use std::borrow::Cow; pub fn title(label :&str, version :&str, license: &str, author :&str) { let space = 42+version.len()+label.len()+license.len()+author.len(); let sep = format!("{}", CSEP.fg(&"―".repeat(WIDTH+1))); let titlesep = CTITLESEP.fg(" :: "); ...
true
ff0d0a84ec488f4fa2de28b4c885a14fee883d9c
Rust
bgoldbeck/rustecs
/src/ecsystem/blackboard.rs
UTF-8
1,081
2.984375
3
[ "MIT" ]
permissive
use std::collections::HashMap; use std::cell::RefCell; use std::cell::Ref; use std::rc::Rc; use std::any::*; pub trait IBObject { fn to_value<T: 'static>(&self) -> Option<&T>; } #[derive(Debug)] pub enum BlackboardObject { Doodle { object: (Box<Any>), }, } impl<'a> IBObject for BlackboardObject...
true
03418e709e6616a281302367059dc982441efdba
Rust
XOSplicer/advent-of-code-2019
/src/24-1.rs
UTF-8
6,685
3.140625
3
[]
no_license
use anyhow::Result as AnyResult; use std::collections::HashSet; use std::fmt; use std::fs; use std::str::FromStr; use thiserror::Error; #[derive(Debug, Error)] enum MyError { #[error("Bad input`{0}`")] BadInput(String), #[error("Bad layout")] BadLayout, } #[derive(Debug, Clone, PartialEq, Eq, Hash)] e...
true
eebd0979ea1a286fe8fc362828d6ba4af371d644
Rust
bestouff/tui-rs
/examples/gauge.rs
UTF-8
4,115
2.84375
3
[ "MIT" ]
permissive
extern crate termion; extern crate tui; use std::io; use std::thread; use std::time; use std::sync::mpsc; use termion::event; use termion::input::TermRead; use tui::Terminal; use tui::backend::MouseBackend; use tui::widgets::{Block, Borders, Gauge, Widget}; use tui::layout::{Direction, Group, Rect, Size}; use tui::s...
true
0f4606acc75e9033fc3c8182507cf45a524e1a6a
Rust
gifnksm/ProjectEulerRust
/src/bin/p018.rs
UTF-8
1,499
3.15625
3
[ "MIT" ]
permissive
//! [Problem 18](https://projecteuler.net/problem=18) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use std::{cmp, num::ParseIntError}; const TRIANGLE: &str = " 75 95 64 17 47 82 18 35 87 10 20 04 82 47 65 19 01 23 75 ...
true
55c92aaa4957ddb8415174caf6e8d322a39cda64
Rust
CBenoit/nushell
/crates/nu-command/src/filters/reverse.rs
UTF-8
1,730
2.796875
3
[ "MIT" ]
permissive
use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Value, }; #[derive(Clone)] pub struct Reverse; impl Command for Reverse { fn name(&self) -> &str { "re...
true
346e2336c4f58103e4917870a1e5bdf71c3ee23d
Rust
jlgerber/packybara-grpc
/src/client_service/levels.rs
UTF-8
6,956
3.046875
3
[]
no_license
//! `levels` module exports the `get_levels::Options` struct which provides query //! parameters for the `ClientService.get_levels` method, and the `add_levels::Options` //! struct which provides parameters for the `ClientServer.add_levels` method. use super::*; /// Provides `Options` for the `ClientService.get_levels...
true
61963dbd1b0f552bc161c88b417b6fd29d451689
Rust
monsieurbadia/qoeur-llvm
/compiler/prog/qoeurcp_span/src/span.rs
UTF-8
963
3.171875
3
[ "MIT" ]
permissive
use super::loc::Loc; use std::cmp::{max, min}; use std::fmt; #[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] pub struct Span { pub start: Loc, pub end: Loc, } // TODO: remove me from impl Default for Span { fn default() -> Span { Self::from_start(Loc::zero()) } } impl fmt::Display f...
true
c9f36bdc3a8077afa4952a16c7c346f2cfcfb354
Rust
DrSensor/scdlang
/packages/core/src/core/builder.rs
UTF-8
2,296
3
3
[ "UPL-1.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::{cache, error::Error, external::Builder}; use pest_derive::Parser; #[derive(Parser, Default, Clone)] // 🤔 is it wise to derive from Copy&Clone ? #[grammar = "grammar.pest"] /** __Core__ parser and also [`Builder`]. # Examples ```ignore use scdlang::semantics::Kind; let mut parser = Scdlang::new(); parser...
true
41141e4480599d79b600d3cedf7277a5e216c0ca
Rust
teloxide/teloxide
/crates/teloxide/src/dispatching/dialogue/storage/in_mem_storage.rs
UTF-8
1,956
2.96875
3
[ "MIT" ]
permissive
use super::Storage; use futures::future::BoxFuture; use std::{collections::HashMap, sync::Arc}; use teloxide_core::types::ChatId; use thiserror::Error; use tokio::sync::Mutex; /// An error returned from [`InMemStorage`]. #[derive(Debug, Error)] pub enum InMemStorageError { /// Returned from [`InMemStorage::remove_...
true
81442b9469ee88088ab00ca776e8c0db86497f0f
Rust
cronokirby/chika
/src/errors.rs
UTF-8
634
2.53125
3
[ "MIT" ]
permissive
use crate::codespan_reporting::files; use std::{fmt, io}; #[derive(Debug)] pub enum Error { IO(io::Error), } impl From<files::Error> for Error { fn from(error: files::Error) -> Self { match error { files::Error::Io(e) => e.into(), other => panic!("Compiler Bug:\n{}", other), ...
true
50d6b1717d1c4e82e25d9e6264518292b85ee4e9
Rust
CarloMicieli/trenako
/crates/server/src/web/queries.rs
UTF-8
4,458
2.796875
3
[ "Apache-2.0" ]
permissive
use crate::web::problem::ProblemDetail; use crate::web::responders::ToProblemDetail; use common::queries::errors::QueryError; use uuid::Uuid; impl ToProblemDetail for QueryError { fn to_problem_detail(self, request_id: Uuid, path: Option<&str>) -> ProblemDetail { match self { QueryError::Conver...
true
0657c3282bc8b842588777776452a3532e851ab2
Rust
racklet/kicad-rs
/kicad-rs/src/error.rs
UTF-8
620
3.359375
3
[ "Apache-2.0" ]
permissive
use std::error::Error; use std::fmt; // A result that can carry any Error implementation pub type DynamicResult<T> = Result<T, Box<dyn Error>>; // A struct implementing the Error trait, carrying just a simple message #[derive(Debug)] pub struct StringError { str: String, } pub fn errorf(s: &str) -> Box<dyn Error...
true
bd89f04503647d774e6e625b7f68e72eb23385d4
Rust
gelfand/etk
/etk-dasm/src/blocks/annotated.rs
UTF-8
38,851
3.34375
3
[ "MIT", "Apache-2.0" ]
permissive
//! Representation of EVM instruction blocks as expressions applied to inputs //! (ie. stack/memory/storage). use crate::sym::{Expr, Var}; use etk_asm::ops::{ConcreteOp, Metadata}; use std::collections::VecDeque; use super::BasicBlock; /// Possible ways for an [`AnnotatedBlock`] to exit. #[derive(Debug, Clone)] pub...
true
60329472d658b33d78529d1f9447ed3e0ee53e2e
Rust
Anders429/shield
/src/components/sprite.rs
UTF-8
2,900
3.140625
3
[]
no_license
use num_enum::UnsafeFromPrimitive; use std::mem; #[derive(UnsafeFromPrimitive)] #[repr(u8)] pub(crate) enum Pixel { Transparent = 0, Color_A = 1, Color_B = 2, Color_C = 3, } #[derive(Clone, Copy, Default, Eq, Hash, PartialEq)] pub struct Color { pub(crate) red: u8, pub(crate) green: u8, pu...
true
62dc8644e63000c0db1a883cdea1a90f0d7c3189
Rust
netvipec/AoC2017
/Rust/day13/src/main.rs
UTF-8
1,739
3.3125
3
[]
no_license
use std::io::{self, BufRead}; type InputT = Vec<(usize, usize)>; type OutputT = usize; fn read_input() -> InputT { let stdin = io::stdin(); let input: InputT = stdin .lock() .lines() .map(|x| { let line = x.unwrap(); let mut p = line.split(": "); let...
true
78478a4c77684aab1bcebce442a3d089019a0b40
Rust
katandps/beatoraja_play_recommend
/crates/send_slack/src/config.rs
UTF-8
591
2.515625
3
[ "MIT" ]
permissive
use serde::Deserialize; #[derive(Clone, Debug, Deserialize)] pub struct Cfg { #[serde(default = "slack_bot_token")] pub slack_bot_token: String, #[serde(default = "slack_channel")] pub slack_channel: String, #[serde(default = "slack_file_name")] pub slack_file_name: String, } fn slack_bot_toke...
true
c86bf169882326f7dc10ad37f88eb4f5455d38ae
Rust
nshou/test_deps
/src/lib.rs
UTF-8
3,959
2.8125
3
[ "MIT" ]
permissive
//! `test_deps` allows developers to define dependencies among tests. use lazy_static::lazy_static; use std::collections::HashMap; use std::sync::{Arc, Condvar, Mutex, PoisonError}; pub use test_deps_if::deps; lazy_static! { static ref TEST_DEPS_REG: Mutex<(HashMap<String, ()>, HashMap<String, Vec<Arc<Condvar>>>)...
true
32cb88dc524032a2152ec03b19dc8772101ec7a4
Rust
Dmitri9149/Rust_Tokenizers
/examples/ulysses.rs
UTF-8
9,286
2.5625
3
[ "MIT" ]
permissive
// the BPE tokenizer is composed here from modules use bpe::pairs::Pairs; use bpe::TextStage; use bpe::VocabStage; use bpe::vector_of_words::WordsVector; use bpe::vocab_of_tokens::{VocabOfTokens, OrderedSetOfTokens}; use bpe::tokenize_bpe_word::tokenize_word; use bpe::string_processing::prepare_for_tokenization_3; use ...
true
21ce0d3d1e58e20efc31153140a96e6fd1213e1e
Rust
nervosnetwork/ckb
/test/src/util/log_monitor.rs
UTF-8
1,464
2.75
3
[ "MIT" ]
permissive
use crate::node::Node; use crate::utils::{sleep, tweaked_duration}; use std::fs::{metadata, File}; use std::io::{BufRead, BufReader, Seek, SeekFrom}; use std::time::Instant; pub fn monitor_log_until_expected_show( node: &Node, seek_from: u64, timeout: u64, expected: &str, ) -> Option<String> { let ...
true
7e46f369f45bce15bec12f6aaaf733babc1910be
Rust
lubaozhen/swc
/crates/swc_css_parser/src/parser/style_rule.rs
UTF-8
7,135
2.671875
3
[ "MIT", "Apache-2.0" ]
permissive
use super::{input::ParserInput, PResult, Parser}; use crate::{ error::{Error, ErrorKind}, parser::{Ctx, RuleContext}, Parse, }; use swc_common::Span; use swc_css_ast::*; impl<I> Parser<I> where I: ParserInput, { pub(crate) fn parse_rule_list(&mut self, ctx: RuleContext) -> PResult<Vec<Rule>> { ...
true
07ed0fea063c7026f2edace6cc807e995ed2ac45
Rust
tramulns/rust-cookbook
/web/clients/download/post-file/src/main.rs
UTF-8
631
2.859375
3
[]
no_license
/// Отправить POST-запросом файл в paste-rs use std::fs::File; use std::io::Read; type Error = Box<dyn std::error::Error>; type Result<T> = std::result::Result<T, Error>; #[tokio::main] async fn main() -> Result<()> { let paste_api = "https://paste.rs"; let mut file = File::open("message")?; let mut cont...
true
594f45fae57772a02b7058ef5eaf69d62403ef36
Rust
vtheuer/aoc-2020
/src/day16.rs
UTF-8
3,683
2.96875
3
[]
no_license
use crate::day::Day; use crate::util::split_pair; use fnv::FnvHashSet; use std::cell::Cell; pub struct Day16<'a> { constraints: Vec<(&'a str, (usize, usize), (usize, usize))>, my_ticket: Vec<usize>, other_tickets: Vec<Vec<usize>>, valid_tickets: Cell<Vec<usize>>, } fn parse_ticket(line: &str) -> Vec<u...
true
95290ece7198052e4d955cb66ff61ae3cb5d78d4
Rust
LeSeulArtichaut/twilight
/http/src/request/template/update_template.rs
UTF-8
4,935
3.25
3
[ "ISC" ]
permissive
use crate::{ client::Client, error::Error as HttpError, request::{validate, Pending, Request}, routing::Route, }; use serde::Serialize; use std::{ error::Error, fmt::{Display, Formatter, Result as FmtResult}, }; use twilight_model::{id::GuildId, template::Template}; /// Error emitted when the t...
true
8734ba7179e2986c9143c206e6ccb491817be51d
Rust
hisland/my-learn
/rust-programming-2/02-struct/14-multi-impl-block.rs
UTF-8
467
3.796875
4
[]
no_license
fn main() { let r1 = Rect { width: 12, height: 12, }; println!("area is: {}", r1.area()); let r2 = Rect::new(13, 13); println!("area is: {}", r2.area()); } struct Rect { width: u32, height: u32, } // 第一部分实现 impl Rect { fn area(&self) -> u32 { self.width * self....
true
2c0a3b641befb6eb59fcac149e884bc28bb7096f
Rust
fgadaleta/rust-dataframe
/src/table.rs
UTF-8
11,244
2.96875
3
[ "Apache-2.0" ]
permissive
use std::sync::Arc; use arrow::array::*; use arrow::datatypes::*; use arrow::record_batch::RecordBatch; use crate::error::*; #[derive(Clone)] pub struct ChunkedArray { chunks: Vec<Arc<dyn Array>>, num_rows: usize, null_count: usize, } impl ChunkedArray { /// Construct a `ChunkedArray` from a list of...
true
5fcd3ffea123784950db79ff9329ecd8037a8970
Rust
Masterchef365/iced_mpsc
/examples/button.rs
UTF-8
1,918
2.84375
3
[]
no_license
use iced::*; use iced_mpsc::Mpsc; fn main() { App::run(Default::default()) } struct App { clicky: button::State, n_clicks: usize, sender: Option<iced_mpsc::Sender<()>>, iced_mpsc: Mpsc<()>, } #[derive(Debug, Clone)] enum Message { Clicky, Mpsc(iced_mpsc::Message<()>), } impl Application ...
true
ecbb4cbd02e05c4be4b9de3a2897e8c2046c6c8c
Rust
wzhzzmzzy/ray-tracing-rust
/src/common/vec3_opts.rs
UTF-8
3,669
3.328125
3
[]
no_license
use std::ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign, Neg}; use crate::common::vec3::Vec3; use crate::one_week::random_f64; use std::cmp::min; impl Add<Vec3> for Vec3 { type Output = Self; fn add(self, other: Self) -> Self { Self { x: self.x + other.x, ...
true
f341e320303ced7c1f41356b6853eb425b3a334f
Rust
mwatts/eve-native
/src/parser.rs
UTF-8
22,215
3.03125
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
use crate::combinators::*; use crate::compiler::{Node, OutputType}; use crate::error::ParseError; use std::str::FromStr; //-------------------------------------------------------------------- // Constants //-------------------------------------------------------------------- const BREAK_CHARS: &'static str = "#\\.,()...
true
f917834846b5a8d3e02a249eda12a3db3d9ca005
Rust
benmkw/microscheme
/scheme_lib/src/tests.rs
UTF-8
7,979
3.125
3
[ "MIT" ]
permissive
use super::*; use Expression::*; #[test] fn basics() { let input = "(+ 3 4)"; test_eq!(run(input) => Number(7)); let input = "(+ 3 (* 3 2))"; test_eq!(run(input) => Number(9)); let input = "(- 6 2)"; test_eq!(run(input) => Number(4)); let input = "(* 3 (/ 4 2))"; test_eq!(run(input) ...
true
cbad25dbad7e880657e6e3a8b6b94140b61d3bd4
Rust
ddboline/programming_tests
/rust/codewars/getting_along_with_integer_partitions/src/lib.rs
UTF-8
2,093
3.484375
3
[]
no_license
use std::collections::HashMap; use std::rc::Rc; fn part(n: i64) -> String { let mut cache: HashMap<(i64, i64), Rc<Vec<i64>>> = HashMap::new(); let prod = partitions_recursive(n, n, &mut cache); let range = prod[prod.len()-1] - prod[0]; let sum: i64 = prod.iter().sum(); let mean = sum as f64 / prod....
true
2ef82a6e336b966fb9c4d54b961956280c06c137
Rust
Crghilardi/tvalue_rs
/src/main.rs
UTF-8
2,172
3.03125
3
[]
no_license
fn main() { let df:i32 = 1; let prob:f32 = 0.05; println!("df = {}",df); println!("prob = {}",prob); println!("tvalue(1,0.05) = {}", tvalue(df, prob)); println!("tvalue(2,0,05) = {}", tvalue(2, prob)); println!("tvalue(3,0.05) = {}", tvalue(3, prob)); println!("tvalue(4,0,05) = {}", t...
true
666f22e0afdd56513e696e272dd521d21d018854
Rust
jakyle/rust-algos
/src/array_strings_are_equal.rs
UTF-8
1,471
4.1875
4
[ "MIT" ]
permissive
/// Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise. /// /// A string is represented by an array if the array elements concatenated in order forms the string. /// /// /// /// Example 1: /// /// Input: word1 = ["ab", "c"], word2 = ["a", "bc"] /// Outp...
true
883578e9f9179d777d902b6f43f35a901fd38ff1
Rust
HerbLuo/query-pro-bg-rust
/src/component/uid.rs
UTF-8
1,072
2.75
3
[]
no_license
use rocket::request::FromRequest; use rocket::{Request, request}; use std::lazy::SyncOnceCell; use rocket::http::Status; pub struct Uid { pub uid_sql_val_str: Option<String>, } static UID_GETTER: SyncOnceCell<Box<dyn Sync + Send + Fn(&Request) -> Result<Uid, String>>> = SyncOnceCell::new(); pub fn set_uid_getter...
true
396b68439819df34e87de4f36ee9b001c4478547
Rust
SunLab-GMU/RusTEE-CompileTAinRust
/examples/acipher/proto/src/lib.rs
UTF-8
459
2.6875
3
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
pub enum Command { GenKey, GetSize, Encrypt, Decrypt, Unknown, } impl From<u32> for Command { #[inline] fn from(value: u32) -> Command { match value { 0 => Command::GenKey, 1 => Command::GetSize, 2 => Command::Encrypt, 3 => Command::D...
true