file_name
large_stringlengths
4
69
prefix
large_stringlengths
0
26.7k
suffix
large_stringlengths
0
24.8k
middle
large_stringlengths
0
2.12k
fim_type
large_stringclasses
4 values
app_uart_tiva_c.rs
#![feature(plugin)] #![crate_type="staticlib"] #![no_std] extern crate core; extern crate zinc; #[macro_use] #[plugin] #[no_link] extern crate macro_platformtree; use zinc::drivers::chario::CharIO; platformtree!( tiva_c@mcu { clock { source = "MOSC"; xtal = "X16_0MHz"; pll = true; ...
mode = "115200,8n1"; } } } os { single_task { loop = "run"; args { timer = &timer; uart = &uart; txled = &txled; uart_tx = &uart_tx; } } } ); fn run(args: &pt::run_args) { use zinc::hal::timer::Timer; use zinc::hal::pin::Gpio; a...
uart@0 {
random_line_split
state_diff.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
//! State diff module. use std::fmt; use std::ops::*; use std::collections::BTreeMap; use util::Address; use account_diff::*; #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "ipc", binary)] /// Expression for the delta between two system states. Encoded the /// delta of every altered account. pub struct ...
// You should have received a copy of the GNU General Public License // along with Parity. If not, see <http://www.gnu.org/licenses/>.
random_line_split
state_diff.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
{ /// Raw diff key-value pub raw: BTreeMap<Address, AccountDiff> } impl StateDiff { /// Get the actual data. pub fn get(&self) -> &BTreeMap<Address, AccountDiff> { &self.raw } } impl fmt::Display for StateDiff { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { for (add, acc) in &self.raw { write!(...
StateDiff
identifier_name
state_diff.rs
// Copyright 2015-2017 Parity Technologies (UK) Ltd. // This file is part of Parity. // Parity is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any lat...
}
{ &self.raw }
identifier_body
request.rs
//! Server Requests //! //! These are requests that a `hyper::Server` receives, and include its method, //! target URI, headers, and message body. use std::io::IoResult; use std::io::net::ip::SocketAddr; use {HttpResult}; use version::{HttpVersion}; use method::Method::{mod, Get, Head}; use header::Headers; use header...
(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.body.read(buf) } } #[cfg(test)] mod tests { use mock::MockStream; use super::Request; macro_rules! sock( ($s:expr) => (::std::str::from_str::<::std::io::net::ip::SocketAddr>($s).unwrap()) ) #[test] fn test_get_empty_body...
read
identifier_name
request.rs
//! Server Requests //! //! These are requests that a `hyper::Server` receives, and include its method, //! target URI, headers, and message body. use std::io::IoResult; use std::io::net::ip::SocketAddr; use {HttpResult}; use version::{HttpVersion}; use method::Method::{mod, Get, Head}; use header::Headers; use header...
else if headers.has::<ContentLength>() { match headers.get::<ContentLength>() { Some(&ContentLength(len)) => SizedReader(stream, len), None => unreachable!() } } else if headers.has::<TransferEncoding>() { todo!("check for Transfer-Encoding: c...
{ EmptyReader(stream) }
conditional_block
request.rs
//! Server Requests //! //! These are requests that a `hyper::Server` receives, and include its method, //! target URI, headers, and message body. use std::io::IoResult; use std::io::net::ip::SocketAddr; use {HttpResult}; use version::{HttpVersion}; use method::Method::{mod, Get, Head}; use header::Headers; use header...
}
{ let mut stream = MockStream::with_input(b"\ POST / HTTP/1.1\r\n\ Host: example.domain\r\n\ \r\n\ I'm a bad request.\r\n\ "); let mut req = Request::new(&mut stream, sock!("127.0.0.1:80")).unwrap(); assert_eq!(req.read_to_string(), Ok(""....
identifier_body
request.rs
//! Server Requests //! //! These are requests that a `hyper::Server` receives, and include its method, //! target URI, headers, and message body. use std::io::IoResult; use std::io::net::ip::SocketAddr; use {HttpResult}; use version::{HttpVersion}; use method::Method::{mod, Get, Head}; use header::Headers; use header...
} #[cfg(test)] mod tests { use mock::MockStream; use super::Request; macro_rules! sock( ($s:expr) => (::std::str::from_str::<::std::io::net::ip::SocketAddr>($s).unwrap()) ) #[test] fn test_get_empty_body() { let mut stream = MockStream::with_input(b"\ GET / HTTP/1....
impl<'a> Reader for Request<'a> { fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.body.read(buf) }
random_line_split
shootout-spectralnorm.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
else if args.len() < 2 { 2000 } else { args[1].parse().unwrap() }); println!("{:.9}", answer); } fn spectralnorm(n: uint) -> f64 { assert!(n % 2 == 0, "only even lengths are accepted"); let mut u = repeat(1.0).take(n).collect::<Vec<_>>(); let mut v = u.clone(); let mut tmp ...
{ 5500 }
conditional_block
shootout-spectralnorm.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
struct Racy<T>(T); unsafe impl<T:'static> Send for Racy<T> {} // Executes a closure in parallel over the given mutable slice. The closure `f` // is run in parallel and yielded the starting index within `v` as well as a // sub-slice of `v`. fn parallel<T, F>(v: &mut [T], f: F) where T: Send + Sync, ...
fn dot(v: &[f64], u: &[f64]) -> f64 { v.iter().zip(u.iter()).map(|(a, b)| *a * *b).sum() }
random_line_split
shootout-spectralnorm.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
struct Racy<T>(T); unsafe impl<T:'static> Send for Racy<T> {} // Executes a closure in parallel over the given mutable slice. The closure `f` // is run in parallel and yielded the starting index within `v` as well as a // sub-slice of `v`. fn parallel<T, F>(v: &mut [T], f: F) where T: Send + Sync...
{ v.iter().zip(u.iter()).map(|(a, b)| *a * *b).sum() }
identifier_body
shootout-spectralnorm.rs
// The Computer Language Benchmarks Game // http://benchmarksgame.alioth.debian.org/ // // contributed by the Rust Project Developers // Copyright (c) 2012-2014 The Rust Project Developers // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted...
(v: &[f64], out: &mut [f64]) { parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j))); } fn mult_Atv(v: &[f64], out: &mut [f64]) { parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i))); } fn mult<F>(v: &[f64], out: &mut [f64], start: uint, a: F) where F: Fn(uint, uint) -> f64 { ...
mult_Av
identifier_name
trait-inheritance-num5.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ num_eq_one::<int>(); // you need to actually use the function to trigger the ICE }
identifier_body
trait-inheritance-num5.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
use std::cmp::PartialEq; use std::num::NumCast; pub trait NumExt: PartialEq + Num + NumCast {} impl NumExt for f32 {} impl NumExt for int {} fn num_eq_one<T:NumExt>() -> T { NumCast::from(1i).unwrap() } pub fn main() { num_eq_one::<int>(); // you need to actually use the function to trigger the ICE }
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
trait-inheritance-num5.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { num_eq_one::<int>(); // you need to actually use the function to trigger the ICE }
main
identifier_name
stdin_read_worker.rs
use std::io::prelude::*; use std::thread::{self, JoinHandle}; use std::os::unix::prelude::*; use std::sync::mpsc::*; use super::*; // The way this works on the server side, is there is a special enum for passing the io bytes, // called VteWorkerMsg. Maybe I should reuse that instead of ClientMsg, because only the inpu...
error!("Sender failed to send"); break; } } Err(msg) => { error!("{}", msg); break; } } } } }
random_line_split
stdin_read_worker.rs
use std::io::prelude::*; use std::thread::{self, JoinHandle}; use std::os::unix::prelude::*; use std::sync::mpsc::*; use super::*; // The way this works on the server side, is there is a special enum for passing the io bytes, // called VteWorkerMsg. Maybe I should reuse that instead of ClientMsg, because only the inpu...
/// start reading from stdin. Exits when a read fails. fn enter_read_loop(&mut self) { let mut buf = [0 as u8; 4096]; loop { match self.io.read(&mut buf) { Ok(num_bytes) => { if num_bytes == 0 { break; ...
{ info!("spawning stdin reader thread"); thread::spawn(move || { let mut worker = StdinReadWorker { client_tx: tx, io: io, }; worker.enter_read_loop(); info!("exiting stdin reader thread"); }) }
identifier_body
stdin_read_worker.rs
use std::io::prelude::*; use std::thread::{self, JoinHandle}; use std::os::unix::prelude::*; use std::sync::mpsc::*; use super::*; // The way this works on the server side, is there is a special enum for passing the io bytes, // called VteWorkerMsg. Maybe I should reuse that instead of ClientMsg, because only the inpu...
(io: F, tx: Sender<ClientMsg>) -> JoinHandle<()> { info!("spawning stdin reader thread"); thread::spawn(move || { let mut worker = StdinReadWorker { client_tx: tx, io: io, }; worker.enter_read_loop(); info!("exiting stdin re...
spawn
identifier_name
service_factory.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
} else { quote! { env!("CARGO_PKG_NAME") } } } fn artifact_version(&self) -> impl ToTokens { if let Some(ref artifact_version) = self.artifact_version { // Check that artifact version is semver compatible. Version::parse(artifact_version).expect("Unab...
quote! { #artifact_name }
random_line_split
service_factory.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
(&self) -> impl ToTokens { let cr = &self.cr; if let Some(ref proto_sources_mod) = self.proto_sources { quote! { #cr::ArtifactProtobufSpec::new( #proto_sources_mod::PROTO_SOURCES .iter() .map(|&(name, contents)...
artifact_protobuf_spec
identifier_name
service_factory.rs
// Copyright 2020 The Exonum Team // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to i...
} fn artifact_version(&self) -> impl ToTokens { if let Some(ref artifact_version) = self.artifact_version { // Check that artifact version is semver compatible. Version::parse(artifact_version).expect("Unable to parse artifact version"); quote! { #artifact_version }...
{ quote! { env!("CARGO_PKG_NAME") } }
conditional_block
json.rs
/* * Hi there! * * I found that handling Json was quite annoying, so I wrote this * little lib to help. You can find an example of the usage in the * tests at the end. * * I lacked inspiration on the naming of value() and item(), and got * lost in the lifetimes, so from_json takes a Json and not a * JsonLike. ...
_ => error(self, ~"not an object") } } fn as_list(self) -> Result<&'a List, ValueError> { match *self { List(ref l) => Ok(l), _ => error(self, ~"not a list") } } // fn as_null(self) -> Result<&'a Null, ValueError> { // match *self { /...
fn as_obj(self) -> Result<&'a ~Object, ValueError> { match *self { Object(ref o) => Ok(o),
random_line_split
json.rs
/* * Hi there! * * I found that handling Json was quite annoying, so I wrote this * little lib to help. You can find an example of the usage in the * tests at the end. * * I lacked inspiration on the naming of value() and item(), and got * lost in the lifetimes, so from_json takes a Json and not a * JsonLike. ...
(j: &Json) -> Result<f32, ValueError> { j.to_num().map(|n| n as f32) } } impl FromJson for int { fn from_json(j: &Json) -> Result<int, ValueError> { j.to_num().and_then( |i| { match i.to_int() { Some(v) => Ok(v), None => error(j, ~"is not an integer")...
from_json
identifier_name
json.rs
/* * Hi there! * * I found that handling Json was quite annoying, so I wrote this * little lib to help. You can find an example of the usage in the * tests at the end. * * I lacked inspiration on the naming of value() and item(), and got * lost in the lifetimes, so from_json takes a Json and not a * JsonLike. ...
} impl ToStr for ValueError { fn to_str(&self) -> ~str { format!("Can convert value \"{}\": {}", self.value, self.msg) } } /// This trait defines a number of operation that make getting data out of Json easier pub trait JsonLike<'a> { /// If this json value is a string, returns a reference to it ...
{ write!(f.buf, r#"Can't convert value: "{}" Reason: "{}""#, obj.value, obj.msg); }
identifier_body
TestNativeSqrt.rs
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by app...
float2 __attribute__((kernel)) testNativeSqrtFloat2Float2(float2 in) { return native_sqrt(in); } float3 __attribute__((kernel)) testNativeSqrtFloat3Float3(float3 in) { return native_sqrt(in); } float4 __attribute__((kernel)) testNativeSqrtFloat4Float4(float4 in) { return native_sqrt(in); }
}
random_line_split
redox.rs
pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000; pub const SYS_REALLOC: usize = 1001; pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; pub fn sys_debug(buf: &[u8]) -> Result<usize> { unsafe { syscall2(SYS_DEBUG, buf.as_ptr() as usize, buf.len()) } } pub unsafe f...
use syscall::{syscall1, syscall2}; use error::Result;
random_line_split
redox.rs
use syscall::{syscall1, syscall2}; use error::Result; pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000; pub const SYS_REALLOC: usize = 1001; pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; pub fn
(buf: &[u8]) -> Result<usize> { unsafe { syscall2(SYS_DEBUG, buf.as_ptr() as usize, buf.len()) } } pub unsafe fn sys_alloc(size: usize) -> Result<usize> { syscall1(SYS_ALLOC, size) } pub unsafe fn sys_realloc(ptr: usize, size: usize) -> Result<usize> { syscall2(SYS_REALLOC, ptr, size) } pub unsafe fn sys...
sys_debug
identifier_name
redox.rs
use syscall::{syscall1, syscall2}; use error::Result; pub const SYS_DEBUG: usize = 0; pub const SYS_ALLOC: usize = 1000; pub const SYS_REALLOC: usize = 1001; pub const SYS_REALLOC_INPLACE: usize = 1002; pub const SYS_UNALLOC: usize = 1003; pub fn sys_debug(buf: &[u8]) -> Result<usize> { unsafe { syscall2(SYS_DEB...
pub unsafe fn sys_unalloc(ptr: usize) -> Result<usize> { syscall1(SYS_UNALLOC, ptr) }
{ syscall2(SYS_REALLOC_INPLACE, ptr, size) }
identifier_body
calc.rs
// Copyright 2014 Pierre Talbot (IRCAM) // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // http://www.apache.org/licenses/LICENSE-2.0
pub use self::calc::*; grammar! calc { // #![show_api] program = spacing expression expression = term (term_op term)* > fold_left term = exponent (factor_op exponent)* > fold_left exponent = (factor exponent_op)* factor > fold_right factor = number > number_expr / identifier > var...
// Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License.
random_line_split
issue-12860.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
if!connected.contains(&cyp){ border.insert(cyp); } if!connected.contains(&cym) { border.insert(cym); } if!connected.contains(&czp){ border.insert(czp); } if!connected.contains(&czm) { border.insert(czm); } ...
} if !connected.contains(&cxm){ border.insert(cxm); }
random_line_split
issue-12860.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
if!connected.contains(&cym) { border.insert(cym); } if!connected.contains(&czp){ border.insert(czp); } if!connected.contains(&czm) { border.insert(czm); } } }
{ border.insert(cyp); }
conditional_block
issue-12860.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ x: int, y: int, z: int } fn main() { let mut connected = HashSet::new(); let mut border = HashSet::new(); let middle = XYZ{x: 0, y: 0, z: 0}; border.insert(middle); while border.len() > 0 && connected.len() < 10000 { let choice = *(border.iter().next().unwrap()); bo...
XYZ
identifier_name
issue-12860.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
border.insert(cxp); } if !connected.contains(&cxm){ border.insert(cxm); } if!connected.contains(&cyp){ border.insert(cyp); } if!connected.contains(&cym) { border.insert(cym); } if!connected.contains(&czp){ ...
{ let mut connected = HashSet::new(); let mut border = HashSet::new(); let middle = XYZ{x: 0, y: 0, z: 0}; border.insert(middle); while border.len() > 0 && connected.len() < 10000 { let choice = *(border.iter().next().unwrap()); border.remove(&choice); connected.insert(choi...
identifier_body
tyencode.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
fn enc_onceness(w: &mut SeekableMemWriter, o: Onceness) { match o { Once => mywrite!(w, "o"), Many => mywrite!(w, "m") } } pub fn enc_bare_fn_ty(w: &mut SeekableMemWriter, cx: &ctxt, ft: &ty::BareFnTy) { enc_fn_style(w, ft.fn_style); enc_abi(w, ft.abi); enc_fn_sig(w, cx, &ft.sig);...
{ mywrite!(w, "["); mywrite!(w, "{}", abi.name()); mywrite!(w, "]") }
identifier_body
tyencode.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
} } fn enc_fn_style(w: &mut SeekableMemWriter, p: FnStyle) { match p { NormalFn => mywrite!(w, "n"), UnsafeFn => mywrite!(w, "u"), } } fn enc_abi(w: &mut SeekableMemWriter, abi: Abi) { mywrite!(w, "["); mywrite!(w, "{}", abi.name()); mywrite!(w, "]") } fn enc_onceness(w: &mut ...
ty::ty_open(_) => { cx.diag.handler().bug("unexpected type in enc_sty (ty_open)"); }
random_line_split
tyencode.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
(w: &mut SeekableMemWriter, cx: &ctxt, s: &ty::TraitRef) { mywrite!(w, "{}|", (cx.ds)(s.def_id)); enc_substs(w, cx, &s.substs); } pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore) { match s { ty::UniqTraitStore => mywrite!(w, "~"), ty::RegionTraitStore(re, m) =...
enc_trait_ref
identifier_name
datassette.rs
// This file is part of zinc64. // Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved. // Licensed under the GPLv3. See LICENSE file in the project root for full license text. #[cfg(not(feature = "std"))] use alloc::prelude::*; use bit_field::BitField; use zinc64_core::{IoPort, Pin, Shared}; use super...
(&self) -> bool { self.remaining_cycles == 0 } pub fn advance(&mut self) -> bool { self.remaining_cycles -= 1; if self.low_cycles == 0 { true } else { self.low_cycles -= 1; false } } } pub struct Datassette { // Dependencies ...
is_done
identifier_name
datassette.rs
// This file is part of zinc64. // Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved. // Licensed under the GPLv3. See LICENSE file in the project root for full license text. #[cfg(not(feature = "std"))] use alloc::prelude::*; use bit_field::BitField; use zinc64_core::{IoPort, Pin, Shared}; use super...
} } pub fn attach(&mut self, tape: Box<dyn Tape>) { self.tape = Some(tape); } pub fn clock(&mut self) { if self.is_playing() && self.tape.is_some() { if self.current_pulse.is_done() { let pulse_maybe = if let Some(ref mut tape) = self.tape { ...
cia_flag_pin, cpu_io_port, playing: false, tape: None, current_pulse: Pulse::new(0, DUTY_CYCLE),
random_line_split
datassette.rs
// This file is part of zinc64. // Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved. // Licensed under the GPLv3. See LICENSE file in the project root for full license text. #[cfg(not(feature = "std"))] use alloc::prelude::*; use bit_field::BitField; use zinc64_core::{IoPort, Pin, Shared}; use super...
} } pub struct Datassette { // Dependencies cia_flag_pin: Shared<Pin>, cpu_io_port: Shared<IoPort>, // Runtime State playing: bool, tape: Option<Box<dyn Tape>>, current_pulse: Pulse, } impl Datassette { pub fn new(cia_flag_pin: Shared<Pin>, cpu_io_port: Shared<IoPort>) -> Self { ...
{ self.low_cycles -= 1; false }
conditional_block
util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate libc; use std::io; macro_rules! try_or { ($val:expr, $or:expr) => { match $val { ...
(msg: &str) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) }
io_err
identifier_name
util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate libc; use std::io; macro_rules! try_or { ($val:expr, $or:expr) => { match $val { ...
{ io::Error::new(io::ErrorKind::Other, msg) }
identifier_body
util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate libc; use std::io; macro_rules! try_or { ($val:expr, $or:expr) => { match $val { ...
fn is_negative(&self) -> bool { *self < 0 } } impl Signed for usize { fn is_negative(&self) -> bool { (*self as isize) < 0 } } #[cfg(any(target_os = "linux"))] pub fn from_unix_result<T: Signed>(rv: T) -> io::Result<T> { if rv.is_negative() { let errno = unsafe { *libc::__e...
} impl Signed for i32 {
random_line_split
util.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ extern crate libc; use std::io; macro_rules! try_or { ($val:expr, $or:expr) => { match $val { ...
} #[cfg(any(target_os = "openbsd"))] pub fn from_unix_result<T: Signed>(rv: T) -> io::Result<T> { if rv.is_negative() { Err(io::Error::last_os_error()) } else { Ok(rv) } } pub fn io_err(msg: &str) -> io::Error { io::Error::new(io::ErrorKind::Other, msg) }
{ Ok(rv) }
conditional_block
media_queries.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo's media-query device and expression representation. use app_units::Au; use cssparser::RGBA; use custom_...
{ Progressive, Interlace, } /// https://drafts.csswg.org/mediaqueries-4/#scan fn eval_scan(_: &Device, _: Option<Scan>) -> bool { // Since we doesn't support the 'tv' media type, the'scan' feature never // matches. false } lazy_static! { /// A list with all the media features that Servo suppo...
Scan
identifier_name
media_queries.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ //! Servo's media-query device and expression representation. use app_units::Au; use cssparser::RGBA; use custom_...
/// Returns whether we ever looked up the root font size of the Device. pub fn used_root_font_size(&self) -> bool { self.used_root_font_size.load(Ordering::Relaxed) } /// Returns the viewport size of the current device in app units, needed, /// among other things, to resolve viewport units...
/// Whether a given animation name may be referenced from style. pub fn animation_name_may_be_referenced(&self, _: &KeyframesName) -> bool { // Assume it is, since we don't have any good way to prove it's not. true }
random_line_split
test_session.rs
extern crate wechat; extern crate redis; use wechat::session::{SessionStore, RedisStorage}; const REDIS_URI: &'static str = "redis://127.0.0.1/"; #[test] fn test_redis_storage_set_then_get_del() { let client = redis::Client::open(REDIS_URI).unwrap(); let session = RedisStorage::new(client); session.del...
() { let client = redis::Client::open(REDIS_URI).unwrap(); let session = RedisStorage::new(client); session.del("test_session_3"); let data: Option<usize> = session.get("test_session_3", Some(1usize)); let data = data.unwrap(); assert_eq!(1usize, data); }
test_redis_storage_get_with_default
identifier_name
test_session.rs
extern crate wechat; extern crate redis; use wechat::session::{SessionStore, RedisStorage}; const REDIS_URI: &'static str = "redis://127.0.0.1/";
#[test] fn test_redis_storage_set_then_get_del() { let client = redis::Client::open(REDIS_URI).unwrap(); let session = RedisStorage::new(client); session.del("test_session_1"); session.set("test_session_1", 1usize, None); let data: usize = session.get("test_session_1", None).unwrap(); assert_e...
random_line_split
test_session.rs
extern crate wechat; extern crate redis; use wechat::session::{SessionStore, RedisStorage}; const REDIS_URI: &'static str = "redis://127.0.0.1/"; #[test] fn test_redis_storage_set_then_get_del()
#[test] fn test_redis_storage_get_without_default() { let client = redis::Client::open(REDIS_URI).unwrap(); let session = RedisStorage::new(client); session.del("test_session_2"); let data: Option<usize> = session.get("test_session_2", None); assert!(data.is_none()); } #[test] fn test_redis_stor...
{ let client = redis::Client::open(REDIS_URI).unwrap(); let session = RedisStorage::new(client); session.del("test_session_1"); session.set("test_session_1", 1usize, None); let data: usize = session.get("test_session_1", None).unwrap(); assert_eq!(1usize, data); session.del("test_session_1"...
identifier_body
errors.rs
// Copyright 2016 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
, &BadEntityPlace => { writeln!(f, "cannot convert value place into entity place") }, } } } #[derive(Debug)] pub struct DbError { inner: Context<DbErrorKind>, } impl ::std::fmt::Display for DbError { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt...
{ writeln!(f, ":db/id in map notation must either not be present or be an entid, an ident, or a tempid") }
conditional_block
errors.rs
// Copyright 2016 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
UnknownAttribute(Entid), #[fail(display = "cannot reverse-cache non-unique attribute: {}", _0)] CannotCacheNonUniqueAttributeInReverse(Entid), #[fail(display = "schema alteration failed: {}", _0)] SchemaAlterationFailed(String), /// A transaction tried to violate a constraint of the schema of...
#[fail(display = "unknown attribute for entid: {}", _0)]
random_line_split
errors.rs
// Copyright 2016 Mozilla // // Licensed under the Apache License, Version 2.0 (the "License"); you may not use // this file except in compliance with the License. You may obtain a copy of the // License at http://www.apache.org/licenses/LICENSE-2.0 // Unless required by applicable law or agreed to in writing, software...
(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { use self::InputError::*; match self { &BadDbId => { writeln!(f, ":db/id in map notation must either not be present or be an entid, an ident, or a tempid") }, &BadEntityPlace => { ...
fmt
identifier_name
saturating_pow.rs
use malachite_base::num::basic::integers::PrimitiveInt; use malachite_base::num::basic::signeds::PrimitiveSigned; use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base_test_util::generators::{ signed_unsigned_pair_gen_var_14, unsigned_pair_gen_var_28, }; #[test] fn test_saturating_pow() ...
<T: PrimitiveUnsigned>() { unsigned_pair_gen_var_28::<T, u64>().test_properties(|(x, y)| { let mut power = x; power.saturating_pow_assign(y); assert_eq!(power, x.saturating_pow(y)); if y!= 0 { assert!(power >= x); } if power < T::MAX { assert_e...
saturating_pow_properties_helper_unsigned
identifier_name
saturating_pow.rs
use malachite_base::num::basic::integers::PrimitiveInt;
use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base_test_util::generators::{ signed_unsigned_pair_gen_var_14, unsigned_pair_gen_var_28, }; #[test] fn test_saturating_pow() { fn test<T: PrimitiveInt>(x: T, y: u64, out: T) { assert_eq!(x.saturating_pow(y), out); let ...
use malachite_base::num::basic::signeds::PrimitiveSigned;
random_line_split
saturating_pow.rs
use malachite_base::num::basic::integers::PrimitiveInt; use malachite_base::num::basic::signeds::PrimitiveSigned; use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base_test_util::generators::{ signed_unsigned_pair_gen_var_14, unsigned_pair_gen_var_28, }; #[test] fn test_saturating_pow() ...
test::<u8>(0, 0, 1); test::<u64>(123, 0, 1); test::<u64>(123, 1, 123); test::<u16>(0, 123, 0); test::<u16>(1, 123, 1); test::<i16>(-1, 123, -1); test::<i16>(-1, 124, 1); test::<u8>(3, 3, 27); test::<i32>(-10, 9, -1000000000); test::<i32>(-10, 10, i32::MAX); test::<i16>(-10, ...
{ assert_eq!(x.saturating_pow(y), out); let mut x = x; x.saturating_pow_assign(y); assert_eq!(x, out); }
identifier_body
saturating_pow.rs
use malachite_base::num::basic::integers::PrimitiveInt; use malachite_base::num::basic::signeds::PrimitiveSigned; use malachite_base::num::basic::unsigneds::PrimitiveUnsigned; use malachite_base_test_util::generators::{ signed_unsigned_pair_gen_var_14, unsigned_pair_gen_var_28, }; #[test] fn test_saturating_pow() ...
}); } fn saturating_pow_properties_helper_signed<T: PrimitiveSigned>() { signed_unsigned_pair_gen_var_14::<T, u64>().test_properties(|(x, y)| { let mut power = x; power.saturating_pow_assign(y); assert_eq!(power, x.saturating_pow(y)); if power > T::MIN && power < T::MAX { ...
{ assert_eq!(power, x.pow(y)); }
conditional_block
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> HTMLTimeElement { HTMLTimeElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) } } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<D...
new_inherited
identifier_name
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
#[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLTimeElement> { Node::reflect_node(box HTMLTimeElement::new_inherited(local_name, prefix, document), document, ...
{ HTMLTimeElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document) } }
identifier_body
htmltimeelement.rs
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ use dom::bindings::codegen::Bindings::HTMLTimeElementBinding; use dom::bindings::js::Root; use dom::bindings::str:...
} } #[allow(unrooted_must_root)] pub fn new(local_name: LocalName, prefix: Option<DOMString>, document: &Document) -> Root<HTMLTimeElement> { Node::reflect_node(box HTMLTimeElement::new_inherited(local_name, prefix, document), documen...
HTMLTimeElement { htmlelement: HTMLElement::new_inherited(local_name, prefix, document)
random_line_split
rect.rs
//! Basic manipulation of rectangles. use std::cmp; /// A rectangular region of non-zero width and height. /// # Examples /// ``` /// use imageproc::rect::Rect; /// use imageproc::rect::Region; /// /// // Construct a rectangle with top-left corner at (4, 5), width 6 and height 7. /// let rect = Rect::at(4, 5).of_size...
Some(Rect { left: left, top: top, width: (right - left) as u32 + 1, height: (bottom - top) as u32 + 1, }) } } impl Region<i32> for Rect { fn contains(&self, x: i32, y: i32) -> bool { self.left <= x && x <= self.right() && self.to...
{ return None; }
conditional_block
rect.rs
//! Basic manipulation of rectangles. use std::cmp; /// A rectangular region of non-zero width and height. /// # Examples /// ``` /// use imageproc::rect::Rect; /// use imageproc::rect::Region; /// /// // Construct a rectangle with top-left corner at (4, 5), width 6 and height 7. /// let rect = Rect::at(4, 5).of_size...
/// See the [struct-level documentation](struct.Rect.html) for examples. pub fn top(&self) -> i32 { self.top } /// Smallest x-coordinate reached by rect. /// /// See the [struct-level documentation](struct.Rect.html) for examples. pub fn left(&self) -> i32 { self.left } ...
random_line_split
rect.rs
//! Basic manipulation of rectangles. use std::cmp; /// A rectangular region of non-zero width and height. /// # Examples /// ``` /// use imageproc::rect::Rect; /// use imageproc::rect::Region; /// /// // Construct a rectangle with top-left corner at (4, 5), width 6 and height 7. /// let rect = Rect::at(4, 5).of_size...
} /// Position of the top left of a rectangle. /// Only used when building a [`Rect`](struct.Rect.html). #[derive(Copy, Clone, Debug, PartialEq, Eq)] pub struct RectPosition { left: i32, top: i32, } impl RectPosition { /// Construct a rectangle from a position and size. Width and height /// are requi...
{ self.left as f32 <= x && x <= self.right() as f32 && self.top as f32 <= y && y <= self.bottom() as f32 }
identifier_body
rect.rs
//! Basic manipulation of rectangles. use std::cmp; /// A rectangular region of non-zero width and height. /// # Examples /// ``` /// use imageproc::rect::Rect; /// use imageproc::rect::Region; /// /// // Construct a rectangle with top-left corner at (4, 5), width 6 and height 7. /// let rect = Rect::at(4, 5).of_size...
(&self) -> u32 { self.width } /// Height of rect. pub fn height(&self) -> u32 { self.height } /// Returns the intersection of self and other, or none if they are are disjoint. /// /// # Examples /// ``` /// use imageproc::rect::Rect; /// use imageproc::rect::Reg...
width
identifier_name
lib.rs
//! FFI bindings for `energymon-rapl.h`. extern crate libc; extern crate energymon_sys; pub use energymon_sys::energymon; use libc::{c_int, uint64_t, c_char, size_t}; extern "C" { pub fn energymon_init_rapl(em: *mut energymon) -> c_int; pub fn energymon_read_total_rapl(em: *const energymon) -> uint64_t; ...
pub fn energymon_get_interval_rapl(em: *const energymon) -> uint64_t; pub fn energymon_get_precision_rapl(em: *const energymon) -> uint64_t; pub fn energymon_is_exclusive_rapl() -> c_int; pub fn energymon_get_rapl(em: *mut energymon) -> c_int; }
pub fn energymon_get_source_rapl(buffer: *mut c_char, n: size_t) -> *mut c_char;
random_line_split
collector.rs
use capnp; use zmq; use capnp_zmq; static GRID_WIDTH : u32 = 120; static GRID_HEIGHT : u32 = 120; pub fn main() -> Result<(), zmq::Error> { use explorers_capnp::{observation, grid}; use capnp::message::{MessageReader, MessageBuilder}; let mut context = zmq::Context::new(); let mut subscriber = try!(c...
else if (poll_items[1].get_revents() & zmq::POLLIN)!= 0 { // there's a new observation waiting for us let frames = try!(capnp_zmq::recv(&mut subscriber)); let segments = capnp_zmq::frames_to_segments(&frames); let reader = capnp::message::SegmentArrayMessageReader::new...
{ try!(responder.recv_msg(0)); try!(capnp_zmq::send(&mut responder, & mut message)); }
conditional_block
collector.rs
use capnp; use zmq; use capnp_zmq; static GRID_WIDTH : u32 = 120; static GRID_HEIGHT : u32 = 120; pub fn main() -> Result<(), zmq::Error> { use explorers_capnp::{observation, grid}; use capnp::message::{MessageReader, MessageBuilder}; let mut context = zmq::Context::new(); let mut subscriber = try!(c...
try!(responder.recv_msg(0)); try!(capnp_zmq::send(&mut responder, & mut message)); } else if (poll_items[1].get_revents() & zmq::POLLIN)!= 0 { // there's a new observation waiting for us let frames = try!(capnp_zmq::recv(&mut subscriber)); let segm...
random_line_split
collector.rs
use capnp; use zmq; use capnp_zmq; static GRID_WIDTH : u32 = 120; static GRID_HEIGHT : u32 = 120; pub fn main() -> Result<(), zmq::Error>
// scheme, this usage pattern could waste memory if these // updates caused allocations in the message. Fortunately, // the updates only change the values of existing numeric // fields, so no allocation occurs. If that were not the // case, we could occasionally garbage collect by copying // to ...
{ use explorers_capnp::{observation, grid}; use capnp::message::{MessageReader, MessageBuilder}; let mut context = zmq::Context::new(); let mut subscriber = try!(context.socket(zmq::SUB)); let mut responder = try!(context.socket(zmq::REP)); try!(subscriber.bind("tcp://*:5555")); try!(subsc...
identifier_body
collector.rs
use capnp; use zmq; use capnp_zmq; static GRID_WIDTH : u32 = 120; static GRID_HEIGHT : u32 = 120; pub fn
() -> Result<(), zmq::Error> { use explorers_capnp::{observation, grid}; use capnp::message::{MessageReader, MessageBuilder}; let mut context = zmq::Context::new(); let mut subscriber = try!(context.socket(zmq::SUB)); let mut responder = try!(context.socket(zmq::REP)); try!(subscriber.bind("tc...
main
identifier_name
outgoing.rs
// This test should really be part of ruma_serde, but some tooling doesn't like // cyclic dev-dependencies, which are required for this test to be moved there. #![allow(clippy::exhaustive_structs, clippy::redundant_allocation)] use ruma::{Outgoing, UserId}; #[allow(unused)] pub struct Thing<'t, T> {
#[allow(dead_code)] pub struct IncomingThing<T> { some: String, t: T, } #[allow(unused)] #[derive(Copy, Clone, Debug, Outgoing, serde::Serialize)] #[serde(crate = "serde")] pub struct OtherThing<'t> { pub some: &'t str, pub t: &'t [u8], } #[derive(Outgoing)] #[incoming_derive(!Deserialize)] #[non_exha...
some: &'t str, t: &'t T, } #[derive(Debug)]
random_line_split
outgoing.rs
// This test should really be part of ruma_serde, but some tooling doesn't like // cyclic dev-dependencies, which are required for this test to be moved there. #![allow(clippy::exhaustive_structs, clippy::redundant_allocation)] use ruma::{Outgoing, UserId}; #[allow(unused)] pub struct Thing<'t, T> { some: &'t st...
<'t> { pub some: &'t str, pub t: &'t [u8], } #[derive(Outgoing)] #[incoming_derive(!Deserialize)] #[non_exhaustive] pub struct FakeRequest<'a, T> { pub abc: &'a str, pub thing: Thing<'a, T>, pub device_id: &'a ::ruma_common::DeviceId, pub user_id: &'a UserId, pub bytes: &'a [u8], pub re...
OtherThing
identifier_name
rc4.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /*! * An implement...
(key: &[u8]) -> Rc4 { assert!(key.len() >= 1 && key.len() <= 256); let mut rc4 = Rc4 { i: 0, j: 0, state: [0; 256] }; for (i, x) in rc4.state.iter_mut().enumerate() { *x = i as u8; } let mut j: u8 = 0; for i in 0..256 { j = j.wrapping_add(rc4.state...
new
identifier_name
rc4.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /*! * An implement...
} impl Decryptor for Rc4 { fn decrypt(&mut self, input: &mut RefReadBuffer, output: &mut RefWriteBuffer, _: bool) -> Result<BufferResult, SymmetricCipherError> { symm_enc_or_dec(self, input, output) } } #[cfg(test)] mod test { use std::iter::repeat; use symmetriccipher::Synchrono...
{ symm_enc_or_dec(self, input, output) }
identifier_body
rc4.rs
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. /*! * An implement...
}); bh.bytes = input.len() as u64; } #[bench] pub fn rc4_64k(bh: & mut Bencher) { let mut rc4 = Rc4::new("key".as_bytes()); let input = [1u8; 65536]; let mut output = [0u8; 65536]; bh.iter( || { rc4.process(&input, &mut output); }); ...
let mut output = [0u8; 1024]; bh.iter( || { rc4.process(&input, &mut output);
random_line_split
iterating_docs_and_positions.rs
// # Iterating docs and positioms. // // At its core of tantivy, relies on a data structure // called an inverted index. // // This example shows how to manually iterate through // the list of documents containing a term, getting // its term frequency, and accessing its positions. // --- // Importing tantivy... #[macr...
let index = Index::create_in_ram(schema.clone()); let mut index_writer = index.writer_with_num_threads(1, 50_000_000)?; index_writer.add_document(doc!(title => "The Old Man and the Sea")); index_writer.add_document(doc!(title => "Of Mice and Men")); index_writer.add_document(doc!(title => "The mode...
let title = schema_builder.add_text_field("title", TEXT | STORED); let schema = schema_builder.build();
random_line_split
iterating_docs_and_positions.rs
// # Iterating docs and positioms. // // At its core of tantivy, relies on a data structure // called an inverted index. // // This example shows how to manually iterate through // the list of documents containing a term, getting // its term frequency, and accessing its positions. // --- // Importing tantivy... #[macr...
() -> tantivy::Result<()> { // We first create a schema for the sake of the // example. Check the `basic_search` example for more information. let mut schema_builder = Schema::builder(); // For this example, we need to make sure to index positions for our title // field. `TEXT` precisely does this....
main
identifier_name
iterating_docs_and_positions.rs
// # Iterating docs and positioms. // // At its core of tantivy, relies on a data structure // called an inverted index. // // This example shows how to manually iterate through // the list of documents containing a term, getting // its term frequency, and accessing its positions. // --- // Importing tantivy... #[macr...
} Ok(()) }
{ while block_segment_postings.advance() { // Once again these docs MAY contains deleted documents as well. let docs = block_segment_postings.docs(); // Prints `Docs [0, 2].` println!("Docs {:?}", docs); } }
conditional_block
iterating_docs_and_positions.rs
// # Iterating docs and positioms. // // At its core of tantivy, relies on a data structure // called an inverted index. // // This example shows how to manually iterate through // the list of documents containing a term, getting // its term frequency, and accessing its positions. // --- // Importing tantivy... #[macr...
let searcher = reader.searcher(); // A tantivy index is actually a collection of segments. // Similarly, a searcher just wraps a list `segment_reader`. // // (Because we indexed a very small number of documents over one thread // there is actually only one segment here, but let's iterate throug...
{ // We first create a schema for the sake of the // example. Check the `basic_search` example for more information. let mut schema_builder = Schema::builder(); // For this example, we need to make sure to index positions for our title // field. `TEXT` precisely does this. let title = schema_bu...
identifier_body
lib.rs
#![feature(const_fn)] #![feature(slice_patterns)] #![cfg_attr(test, feature(test))] pub mod color; pub mod matrix; pub mod orientation; pub mod point; pub mod quaternion; pub mod vector; #[cfg(test)] mod test; pub use color::Color; pub use matrix::{Matrix3, Matrix4}; pub use orientation::Orientation; pub use point::...
} pub trait Dot<Other=Self> { type Output; fn dot(self, rhs: Other) -> Self::Output; } impl Dot for [f32; 3] { type Output = f32; fn dot(self, rhs: [f32; 3]) -> f32 { self[0] * rhs[0] + self[1] * rhs[1] + self[2] * rhs[2] } } // Doesn't cause ICE. impl<'a, T> Dot<&'a T> for...
{ f32::min(f32::max(self, min), max) }
identifier_body
lib.rs
#![feature(const_fn)] #![feature(slice_patterns)] #![cfg_attr(test, feature(test))] pub mod color; pub mod matrix; pub mod orientation; pub mod point; pub mod quaternion; pub mod vector; #[cfg(test)] mod test; pub use color::Color; pub use matrix::{Matrix3, Matrix4}; pub use orientation::Orientation; pub use point::...
(self, rhs: &T) -> Self::Output { self.dot(*rhs) } } // // Causes ICE. // impl<'a, T, U> Dot<&'a U> for T where T: Dot<U>, U: Copy { // type Output = T::Output; // // fn dot(self, rhs: &U) -> Self::Output { // self.dot(*rhs) // } // } pub trait Lerp { fn lerp(t: f32, from: Self, to...
dot
identifier_name
lib.rs
#![feature(const_fn)] #![feature(slice_patterns)] #![cfg_attr(test, feature(test))] pub mod color; pub mod matrix; pub mod orientation; pub mod point; pub mod quaternion; pub mod vector; #[cfg(test)] mod test; pub use color::Color; pub use matrix::{Matrix3, Matrix4}; pub use orientation::Orientation; pub use point::...
impl<'a, T> Dot<&'a T> for T where T: Dot<T> + Copy { type Output = T::Output; fn dot(self, rhs: &T) -> Self::Output { self.dot(*rhs) } } // // Causes ICE. // impl<'a, T, U> Dot<&'a U> for T where T: Dot<U>, U: Copy { // type Output = T::Output; // // fn dot(self, rhs: &U) -> Self::Output ...
} } // Doesn't cause ICE.
random_line_split
grades.rs
use Error; use Login; use Year; use std::fmt; use std::collections::HashMap; use reqwest; use chrono; /// A course of studies. #[derive(Deserialize, Debug)] pub struct Course { #[serde(rename = "AbschlTxt")]
#[serde(rename = "StgNr")] pub course_nr: String, #[serde(rename = "StgTxt")] pub course_note: String, } impl Course { /// Returns a list of courses for a given login. /// /// # Arguments /// /// * `login` - Login /// /// # Example /// /// ``` /// use htwdresden:...
pub degree_txt: String, #[serde(rename = "POVersion")] pub regulation_version: String, #[serde(rename = "AbschlNr")] pub deg_nr: String,
random_line_split
grades.rs
use Error; use Login; use Year; use std::fmt; use std::collections::HashMap; use reqwest; use chrono; /// A course of studies. #[derive(Deserialize, Debug)] pub struct
{ #[serde(rename = "AbschlTxt")] pub degree_txt: String, #[serde(rename = "POVersion")] pub regulation_version: String, #[serde(rename = "AbschlNr")] pub deg_nr: String, #[serde(rename = "StgNr")] pub course_nr: String, #[serde(rename = "StgTxt")] pub course_note: String, } imp...
Course
identifier_name
trait-inheritance-overloading-simple.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); assert!(x!= y); assert!(x == z); }
{ MyInt { val: v } }
identifier_body
trait-inheritance-overloading-simple.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(v: int) -> MyInt { MyInt { val: v } } pub fn main() { let (x, y, z) = (mi(3), mi(5), mi(3)); assert!(x!= y); assert!(x == z); }
mi
identifier_name
trait-inheritance-overloading-simple.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use core::cmp::Eq; ...
// file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //
random_line_split
token.rs
#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum StringLiteralKind { Normal, Raw, } #[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum BinOpKind { Plus, Minus, Star, Slash, Percent, Caret, And, Or, Shl, Shr, } #[derive(PartialEq, Eq, Copy, Debug, Clo...
#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum IntegerLiteralSuffix { None, Isize, Usize, U8, I8, U16, I16, U32, I32, U64, I64 } #[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum FloatLiteralSuffix { None, F32, F64 } #[derive(PartialEq, Eq, Copy, Debug, Clon...
Octal, Binary }
random_line_split
token.rs
#[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum
{ Normal, Raw, } #[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum BinOpKind { Plus, Minus, Star, Slash, Percent, Caret, And, Or, Shl, Shr, } #[derive(PartialEq, Eq, Copy, Debug, Clone, Hash)] pub enum KeywordKind { // strict As, Break, Crate,...
StringLiteralKind
identifier_name
structs.rs
//! Rust struct for canonical test data. //! //! See https://github.com/exercism/problem-specifications/blob/main/canonical-schema.json //! for more details on the JSON schema, which makes it possible to implement //! `serde::Deserialize`. use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collection...
(&self) -> impl Iterator<Item = &LabeledTest> { std::iter::once(self) } } impl LabeledTestGroup { fn iter(&self) -> impl Iterator<Item = &LabeledTest> { self.cases.iter().flat_map(LabeledTestItem::iter) } }
iter
identifier_name
structs.rs
//! Rust struct for canonical test data. //! //! See https://github.com/exercism/problem-specifications/blob/main/canonical-schema.json //! for more details on the JSON schema, which makes it possible to implement //! `serde::Deserialize`. use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collection...
std::iter::once(self) } } impl LabeledTestGroup { fn iter(&self) -> impl Iterator<Item = &LabeledTest> { self.cases.iter().flat_map(LabeledTestItem::iter) } }
} } impl LabeledTest { fn iter(&self) -> impl Iterator<Item = &LabeledTest> {
random_line_split
structs.rs
//! Rust struct for canonical test data. //! //! See https://github.com/exercism/problem-specifications/blob/main/canonical-schema.json //! for more details on the JSON schema, which makes it possible to implement //! `serde::Deserialize`. use serde::{Deserialize, Serialize}; use serde_json::Value; use std::collection...
} impl LabeledTestGroup { fn iter(&self) -> impl Iterator<Item = &LabeledTest> { self.cases.iter().flat_map(LabeledTestItem::iter) } }
{ std::iter::once(self) }
identifier_body
lib.rs
#![crate_type="rlib"] #![allow(dead_code)] // for now extern crate regex; use std::collections::HashMap; #[derive(Copy,Clone)] pub struct Input<'a> { pub text: &'a str, pub offset: usize, } pub trait Symbol<'input, G> { type Output; fn parse_complete(&self, grammar: &mut G, text: &'input str) ...
} #[cfg(test)] mod test;
{ Input { text: self.text, offset: self.offset + amount } }
identifier_body
lib.rs
#![crate_type="rlib"] #![allow(dead_code)] // for now extern crate regex; use std::collections::HashMap; #[derive(Copy,Clone)] pub struct Input<'a> { pub text: &'a str, pub offset: usize, } pub trait Symbol<'input, G> { type Output; fn parse_complete(&self, grammar: &mut G, text: &'input str) ...
<'input> { pub expected: &'input str, pub offset: usize } #[macro_use] pub mod macros; pub mod util; pub mod tree; impl<'input> Input<'input> { fn offset_by(&self, amount: usize) -> Input<'input> { Input { text: self.text, offset: self.offset + amount } } } #[cfg(test)] mod test;
Error
identifier_name
lib.rs
#![crate_type="rlib"] #![allow(dead_code)] // for now extern crate regex; use std::collections::HashMap; #[derive(Copy,Clone)] pub struct Input<'a> { pub text: &'a str, pub offset: usize, } pub trait Symbol<'input, G> { type Output; fn parse_complete(&self, grammar: &mut G, text: &'input str) ...
else { Err(Error { expected: "end of input", offset: end.offset }) } } fn parse_prefix(&self, grammar: &mut G, text: &'input str) -> ParseResult<'input,Self::Output> { let input = Input { text: text, offset: 0 }; self.parse(g...
{ Ok(result) }
conditional_block
lib.rs
#![crate_type="rlib"] #![allow(dead_code)] // for now extern crate regex; use std::collections::HashMap; #[derive(Copy,Clone)] pub struct Input<'a> { pub text: &'a str, pub offset: usize,
pub trait Symbol<'input, G> { type Output; fn parse_complete(&self, grammar: &mut G, text: &'input str) -> Result<Self::Output, Error<'input>> { let start = Input { text: text, offset: 0 }; let start = util::skip_whitespace(start); let (mid, result) = try!(self...
}
random_line_split
rem.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::i8x16; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct i8x16(pub i8, pub i8, pub i8, pub i8, // pub i8, pub i8, pub i8, pub i8, // pub i8, pub ...
() { let x: i8x16 = i8x16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ); let y: i8x16 = i8x16( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ); let z: i8x16 = x % y; let result: String = format!("{:?}", z); assert_eq!(result, "i8x16(\ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0...
rem_test1
identifier_name
rem.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::i8x16; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct i8x16(pub i8, pub i8, pub i8, pub i8, // pub i8, pub i8, pub i8, pub i8, // pub i8, pub ...
}
{ let x: i8x16 = i8x16( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ); let y: i8x16 = i8x16( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 ); let z: i8x16 = x % y; let result: String = format!("{:?}", z); assert_eq!(result, "i8x16(\ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1...
identifier_body
rem.rs
#![feature(core, core_simd)] extern crate core; #[cfg(test)] mod tests { use core::simd::i8x16; // #[simd] // #[derive(Copy, Clone, Debug)] // #[repr(C)] // pub struct i8x16(pub i8, pub i8, pub i8, pub i8, // pub i8, pub i8, pub i8, pub i8, // pub i8, pub ...
let z: i8x16 = x % y; let result: String = format!("{:?}", z); assert_eq!(result, "i8x16(\ 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1\ )".to_string()); } }
); let y: i8x16 = i8x16( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 );
random_line_split
lib.rs
#[macro_use] extern crate erlang_nif_sys; #[macro_use] extern crate ruster as nif; use nif::{Env, Term, CTerm, AsTerm, TermAs, OwnedEnv, Atom}; use nif::{open_resource_type, new_binary, ResourcePtr, Error}; use nif::{selfpid, send_from_process}; use erlang_nif_sys::{enif_priv_data, c_void, c_int}; use std::cell::C...
, _ => Err(Error::Badarg), } } fn mutate_resource(env: &mut Env, args: &[Term]) -> nif::Result<Term> { let (resnum, resterm, valterm):(i32, Term, Term) = try!(args.term_as(env)); Err(Error::Badarg) } fn reverse_binary(env: &mut Env, args: &[Term]) -> nif::Result<Term> { let (binterm,):(Term,)...
{ let p: ResourcePtr<i32> = try!(resterm.term_as(env)); Ok((*p).as_term(env)) }
conditional_block
lib.rs
#[macro_use] extern crate erlang_nif_sys; #[macro_use] extern crate ruster as nif; use nif::{Env, Term, CTerm, AsTerm, TermAs, OwnedEnv, Atom}; use nif::{open_resource_type, new_binary, ResourcePtr, Error}; use nif::{selfpid, send_from_process}; use erlang_nif_sys::{enif_priv_data, c_void, c_int}; use std::cell::C...
{ prebuilt_atom: Atom, } impl PrivData { fn new(env: &mut Env) -> PrivData { PrivData { prebuilt_atom: Atom::new(env, "prebuilt_atom"), } } } fn get_priv_data(env: &mut Env) -> &'static PrivData { unsafe { &*(enif_priv_data(env) as *mut PrivData) } } // #[deri...
PrivData
identifier_name
lib.rs
#[macro_use] extern crate erlang_nif_sys; #[macro_use] extern crate ruster as nif; use nif::{Env, Term, CTerm, AsTerm, TermAs, OwnedEnv, Atom}; use nif::{open_resource_type, new_binary, ResourcePtr, Error}; use nif::{selfpid, send_from_process}; use erlang_nif_sys::{enif_priv_data, c_void, c_int}; use std::cell::C...
fn selfsend(env: &mut Env, _args: &[Term]) -> nif::Result<Term> { let to_pid = selfpid(env); let mut msg_env = OwnedEnv::new(); let msg = 9998.as_term(msg_env.as_mut()); unsafe{ send_from_process(env, &to_pid, msg_env, msg).unwrap() }; Ok(AsTerm::term_from(env, &0)) //Ok(0.as_term(env)) } fn...
{ let (f,):(f64,) = try!(args.term_as(env)); Ok((f*2.0).as_term(env)) }
identifier_body
lib.rs
#[macro_use] extern crate erlang_nif_sys; #[macro_use] extern crate ruster as nif; use nif::{Env, Term, CTerm, AsTerm, TermAs, OwnedEnv, Atom}; use nif::{open_resource_type, new_binary, ResourcePtr, Error}; use nif::{selfpid, send_from_process}; use erlang_nif_sys::{enif_priv_data, c_void, c_int}; use std::cell::Cel...
impl PrivData { fn new(env: &mut Env) -> PrivData { PrivData { prebuilt_atom: Atom::new(env, "prebuilt_atom"), } } } fn get_priv_data(env: &mut Env) -> &'static PrivData { unsafe { &*(enif_priv_data(env) as *mut PrivData) } } // #[derive(Debug)] // struct Droppable...
prebuilt_atom: Atom, }
random_line_split